08 November 2008

Setting Up A Django Development Virtual Environment on OS X

This is a simple script I currently use to set up a Python virtualenv for Django development. It just sets up a new virtualenv and checks out the latest revision of Django from their web site. Maybe someone else will find it useful. Improvements are definitely welcome!

#! /bin/bash
virtualenv env
svn co http://code.djangoproject.com/svn/django/trunk/django env/lib/python2.5/site-packages/django
cp env/lib/python2.5/site-packages/django/bin/django-admin.py django-admin.py

I save the script in /usr/local/bin as "djangovirtualenv.sh" and whenever I want to setup a new environment I do this:

justin$ cd ~/projects
justin$ mkdir NewProject
justin$ cd NewProject
justin$ djangovirtualenv.sh
justin$ source env/bin/activate
justin$ python djangoadmin.py startproject newproject

You can get virtualenv from PyPi