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"
- The URI is constructed from the "Git Read-Only" link, and a suffix like
- zsh needs the speech marks - if you're on bash you can drop those.
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 .
Tagged in code