You are here: Home Tech Buildout for Django with PostgreSQL on OS X
Navigation
 

Buildout for Django with PostgreSQL on OS X

by Chris Shenton last modified Feb 08, 2010 06:07 PM
— filed under: , , ,

Need to install PostgreSQL from source so buildout of psycopg2 can find libraries, includes and commands.

PostgreSQL 8.4 just came out so I installed it from the .dmg installer on my OS X laptop. The pgAdmin3 GUI tool makes navigation through the database easy.

I decided to try changing my Django app to use PostgreSQL instead of my developer environment's 'sqlite', should be no problem.  Just add 'psycopg2' to the eggs=... directive that the 'djangorecipe' uses.

[buildout]
parts = django
eggs  =	psycopg2

[django]
recipe	= djangorecipe
version = 1.0.2
settings = settings
eggs	= ${buildout:eggs}
project	= filedrop

The buildout failed with mysterious messages about inability to find a file, some file, that I erroneously assumed was setup.py, even tho that file exists in the distro:

Running easy_install:
/usr/local/cshenton/Projects/smd/filedrop/django-filedrop-0.8/bin/python "-c" "from setuptools.command.easy_install import main; main()" "-mUNxd" "/usr/local/cshenton/Projects/smd/filedrop/django-filedrop-0.8/eggs/tmpFX7r84" "-Z" "/usr/local/cshenton/Projects/smd/filedrop/django-filedrop-0.8/download-cache/dist/psycopg2-2.0.11.tar.gz"
path=/usr/local/cshenton/Projects/smd/filedrop/django-filedrop-0.8/eggs/setuptools-0.6c9-py2.6.egg

Processing psycopg2-2.0.11.tar.gz
Running psycopg2-2.0.11/setup.py -q bdist_egg --dist-dir /var/folders/gs/gsjsxRPaGWWbfv9-XdzpyU+++TU/-Tmp-/easy_install-FTrfM_/psycopg2-2.0.11/egg-dist-tmp-U4W2tj
error: Setup script exited with error: No such file or directory
An error occured when trying to install psycopg2 2.0.11.

I tried earlier versions of psycopg2 and they failed, sometimes in the same way, sometimes in different ways. One of them failed in a way indicated it couldn't find the 'pg_config' command.  Ah, maybe I need to give it includes, libraries, and binaries.

Compile from source was easy: ./configure, make, sudo make install... I could use buildout's CMMI recipe for this and make it part of the project, but wanted to make it available system-wide.

Buildout still fails. 

Oh, the PostgreSQL files get installed in /usr/local/pgsql/... so add it's bin/ dir to my PATH in my ~/.bash_profile, then source it, and THEN run the buildout again. 

And it works. W00t!

And my application, after a few changes in my Django app's settings.py for the DB, works as well. Very nice.

DATABASE_ENGINE   = 'postgresql_psycopg2'
DATABASE_NAME     = 'filedrop'
DATABASE_USER     = 'postgres'
DATABASE_PASSWORD = 'The bombing starts in five minutes'
DATABASE_HOST     = ''
DATABASE_PORT     = '5432'

 

Document Actions