# christian kaula

about me

Picture of Christian Kaula

Hi there, my name is Chris and I'm a student of Media Informatics. I am a lazy coder which makes me always search for tools that save time. Besides that I do all kinds of things web for money and/or fun.

contact

You can contact me via contact form if you want to get in touch with me. Further I can be found on Xing, Twitter, djangopeople.net and djangogigs.net.

Nice to Know About virtualenvwrapper

Friday 13. November 2009

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:

#!/bin/bash

easy_install pip
pip install ipython
pip install yolk
pip install psycopg2
pip install django
pip install -e hg+http://bitbucket.org/andrewgodwin/south/@stableish#egg=south
pip install pil
pip install -e svn+http://sorl-thumbnail.googlecode.com/svn/trunk/#egg=solr
pip install -e svn+http://django-compress.googlecode.com/svn/trunk/#egg=compress

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:

#!/bin/bash

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.