2004-10-29 20:15:45 +04:00
|
|
|
Compiling and installing psycopg
|
|
|
|
********************************
|
2004-10-19 07:17:12 +04:00
|
|
|
|
2006-01-20 07:07:23 +03:00
|
|
|
** Important note: if you plan to use psyopg2 in a multithreaed application
|
|
|
|
make sure that your libpq has been compiled with the --with-thread-safety
|
|
|
|
option. psycopg2 will work correctly even with a non-thread-safe libpq but
|
|
|
|
libpq will leak memory.
|
|
|
|
|
2010-11-20 04:07:54 +03:00
|
|
|
psycopg2 uses distutils for its build process, so most of the process is
|
|
|
|
executed by the setup.py script. Before building psycopg look at
|
|
|
|
setup.cfg file and change any settings to follow your system (or taste);
|
|
|
|
then:
|
2004-10-19 07:17:12 +04:00
|
|
|
|
2004-10-29 20:15:45 +04:00
|
|
|
python setup.py build
|
2004-10-19 07:17:12 +04:00
|
|
|
|
2004-10-29 20:15:45 +04:00
|
|
|
to build in the local directory; and:
|
2004-10-19 07:17:12 +04:00
|
|
|
|
2004-10-29 20:15:45 +04:00
|
|
|
python setup.py install
|
|
|
|
|
|
|
|
to install system-wide.
|
2004-10-19 07:17:12 +04:00
|
|
|
|
2005-04-10 07:05:39 +04:00
|
|
|
|
2007-01-16 13:11:28 +03:00
|
|
|
Common errors and build problems
|
|
|
|
================================
|
|
|
|
|
|
|
|
One of the most common errors is trying to build psycopg without the right
|
|
|
|
development headers for PostgreSQL, Python or both. If you get errors, look
|
|
|
|
for the following messages and then take the appropriate action:
|
|
|
|
|
|
|
|
libpq-fe.h: No such file or directory
|
|
|
|
PostgreSQL headers are not properly installed on your system or are
|
|
|
|
installed in a non default path. First make sure they are installed, then
|
|
|
|
check setup.cfg and make sure pg_config points to a valid pg_config
|
|
|
|
executable. If you don't have a working pg_config try to play with the
|
|
|
|
include_dirs variable (and note that a working pg_config is better.)
|
|
|
|
|
|
|
|
|
2005-11-20 07:54:33 +03:00
|
|
|
Using setuptools and EasyInstall
|
|
|
|
================================
|
|
|
|
|
|
|
|
If setuptools are installed on your system you can easily create an egg for
|
|
|
|
psycopg and install it. Download the source distribution (if you're reading
|
|
|
|
this file you probably already have) and then edit setup.cfg to your taste
|
|
|
|
and build from the source distribution top-level directory using:
|
|
|
|
|
|
|
|
easy_install .
|
|
|
|
|
|
|
|
|
2005-04-10 07:05:39 +04:00
|
|
|
Compiling under Windows with mingw32
|
2005-11-20 07:54:33 +03:00
|
|
|
====================================
|
2005-04-10 07:05:39 +04:00
|
|
|
|
2006-01-05 19:56:40 +03:00
|
|
|
You can compile psycopg under Windows platform with mingw32
|
|
|
|
(http://www.mingw.org/) compiler. MinGW is also shipped with IDEs such as
|
|
|
|
Dev-C++ (http://www.bloodshed.net/devcpp.html) and Code::Blocks
|
|
|
|
(http://www.codeblocks.org). gcc binaries should be in your PATH.
|
2005-04-10 07:05:39 +04:00
|
|
|
|
2007-09-19 17:39:48 +04:00
|
|
|
You need a PostgreSQL with include and libary files installed. At least v8.0
|
|
|
|
is required.
|
2005-04-10 07:05:39 +04:00
|
|
|
|
2006-01-05 19:56:40 +03:00
|
|
|
First you need to create a libpython2X.a as described in
|
|
|
|
http://starship.python.net/crew/kernr/mingw32/Notes.html. Then run:
|
2005-04-10 07:05:39 +04:00
|
|
|
|
2006-01-05 19:56:40 +03:00
|
|
|
python setup.py build_ext --compiler=mingw32 install
|
2007-01-16 13:11:28 +03:00
|
|
|
|