[Pythonmac-SIG] Getting pyPgSQL 2.3 to build on MacOS X 10.2

Russell E Owen owen@astro.washington.edu
Mon, 16 Dec 2002 17:09:32 -0800


I've been interested in using PostgreSQL from Python but had no luck 
getting an interface to build. Then I saw the announcement today that 
pyPgSQL 2.3 was available, so I gave that a try. The good news is I 
*think* it works. However, I did find two gotchas that I want to warn 
people about:

One: the build process first failed with a complaint about a bad 
library table of contents, and suggested running ranlib. The 
following fixed that (knowing nothing about ranlib but finding the 
suggestion via google):
   cd /usr/local/pgsql/lib/
   sudo ranlib libpq.a

At this point the build and installation went fine (though I started 
with a freshly unpacked source directory, just to be on the safe 
side):
   python setup.py build
   sudo python setup.py install

The second gotcha is that the test suggested in the README fails:

% python test/PgSQLTestCases.py
running sitecustomize.py
Traceback (most recent call last):
   File "test/PgSQLTestCases.py", line 89, in ?
     from pyPgSQL import PgSQL
   File "/Archives*/UnixSoftware/pypgsql/pyPgSQL/PgSQL.py", line 349, in ?
     from libpq import *
   File "/Archives*/UnixSoftware/pypgsql/pyPgSQL/libpq/__init__.py", 
line 23, in ?
     from libpq import *
ImportError: No module named libpq

This is because I followed the README exactly and ran the test code 
from the root level of the pypgsql source distribution. This 
directory has a folder pyPgSQL, but something seems to be missing 
from that (the compiled libq module, I think). In any case, running 
the test from a different directory does much better. The tests all 
run. Well, they also all fail, but that's probably fine -- my 
PostgreSQL isn't fully set up yet. My guess is that everything is 
fine. If I find out otherwise, I'll let folks know.

-- Russell