===============================================
HOW TO INSTALL PYGRESQL ON WIN USING MS TOOLKIT
===============================================

Windows XP SP2
Python: 2.4.2
PostgreSQL 8.1.2
Microsoft Visual C++ Toolkit 2003
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) Microsoft Visual C++ Toolkit 2003,
http://msdn.microsoft.com/visualc/vctoolkit2003/
Microsoft Windows Server 2003 SP1 Platform SDK,
http://www.microsoft.com/downloads/,
Microsoft .NET Framework Version 2.0 Redistributable Package,
Microsoft .NET Framework 2.0 SDK,
http://msdn.microsoft.com/netframework/
(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.)

* In pg_config_os.h:
insert #include <winsock2.h>
before #include <windows.h>

* For the following, see also
www.vrplumber.com/programming/mstoolkit/

* Install Microsoft Visual C++ Toolkit 2003 (3).
Install Microsoft Windows Server 2003 SP1 Platform SDK.
Install Microsoft .NET Framework.
Install Microsoft .NET Framework Version 2.0 Redistributable Package.
Install Microsoft .NET Framework 2.0 SDK.

* 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

* Use the following batch script:

@echo off

Set PATH=%Programfiles%\Microsoft Platform SDK\Bin;%PATH%
Set INCLUDE=%Programfiles%\Microsoft Platform SDK\Include;%INCLUDE%
Set LIB=%Programfiles%\Microsoft Platform SDK\Lib;%LIB%

Set PATH=%Programfiles%\Microsoft Visual C++ Toolkit 2003\bin;%PATH%
Set INCLUDE=%Programfiles%\Microsoft Visual C++ Toolkit 2003\include;%INCLUDE%
Set LIB=%Programfiles%\Microsoft Visual C++ Toolkit 2003\lib;%LIB%
Set LIB=%Programfiles%\Microsoft Visual Studio 8\VC\lib;%LIB%

Set PATH=%PATH%;%Programfiles%\PostgreSQL\8.1\bin
Set INCLUDE=%INCLUDE%;%Programfiles%\PostgreSQL\8.1\include\server\port\win32\sys Set INCLUDE=%INCLUDE%;%Programfiles%\PostgreSQL\8.1\include\server\port\win32
Set INCLUDE=%INCLUDE%;%Programfiles%\PostgreSQL\8.1\include\server
Set INCLUDE=%INCLUDE%;%Programfiles%\PostgreSQL\8.1\include\
Set LIB=%LIB%;%Programfiles%\PostgreSQL\8.1\lib
Set LIB=%LIB%;%Programfiles%\PostgreSQL\8.1\lib\ms

Set PATH=%PATH%;%Programfiles%\Python
Set INCLUDE=%INCLUDE%;%Programfiles%\Python\include
Set LIB=%LIB%;%Programfiles%\Python\libs

cl -DWIN32 -DNDEBUG /LD /Fe_pg.dll pgmodule.c libpq.lib

copy _pg.dll %Programfiles%\Python\Lib\site-packages\_pg.dll

*** 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

Reply via email to