Compiling PostgreSQL and Psycopg 1.1.9 on Mac OS X 10.4 Tiger
So, compiling and installing PostgreSQL from source is pretty easy: Follow the instructions Apple posted. For variation I used the niload utility to create a new user and group for postgres rather than going through System Preferences (try this article for help with that). That done, I needed to install psycopg
Having downloaded and untarred the sources for psycopg 1.1.9 I was a little surprised to see that I had to do the configure-make-make install dance, and not use python setup.py. I ran into a couple of little problems, which is why this is here.
The first problem I encountered was that configure couldn't locate the PostgreSQL headers, and the usual --with-includes option didn't work. I found the answer in a mailing list archive via google pretty quickly though.
Next I realised that I needed to point it to the headers for the mxDateTime extension. Installing this is a nice-and-simple sudo python setup.py install job, so make sure you've grabbed the files and installed it. I found the magic invocation to point psycopg's configure to the mxDateTime stuff in the same place I found the solution to the PostgreSQL headers problem, which was good.
And then the ./configure step worked fine, but the problems weren't finished there: make exited with the following error:
/usr/bin/ld: flag: -undefined dynamic_lookup can't be used with
MACOSX_DEPLOYMENT_TARGET environment variable set to: 10.1
collect2: ld returned 1 exit status
make: *** [psycopgmodule.so] Error 1
The problem here is that (I suspect) there's a mismatch between the version of autoconf or libtool or whatever it was that generated the original makefile and the versions which ship with 10.4. dynamic_lookup was introduced in 10.3. The solution is to force make's hand and tell it what MACOSX_DEPLOYMENT_TARGET it should be using by passing in an explicit value for that environment variable.
That was the last problem, and I was then able to get psycopg built and working fine.
The following instructions assume that you're running the stock Python 2.3.5 that comes with 10.4 and that you've installed PostgreSQL in /usr/local/pgsql, which is the default location and what you should get if you've just followed Apple's instructions.
So, this is what I needed to do to get everything working:
$ ./configure --with-postgres-libraries=/usr/local/pgsql/lib \
> --with-postgres-includes=/usr/local/pgsql/include \
> --with-mxdatetime-includes=/usr/lib/python2.3/site-packages/mx/DateTime/mxDateTime
$ make MACOSX_DEPLOYMENT_TARGET=10.4
$ sudo make install
Ta da.
- 27.7.2005, 13.43
- File under: software, Mac OS X, Mac OS X Tiger, compiling, instructions, PostrgreSQL, Python