Since I'm mostly working on various Django projects I am working with virtualenv/virtualenvwrapper a lot. It allows to encapsulate environments and keep them identical across all servers your app will run on.

The Problem

All this means setting up pretty much the same Python environment over and over again:

Quite tedious after your nth project really.

The Solution

After reading how virtualenv allows bootstrapping environments and as such reducing tedious work I wondered if that can be done with virtualenvwrapper, too. Turns its absolutely possible.

There actually are quite a few hooks in virtualenvwrapper that allow for stuff being run pre- and post- creating/deleting/activating environments. Now my postmkvirtualenv script looks like this:


easy_install pip
pip install ipython
pip install yolk
pip install psycopg2
pip install django
pip install -e hg+
pip install pil
pip install -e svn+
pip install -e svn+

Now whenever I create an environment with mkvirtualenv someproject all my standard Python packages and Django apps get installed automagically. And then I'm able to put something like this in my postactiveate script:


cd /Users/me/Projects/someproject/

So whenever I activate my environment with workon someproject I get beamed right into my project dir and can start hacking right away. Nice and easy.