April 22, 2006
[Daniel] Django From Subversion on Mac OS X
Right. So I'm enamoured with Django, a Python web framework. It's very well done, fast and internationalized. Two days ago, Adrian, a project lead for Django, announced the impending release of the "magic-removal" branch of Django. Since I am in the early stages of Wagging Work and this is the future of Django, I wanted to port it all now up front. What I had been working on was the official "egg" release of Django (0.91). Installing Django from Subversion proved to be a challenge.My setup is Mac OS X (10.4.6), MySQL 4.1.12, Subversion 1.2.3 and Python 2.4.1. My Python install is in "/Library/Frameworks/Python.framework /Versions/2.4/lib" so site-packages is located at "/Library/Frameworks/Python.framework /Versions/2.4/lib/python2.4 /site-packages".
Step 1: Grab Django.
In a suitable place in your home directory, use Subversion to grab the magic-removal branch. In "~/Documents/Code/Python", I ran:
svn co http://code.djangoproject.com/svn/django/branches/magic-removal django_svnLots of line will scroll by as Subversion fetches all the files used by Django. Once it's complete, you'll get a friendly little message like "Checked out revision 2724." Time to move along.
Step 2: Symlink Django
In "/Library/Frameworks/Python.framework /Versions/2.4/lib/python2.4 /site-packages", run the following command (and watch the path carefully. One too many tries at this did I symlink the wrong (one too high) directory and met with spectacular failure):
sudo ln -s ~/Documents/Code/Python/django_svn/django djangoNow, cd to "/usr/local/bin" (or "/usr/bin" if local isn't in your PATH) and run the following symlink:
sudo ln -s /Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/site-packages/django/bin/django-admin.py django-admin.pyThere should now be a convenient symlink there pointing to the appropriate spot. To test if this worked, start a new shell, type in "dj" and hit the Tab key. If it completes to "django-admin.py", your symlink is working. Don't hit "Enter"/"Return" just yet because...
Step 3: Edit your environment variables
...you don't have the needed environment variables present. Without these, you'll get errors like "from django.core import management ImportError"s. So you need to put in the environment variables so Django can find its files. Since I'm going to be using this a lot, I'm setting these items in my "~/.bash_profile" file. You can execute these from the shell directly but you must do it with every new shell you want to use the "django-admin.py" tool in.
PYTHONPATH=/Users/cowz/Documents/Code/Python/django_svn
export PYTHONPATHObviously, substitute your path accordingly. I believe this has to point back to the original Subversion directory to work, though I have not tried it using the "/Library/Frame..." path. Save the "~/.bash_profile" file.
Step 4: Bliss
Start a new shell, type in "django-admin.py startproject whee" and enjoy your newly Subversion-ized Django install. Even better, now all you have to do to update Django is cd into your "~/Documents/Code/Python/django_svn" directory and run the following command:
svn updateThe new files will be fetched and you'll automatically be running the most current Django code. Enjoy!
Permalink
|
Comments (0)

