mirror of
https://github.com/psycopg/psycopg2.git
synced 2024-11-10 19:16:34 +03:00
* libpq.dll not used anymore. win32 setup uses pg_config too.
* Some typo fixed.
This commit is contained in:
parent
96ff591d79
commit
3076046b3f
|
@ -1,3 +1,7 @@
|
|||
2006-01-06 Daniele Varrazzo <daniele.varrazzo@gmail.com>
|
||||
|
||||
* setup.py: libpq.dll not used anymore. win32 setup uses pg_config too.
|
||||
|
||||
2006-01-05 Federico Di Gregorio <fog@initd.org>
|
||||
|
||||
* psycopg/psycopgmodule.c (psyco_set_error): added function to set extra
|
||||
|
|
61
INSTALL
61
INSTALL
|
@ -30,59 +30,14 @@ and build from the source distribution top-level directory using:
|
|||
Compiling under Windows with mingw32
|
||||
====================================
|
||||
|
||||
You can compile psycopg under Windows platform with mingw32 compiler. The
|
||||
software required is:
|
||||
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.
|
||||
|
||||
* MinGW (http://www.mingw.org/). You also get MinGW installed by installing
|
||||
Dev-C++ IDE (http://www.bloodshed.net/devcpp.html);
|
||||
You need a PostgreSQL with include and libary files installed. At least v8.0 is required.
|
||||
|
||||
* either:
|
||||
* a binary PostgreSQL installation with include and libary files, at least
|
||||
release 8.0 (http://www.postgresql.org/download/);
|
||||
* PostgreSQL sources. You will need to compile PostgreSQL, which also
|
||||
requires MSYS (http://www.mingw.org/msys.shtml) and Flex and Bison
|
||||
packages (http://gnuwin32.sourceforge.net/packages.html).
|
||||
First you need to create a libpython2X.a as described in
|
||||
http://starship.python.net/crew/kernr/mingw32/Notes.html. Then run:
|
||||
|
||||
I assume all the software installed in the standard way. gcc compiler directory
|
||||
should be in your path.
|
||||
|
||||
Steps required to package your own version of psycopg:
|
||||
|
||||
1. if building from PostgreSQL binaries:
|
||||
|
||||
1.1. create the file libpqdll.a (you should already know how to build
|
||||
Python extensions with mingw: see
|
||||
http://starship.python.net/crew/kernr/mingw32/Notes.html for
|
||||
details):
|
||||
|
||||
1.1.1. cd C:\Program Files\PostgreSQL\8.0\lib
|
||||
|
||||
1.1.2. pexports C:\WINNT\system32\libpq.dll > libpqdll.def
|
||||
|
||||
1.1.3. dlltool --dllname libpq.dll --def libpqdll.def \
|
||||
--output-lib libpqdll.a
|
||||
|
||||
2. else, if building from PostgreSQL source:
|
||||
|
||||
2.1. compile it:
|
||||
|
||||
2.1.1. unpack postgresql source (ex. in c:\)
|
||||
|
||||
2.1.2. run MSYS
|
||||
|
||||
2.1.3. cd /c/postgresql-8.0
|
||||
|
||||
2.1.4. ./configure --without-zlib
|
||||
|
||||
2.1.5. make
|
||||
|
||||
2.2. create the file libpqdll.a (dlltool is part of MinGW):
|
||||
|
||||
2.2.1. cd postgresql-8.0\src\interfaces\libpq
|
||||
|
||||
2.2.2. dlltool --dllname libpq.dll --def libpqdll.def \
|
||||
--output-lib libpqdll.a
|
||||
|
||||
3. build psycopg:
|
||||
|
||||
3.1. python setup.py build_ext --compiler=mingw32 install
|
||||
python setup.py build_ext --compiler=mingw32 install
|
||||
|
|
|
@ -4,7 +4,7 @@ This module holds all the extensions to the DBAPI-2.0 provided by psycopg.
|
|||
|
||||
- `connection` -- the new-type inheritable connection class
|
||||
- `cursor` -- the new-type inheritable cursor class
|
||||
- `adapt()` -- exposes the PEP-246_ compatile adapting machanism used
|
||||
- `adapt()` -- exposes the PEP-246_ compatible adapting mechanism used
|
||||
by psycopg to adapt Python types to PostgreSQL ones
|
||||
|
||||
.. _PEP-246: http://www.python.org/peps/pep-0246.html
|
||||
|
|
12
setup.cfg
12
setup.cfg
|
@ -43,15 +43,3 @@ use_decimal=0
|
|||
# libraries required to link in "libraries".
|
||||
#library_dirs=
|
||||
#libraries=
|
||||
|
||||
|
||||
# Windows-only definitions
|
||||
# ------------------------
|
||||
|
||||
# The postgresql directory. It can be either the root of a source tree or the
|
||||
# location of a binary installation
|
||||
pgdir=C:\Program files\PostgreSQL\8.0
|
||||
#pgdir=D:\postgresql-8.0.1
|
||||
|
||||
# Dynamically build against libpq.dll
|
||||
use_pg_dll=0
|
||||
|
|
128
setup.py
128
setup.py
|
@ -27,9 +27,6 @@ UPDATEs. psycopg 2 also provide full asycronous operations for the really
|
|||
brave programmer.
|
||||
"""
|
||||
|
||||
# Enable generators on Python 2.2
|
||||
from __future__ import generators
|
||||
|
||||
classifiers = """\
|
||||
Development Status :: 4 - Beta
|
||||
Intended Audience :: Developers
|
||||
|
@ -48,7 +45,6 @@ Operating System :: Unix
|
|||
|
||||
import os
|
||||
import sys
|
||||
import shutil
|
||||
import popen2
|
||||
from distutils.core import setup, Extension
|
||||
from distutils.errors import DistutilsFileError
|
||||
|
@ -77,21 +73,16 @@ class psycopg_build_ext(build_ext):
|
|||
"""
|
||||
user_options = build_ext.user_options[:]
|
||||
user_options.extend([
|
||||
('pgdir=', None,
|
||||
"The postgresql directory, either source or bin (win32 only)"),
|
||||
('use-pg-dll', None,
|
||||
"Build against libpq.dll (win32 only)"),
|
||||
('use-pydatetime', None,
|
||||
"Use Python datatime objects for date and time representation."),
|
||||
('pg_config=', None,
|
||||
"The name of the pg_config binary and/or full path to find it"),
|
||||
('pg-config=', None,
|
||||
"The name of the pg_config binary and/or full path to find it"),
|
||||
('use-decimal', None,
|
||||
"Use Decimal type even on Python 2.3 if the module is provided."),
|
||||
])
|
||||
|
||||
boolean_options = build_ext.boolean_options[:]
|
||||
boolean_options.extend(('use-pg-dll', 'use-pydatetime', 'use-decimal'))
|
||||
|
||||
# libpq directory in win32 source distribution: compiler dependant.
|
||||
libpqdir = None
|
||||
boolean_options.extend(('use-pydatetime', 'use-decimal'))
|
||||
|
||||
def initialize_options(self):
|
||||
build_ext.initialize_options(self)
|
||||
|
@ -101,7 +92,7 @@ class psycopg_build_ext(build_ext):
|
|||
self.pg_config = "pg_config"
|
||||
|
||||
def get_pg_config(self, kind):
|
||||
p = popen2.popen3(self.pg_config + " --" + kind, mode="r")
|
||||
p = popen2.popen3(self.pg_config + " --" + kind, mode="t")
|
||||
r = p[0].readline().strip()
|
||||
if not r:
|
||||
raise Warning(p[2].readline().strip())
|
||||
|
@ -126,53 +117,11 @@ class psycopg_build_ext(build_ext):
|
|||
build_ext.build_extensions(self)
|
||||
|
||||
def finalize_win32(self):
|
||||
"""Finalize build system configuration on win32 platform.
|
||||
|
||||
Address issues related to the different environmental configurations
|
||||
that can be met:
|
||||
|
||||
* msvc or gcc derived (mingw, cygwin) compiler;
|
||||
* source or bin PostgreSQL installation
|
||||
* static or dynamic linking vs. libpq.dll
|
||||
"""
|
||||
self.include_dirs.append(".")
|
||||
"""Finalize build system configuration on win32 platform."""
|
||||
self.libraries.append("ws2_32")
|
||||
|
||||
if self.build_from_src():
|
||||
self.include_dirs.append(os.path.join(
|
||||
self.pgdir, "src", "interfaces", "libpq"))
|
||||
self.include_dirs.append(os.path.join(
|
||||
self.pgdir, "src", "include"))
|
||||
|
||||
if self.get_compiler() == "msvc":
|
||||
self.libpqdir = os.path.join(
|
||||
self.pgdir, "src", "interfaces", "libpq", "Release")
|
||||
else:
|
||||
self.libpqdir = os.path.join(
|
||||
self.pgdir, "src", "interfaces", "libpq")
|
||||
|
||||
self.library_dirs.append(self.libpqdir)
|
||||
|
||||
else:
|
||||
self.include_dirs.append(os.path.join(
|
||||
self.pgdir, "include"))
|
||||
self.library_dirs.append(os.path.join(
|
||||
self.pgdir, "lib"))
|
||||
|
||||
# Remove the library that was added in the finalize_options, since:
|
||||
# 1) We do not need it because we are using the DLL version, or
|
||||
# 2) We do need it, but it might need to be msvc'ified, and
|
||||
# 3) The other benefit is that msvc needs pqdll to be the last
|
||||
self.libraries.remove("pq")
|
||||
|
||||
if self.use_pg_dll:
|
||||
self.libraries.append(self.get_lib("pqdll"))
|
||||
else:
|
||||
self.libraries.append("advapi32")
|
||||
|
||||
if self.get_compiler() == "msvc":
|
||||
self.libraries.append("shfolder")
|
||||
self.libraries.append(self.get_lib("pq"))
|
||||
self.libraries.append("advapi32")
|
||||
if self.get_compiler() == "msvc":
|
||||
self.libraries.append("shfolder")
|
||||
|
||||
def finalize_darwin(self):
|
||||
"""Finalize build system configuration on darwin platform."""
|
||||
|
@ -193,58 +142,6 @@ class psycopg_build_ext(build_ext):
|
|||
if hasattr(self, "finalize_" + sys.platform):
|
||||
getattr(self, "finalize_" + sys.platform)()
|
||||
|
||||
def run(self):
|
||||
build_ext.run(self)
|
||||
|
||||
# Add libpq.dll to the lib directory. libpq.dll can be in a wide
|
||||
# variety of places. The easiest way to add it to the distribution is
|
||||
# to have a copy in a fixed place (lib).
|
||||
if sys.platform == 'win32' and self.use_pg_dll:
|
||||
shutil.copy(self.find_libpq_dll(), "lib")
|
||||
|
||||
## win32-specific stuff ##
|
||||
|
||||
def build_from_src(self):
|
||||
"""Detect if building from postgres source or bin on w32 platform"""
|
||||
return os.path.exists(os.path.join(self.pgdir, "src"))
|
||||
|
||||
def get_lib(self, name):
|
||||
"""Return the full library name given its suffix.
|
||||
|
||||
MS VC compiler doesn't assume a "lib" prefix as gcc derived ones do.
|
||||
Return the library name as required by the compiler.
|
||||
"""
|
||||
if sys.platform == 'win32' and self.get_compiler() == "msvc":
|
||||
return "lib" + name
|
||||
else:
|
||||
return name
|
||||
|
||||
__libpqdll = None
|
||||
|
||||
def find_libpq_dll(self, *dirs):
|
||||
"""Return the full libpq.dll path and name."""
|
||||
if self.__libpqdll:
|
||||
return self.__libpqdll
|
||||
|
||||
for path in self.__iter_libpq_dll():
|
||||
if os.path.exists(path):
|
||||
sys.stdout.write("libpq.dll found in %s\n"
|
||||
% os.path.dirname(path))
|
||||
self.__libpqdll = path
|
||||
return path
|
||||
|
||||
raise DistutilsFileError("Can't find libpq.dll on the system")
|
||||
|
||||
def __iter_libpq_dll(self):
|
||||
"""Iterate on the possible filenames for libpq.dll."""
|
||||
# in the build dir for src installation
|
||||
if self.libpqdir:
|
||||
yield os.path.join(self.libpqdir, "libpq.dll")
|
||||
|
||||
# somewhere in the path - probably in system32 - for bin dist
|
||||
for path in os.environ['PATH'].split(os.pathsep):
|
||||
yield os.path.join(path, "libpq.dll")
|
||||
|
||||
# let's start with macro definitions (the ones not already in setup.cfg)
|
||||
define_macros = []
|
||||
include_dirs = []
|
||||
|
@ -337,11 +234,6 @@ if sys.platform != 'win32':
|
|||
else:
|
||||
define_macros.append(('PSYCOPG_VERSION', '\\"'+PSYCOPG_VERSION_EX+'\\"'))
|
||||
|
||||
|
||||
if sys.platform == 'win32' and int(parser.get('build_ext', 'use_pg_dll')):
|
||||
data_files.append((".\\lib\\site-packages\\psycopg2\\",
|
||||
[ "lib\\libpq.dll" ]))
|
||||
|
||||
# build the extension
|
||||
|
||||
sources = map(lambda x: os.path.join('psycopg', x), sources)
|
||||
|
|
Loading…
Reference in New Issue
Block a user