Enhancements to virtualenv
Project description
Quick Setup
- Add a line like export WORKON_HOME=$HOME/.virtualenvs to your .bashrc.
- Add a line like source /path/to/this/file/virtualenvwrapper_bashrc to your .bashrc.
- Run: source ~/.bashrc
- Run: workon
- A list of environments, empty, is printed.
- Run: mkvirtualenv temp
- Run: workon
- A new environment, temp is created and activated.
- This time, the temp environment is included.
Path Management
Sometimes it is desirable to share installed packages that are not in the system site-pacakges directory and which you do not want to install in each virtualenv. In this case, you could symlink the source into the environment site-packages directory, but it is also easy to add extra directories to the PYTHONPATH by including them in a .pth file inside site-packages using add2virtualenv.
- Check out the source for a big project, such as Django.
- Run: add2virtualenv path_to_source.
- Run: add2virtualenv.
- A usage message and list of current “extra” paths is printed.
References
For more details, refer to the column I wrote for the May 2008 issue of Python Magazine: virtualenvwrapper | And Now For Something Completely Different.