=========================================
HOW TO INSTALL PYGRESQL ON WIN USING MSYS
=========================================
Windows XP SP2
Python: 2.4.2
PostgreSQL 8.1.2
MinGW/MSYS 5.0
PyGreSQL 3.8
*** Required resources ***
(1) Python 2.4.2 binaries for Windows,
www.python.org/ftp/python/2.4.2/python-2.4.2.msi
(2) PostgreSQL 8.1.2 binaries for Windows,
www.postgresql.org/ftp/binary/v8.1.2/win32/
(3) Current MinGW and MSYS (Windows exe installer),
prdownloads.sf.net/mingw/MinGW-5.0.0.exe
prdownloads.sf.net/mingw/MSYS-1.0.10.exe
(4) PyGreSQL 3.8 source,
ftp.pygresql.org/pub/distrib/PyGreSQL-3.8.tgz
*** Installation ***
* Install Python (1)
* Install PostgreSQL (2)
Add "Include Files" and "Library files" from "Development"
feature when asked for the installation options.
* In %PostgreSQLPath%\include\server\pg_config.h,
undefine the following switches:
#undef USE_SSL
#undef ENABLE_NLS
#undef USE_REPL_SNPRINTF
(So the PostgreSQL header files will not try to include
these libraries and functions when compiling PyGreSQL;
they are not needed here.)
* Install MinGW and MSYS (3) (in this order)
* Edit the file "%MinGWpath%\lib\gcc\%MinGWversion%\specs"
and change the entry that reads -lmsvcrt to -lmsvcr71.
* Copy pygresql-3.8.tgz (4)
into your home directory in the MSYS shell.
start the MSYS shell and unpack the file:
tar -xzf PyGreSQL-3.8.tgz
# Mount the installation directories of (1) and (2):
echo $PROGRAMFILES/Python /python >>/etc/fstab
echo $PROGRAMFILES/PostgreSQL/8.1 /postgresql >>/etc/fstab
# Build PyGreSQL as follows:
cd PyGreSQL-3.8
gcc -c -O2 -DWIN32 \
-I/python/include \
-I/postgresql/include \
-I/postgresql/include/server \
-I/postgresql/include/server/port/win32 \
pgmodule.c
# (ignore the warning about redefinition of HAVE_STRERROR)
gcc -shared pgmodule.o -o _pg.dll \
-L/python/libs -lpython24 \
-L/postgresql/lib -lpostgres -lpq
# Install PyGreSQL:
cp pg*.py _pg.dll /python/Lib/site-packages
*** Open Problem ***
All functions which are using PQprint will crash (see below),
if you are using the libpq.dll in the binary distribution.
With a self-compiled version of libpq.dll it worked however.
*** Testing ***
* Start the PostgreSQL server
* Start Python (command line) and
enter the following statements in Python:
from pg import DB
db = DB('template1', user='postgres', passwd='secret')
q = db.query("select (1+1)*3*7 as the_answer")
print q.dictresult()[0]
# this should print {'the_answer': 42}
print str(q)
# this should print "<pg query result>"
print q
# this crashes, but it should print:
the_answer
----------
42
(1 row)
_______________________________________________
PyGreSQL mailing list
[email protected]
http://mailman.vex.net/mailman/listinfo/pygresql