Python: Difference between revisions
Adisbladis (talk | contribs) m Remove mention of pip2nix. This tool just barely works and shouldn't be mentioned in this context. |
Adisbladis (talk | contribs) Use python.override correctly instead of incorrect inline hack. |
||
| Line 68: | Line 68: | ||
let | let | ||
pkgs = import <nixpkgs> {}; | pkgs = import <nixpkgs> {}; | ||
python = pkgs.python3.override { | |||
self = python; | |||
packageOverrides = pyself: pyfinal: { | |||
toolz = pyfinal.callPackage ./toolz.nix { }; | |||
}; | |||
}; | |||
in pkgs.mkShell { | in pkgs.mkShell { | ||
packages = [ | packages = [ | ||
( | (python.withPackages (python-pkgs: [ | ||
# select Python packages here | # select Python packages here | ||
python-pkgs.pandas | python-pkgs.pandas | ||
python-pkgs.requests | python-pkgs.requests | ||
python-pkgs.toolz | |||
])) | ])) | ||
]; | ]; | ||
} | } | ||
</syntaxhighlight> | </syntaxhighlight>Next time you enter the shell specified by this file, Nix will build and include the Python package you have written. | ||
Next time you enter the shell specified by this file, Nix will build and include the Python package you have written. | |||
==== Using nix-shell alongside pip ==== | ==== Using nix-shell alongside pip ==== | ||
When working on a collaborative python project you may want to be able to <code>pip install -r requirements.txt</code> if the project isn't packaged for nix specifically. | When working on a collaborative python project you may want to be able to <code>pip install -r requirements.txt</code> if the project isn't packaged for nix specifically. | ||