Note
Be aware that this code is still in very experimental.
Tools in this repository should provide better way to work with Python and Nix.
End goal is to replace virtualenv and provide better build time isolation
then virtualenv does, while still having the possibility to use tools that
python developers are familiar with (eg pip, easy_install, buildout, ...).
Contents
No. Well at least not for me :)
Well to be honest virtualenv does the job that it promises, but many times this is not enough. Many times system packages are needed to be able to install specific python packages, eg. lxml, Pillow, ...
And nix-virtualenv can install system packages (even MySQL or PostgreSQL).
Make sure Nix is installed:
% curl https://nixos.org/nix/install | sh
or follow the manual.
Clone this repository and place
bin/folder of this repository to$PATH. eg.::% git clone git://github.com/garbas/nix-virtualenv % echo "export PATH=`pwd`/nix-virtualenv/bin:\$PATH" >> ~/.profile
To install packages::
~ % ./bin/nix-virtualenv-py27 examples ... (nix-shell) ~/examples % pip install pyramid ... or ... (nix-shell) ~/examples % easy_install pyramid ... or ... (nix-shell) ~/examples % buildout -c buildout.cfg
To start working on python package::
(nix-shell) ~/examples % python setup.py develop --prefix $PYTHONPREFIX
To install other packages from nixpkgs you can pass them via -p parameter:
% ./bin/nix-virtualenv-py27 examples -p lxml -p postgresql (nix-shell) ~/examples % which psql /nix/store/...-postgresql-9.2.10/bin/psql (nix-shell) ~/examples % python -c "import lxml; print lxml.__file__" /nix/store/...-python2.7-lxml-3.3.6/lib/python2.7/site-packages/lxml/__init__.pyc
Can virtualenv do this? :)
There are few scripts inside bin folder in this repository starting with
the name nix-virtualenv. You can use this scripts to create python
environment as you would with virtualenv.
After running any of the nix-virtualenv-pyXX script use buildout,
pip and easy_install as you're used.
TODO: explain how internals work once implementations settles
- TODO:
python setup.py developshould use --prefix without specifying it - BUG:
pip --editabletries to install into/nix/store/... - BUG:
pip --upgradedoes not work since it tries to upgrade package in place, which is in/nix/store/... - TODO: patch tox to use
nix-virtualenvinstead ofvirtualenv. https://bitbucket.org/hpk42/tox/src/master/tox/_venv.py?at=default#cl-174
Report them to issue tracker:
https://github.com/garbas/nix-virtualenv/issues
or ping me on IRC
garbas on freenode.net