Django with PostgreSQL on Mac OS X Tiger

Most of the time, when I have worked on django projects, I’ve used the
SQLite backend for development on my PowerBook and deployed to
PostgreSQL on my Linux server. For the project I’m working on right now,
though, that turned into an issue when some of the queries that ran fine
on my dev system didn’t work at all on the production box. Apparently
the backend code responsible for assembling the SQL query strings was
producing different text for SQLite and PostgreSQL. So I could avoid
similar issues in the future, I set out to install PostgreSQL on my
laptop today.

Installing PostgreSQL itself turned out to be very easy indeed. I
downloaded the universal installer from Andy Satori’s “PostgreSQL for
” site. Some of the GUI clients included don’t work because I’m
on a PPC PowerBook instead of an x86 MacBook or MacBook Pro, but that’s
OK. I can use the CLI tools, which work fine.

The next thing I needed to do was set up psycopg. That turned out
to be a bit of an issue, since is having some sort of server
problem on their site. I was eventually able to download the tarball
with the sources for psycopg 1.1.21.

In order to compile psycopg, I also needed mxDateTime from eGenix.
They offer several pre-compiled packages, but none would install for me.
Working from the source for 3.0.0, I was able to compile it myself via
python install” into my virtualenv sandbox.

Back in the psycopg build directory, I was able to use these
, but had to hack around a bit to get the mxDateTime
headers in a place that matched the psycopg build expectations. I tried
several variations of path names into the mx source tree, but eventually
gave up and copied them all to one directory:

$ cd egenix-mx-base-3.0.0$ mkdir include$ find . -name '*.h' -exec cp {} `pwd`/include/ ;

I then tried to configure psycopg with:

$ ./configure --with-postgres-libraries=/Library/PostgreSQL8/lib --with-postgres-includes=/Library/PostgreSQL8/include --with-mxdatetime-includes=../egenix-mx-base-3.0.0/include/

That failed to find the Python.h header until I ran configure outside
of my virtualenv environment, using the copy of Python 2.5 I had
installed ages ago from Obviously your path to the mx
includes may vary, but that installer package for the PostgreSQL server
will put everything in /Library/PostgreSQL8.

Once I had configure running, I ran make (still outside of my
virtualenv). The build succeeded, and then I went over to the shell
running my virtual environment to install from there (via a simple “make

The end result of all of that was PostgreSQL 8.2.5 installed globally,
and the mx 3.0.0 and psycopg 1.1.21 packages installed only in my
virtual environment.

After a quick createdb, and edit to my file, I was
able to sync up my dev server against the new database and get back to
work. I suspect, but can’t verify, that I would have had fewer issues if
I was on an x86 Mac of some sort or running Leopard, since many of these
packages seem to have moved on ahead of my platform. The whole thing
took just over an hour, most of which was me fumbling around trying to
find compatible versions of the source for the various pieces since it
has been so long since I’ve compiled any of this stuff.