FRidh / python-on-nix

UNMAINTAINED - Please check Nixpkgs manual instead - Tutorial showing you can use Python on Nix
39 stars 7 forks source link

How to use pip to install python packages #1

Open knedlsepp opened 8 years ago

knedlsepp commented 8 years ago

First of all thank you for the nice summary. It's great to read others' findings on how to work efficiently with these two tools. The main documentation on nixos.org is not very clear at the moment... I was wondering how you go about installing packages from the pypi cheeseshop. If something is not available in nixpkgs, it's not really clear how I can get my hands on it in the right way. I have been considering different methods, each with it's up- and downsides. Maybe you could share your experience and add methods I didn't think of. This is my current list:

FRidh commented 8 years ago

Thanks for your feedback @knedlsepp . Indeed, it would be good to add a section about how to use PyPI packages as well.

I generally create the Nix expressions for new packages by hand and get them merged in nixpkgs as fast as possible. In the meantime, I have a shell.nix file where I add such expressions as well. You might also like how it's organized in this repository

I actually never tried creating virtualenvs on Nix, so I can't say anything about that.

knedlsepp commented 8 years ago

So instead of a "pip install xxx", you create your xxx.nix file inside your project folder (or somewhere else? the ~/.nix-defexpr maybe?), import it with a nix expression from within a "shell.nix" file and then use the nix-shell command to have it available?

FRidh commented 8 years ago

Sorry for the extremely late reply, but yes, I have several shell.nix files which I use to build Python packages and build Python environments. In the root of my $HOME I have a shell.nix which builds a Python environment with common packages I use.

Often I am developing Python packages which develop on other packages. In the root of the package I'm working on I also keep a develop.nix which I use with nix-shell develop. Because setup.py is in the same folder this package will be installed in editable mode.