23 May 2013

Convenient Virtualenv Python hacking

A convenient pattern for testing a bit of Python code in a virtualenv.

mkvirtualenv test
pip install -e "git://github.com/mafrosis/salt-cloud.git#egg=codetest"

A python egg package ends up in site-packages, pointing at a directory in the virtualenv where the code is:

> cat $VIRTUAL_ENV/lib/python2.7/site-packages/salt-cloud.egg-link
/Users/null/.virtualenvs/test/src/salt

You could hack comfortably on the code in that directory, and then when you're finished just delete the folder at $VIRTUAL_ENV to clean up.

If you already have some code cloned into a local directory, you can install it from its current path (instead of into the $VIRTUAL_ENV directory) using this:

pip install -e .

:x


Tagged in code