First real commit

This commit is contained in:
2024-02-27 14:56:36 -08:00
parent 818a1d53a1
commit 3e2f18ae04
15 changed files with 546 additions and 0 deletions
+2
View File
@@ -0,0 +1,2 @@
nix_direnv_watch_file requirements.txt
use flake
+3
View File
@@ -0,0 +1,3 @@
__pycache__
/.direnv
+45
View File
@@ -0,0 +1,45 @@
# python-shell
## Using
- dev shell: `nix develop`
- edit `requirements.txt` for dev shell requirements
## Jupyter in VSCode
To use jupyter in VSCode add these requirements:
```
ipykernel
nbformat
ipywidgets
```
## Updating mach-nix pypi deps db
Add to inputs:
```nix
pypi-deps-db = {
url = "github:davhau/pypi-deps-db/0000000000000000000000000000000000000000";
flake = false;
};
mach-nix.inputs.pypi-deps-db.follows = "pypi-deps-db";
```
## Adding git dependency
Add to mkPython ([more info](https://github.com/DavHau/mach-nix/blob/master/examples.md)):
```nix
packagesExtra = [
(mach.buildPythonPackage
{
src = builtins.fetchGit {
url = "https://github.com/user/repo";
ref = "branch";
rev = "0000000000000000000000000000000000000000";
};
})
];
```
+35
View File
@@ -0,0 +1,35 @@
{
description = "Python shell flake";
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
flake-utils.url = "github:numtide/flake-utils";
mach-nix.url = "github:davhau/mach-nix";
};
outputs = { self, nixpkgs, mach-nix, flake-utils, ... }:
let
pythonVersion = "python39";
in
flake-utils.lib.eachDefaultSystem (system:
let
pkgs = nixpkgs.legacyPackages.${system};
mach = mach-nix.lib.${system};
pythonEnv = mach.mkPython {
python = pythonVersion;
requirements = builtins.readFile ./requirements.txt;
};
in
{
devShells.default = pkgs.mkShellNoCC {
packages = [ pythonEnv ];
shellHook = ''
export PYTHONPATH="${pythonEnv}/bin/python"
'';
};
}
);
}
Executable
+3
View File
@@ -0,0 +1,3 @@
#!/usr/bin/env python
print("Hello world!")
View File