mirror of
https://github.com/psycopg/psycopg2.git
synced 2024-11-26 19:03:43 +03:00
We now use pg_config in setup.py (closes: #70).
This commit is contained in:
parent
c79e92e928
commit
d5674253ca
|
@ -1,3 +1,8 @@
|
||||||
|
2006-01-05 Federico Di Gregorio <fog@initd.org>
|
||||||
|
|
||||||
|
* setup.{cfg,py}: we now use pg_config to locate PostgreSQL libraries
|
||||||
|
and headers (modified patch from lbruno, see #70.)
|
||||||
|
|
||||||
2006-01-01 Federico Di Gregorio <fog@initd.org>
|
2006-01-01 Federico Di Gregorio <fog@initd.org>
|
||||||
|
|
||||||
* Preparing release 2 beta 7.
|
* Preparing release 2 beta 7.
|
||||||
|
|
17
setup.cfg
17
setup.cfg
|
@ -20,16 +20,23 @@ use_decimal=0
|
||||||
# uncommenting the following line and setting its value to the right path.
|
# uncommenting the following line and setting its value to the right path.
|
||||||
#mx_include_dir=
|
#mx_include_dir=
|
||||||
|
|
||||||
# "include_dirs" is the preferred method for locating postgresql headers,
|
# "pg_config" is the preferred method to locate PostgreSQL headers and
|
||||||
# but some extra checks on sys.platform will still be done in setup.py.
|
# libraries needed to build psycopg2. If pg_config is not in the path or
|
||||||
|
# is installed under a different name uncomment the following option and
|
||||||
|
# set it to the pg_config full path.
|
||||||
|
#pg_config=
|
||||||
|
|
||||||
|
# If "pg_config" is not available, "include_dirs" can be used to locate
|
||||||
|
# postgresql headers and libraries. Some extra checks on sys.platform will
|
||||||
|
# still be done in setup.py.
|
||||||
# The next line is the default as used on psycopg author Debian laptop:
|
# The next line is the default as used on psycopg author Debian laptop:
|
||||||
include_dirs=.:/usr/include/postgresql:/usr/include/postgresql/server
|
#include_dirs=/usr/include/postgresql:/usr/include/postgresql/server
|
||||||
|
|
||||||
# Uncomment next line on Mandrake 10.x (and comment previous ones):
|
# Uncomment next line on Mandrake 10.x (and comment previous ones):
|
||||||
#include_dirs=.:/usr/include/pgsql/8.0:/usr/include/pgsql/8.0/server
|
#include_dirs=/usr/include/pgsql/8.0:/usr/include/pgsql/8.0/server
|
||||||
|
|
||||||
# Uncomment next line on SUSE 9.3 (and comment previous ones):
|
# Uncomment next line on SUSE 9.3 (and comment previous ones):
|
||||||
#include_dirs=.:/usr/include/pgsql:/usr/include/pgsql/server
|
#include_dirs=/usr/include/pgsql:/usr/include/pgsql/server
|
||||||
|
|
||||||
# If postgresql is installed somewhere weird (i.e., not in your runtime library
|
# If postgresql is installed somewhere weird (i.e., not in your runtime library
|
||||||
# path like /usr/lib), just add the right path in "library_dirs" and any extra
|
# path like /usr/lib), just add the right path in "library_dirs" and any extra
|
||||||
|
|
32
setup.py
32
setup.py
|
@ -49,6 +49,7 @@ Operating System :: Unix
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
import shutil
|
import shutil
|
||||||
|
import popen2
|
||||||
from distutils.core import setup, Extension
|
from distutils.core import setup, Extension
|
||||||
from distutils.errors import DistutilsFileError
|
from distutils.errors import DistutilsFileError
|
||||||
from distutils.command.build_ext import build_ext
|
from distutils.command.build_ext import build_ext
|
||||||
|
@ -82,6 +83,8 @@ class psycopg_build_ext(build_ext):
|
||||||
"Build against libpq.dll (win32 only)"),
|
"Build against libpq.dll (win32 only)"),
|
||||||
('use-pydatetime', None,
|
('use-pydatetime', None,
|
||||||
"Use Python datatime objects for date and time representation."),
|
"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"),
|
||||||
])
|
])
|
||||||
|
|
||||||
boolean_options = build_ext.boolean_options[:]
|
boolean_options = build_ext.boolean_options[:]
|
||||||
|
@ -95,6 +98,14 @@ class psycopg_build_ext(build_ext):
|
||||||
self.use_pydatetime = 1
|
self.use_pydatetime = 1
|
||||||
self.use_pg_dll = 1
|
self.use_pg_dll = 1
|
||||||
self.pgdir = None
|
self.pgdir = None
|
||||||
|
self.pg_config = "pg_config"
|
||||||
|
|
||||||
|
def get_pg_config(self, kind):
|
||||||
|
p = popen2.popen3(self.pg_config + " --" + kind, mode="r")
|
||||||
|
r = p[0].readline().strip()
|
||||||
|
if not r:
|
||||||
|
raise Warning(p[2].readline().strip())
|
||||||
|
return r
|
||||||
|
|
||||||
def get_compiler(self):
|
def get_compiler(self):
|
||||||
"""Return the c compiler to compile extensions.
|
"""Return the c compiler to compile extensions.
|
||||||
|
@ -164,19 +175,7 @@ class psycopg_build_ext(build_ext):
|
||||||
self.libraries.append(self.get_lib("pq"))
|
self.libraries.append(self.get_lib("pq"))
|
||||||
|
|
||||||
def finalize_darwin(self):
|
def finalize_darwin(self):
|
||||||
"""Finalize build system configuration on darwin platform.
|
"""Finalize build system configuration on darwin platform."""
|
||||||
|
|
||||||
fink installs lots of goodies in /sw/... - make sure we check there
|
|
||||||
"""
|
|
||||||
self.include_dirs.append("/sw/include")
|
|
||||||
self.include_dirs.append("/sw/include/postgresql")
|
|
||||||
self.include_dirs.append("/sw/include/postgresql/server")
|
|
||||||
self.library_dirs.append("/sw/lib")
|
|
||||||
self.include_dirs.append("/opt/local/include")
|
|
||||||
self.include_dirs.append("/opt/local/include/postgresql")
|
|
||||||
self.include_dirs.append("/opt/local/include/postgresql/server")
|
|
||||||
self.library_dirs.append("/opt/local/lib")
|
|
||||||
self.library_dirs.append("/usr/lib")
|
|
||||||
self.libraries.append('ssl')
|
self.libraries.append('ssl')
|
||||||
self.libraries.append('crypto')
|
self.libraries.append('crypto')
|
||||||
|
|
||||||
|
@ -184,8 +183,13 @@ class psycopg_build_ext(build_ext):
|
||||||
"""Complete the build system configuation."""
|
"""Complete the build system configuation."""
|
||||||
build_ext.finalize_options(self)
|
build_ext.finalize_options(self)
|
||||||
|
|
||||||
|
self.include_dirs.append(".")
|
||||||
self.libraries.append("pq")
|
self.libraries.append("pq")
|
||||||
|
|
||||||
|
self.library_dirs.append(self.get_pg_config("libdir"))
|
||||||
|
self.include_dirs.append(self.get_pg_config("includedir"))
|
||||||
|
self.include_dirs.append(self.get_pg_config("includedir-server"))
|
||||||
|
|
||||||
if hasattr(self, "finalize_" + sys.platform):
|
if hasattr(self, "finalize_" + sys.platform):
|
||||||
getattr(self, "finalize_" + sys.platform)()
|
getattr(self, "finalize_" + sys.platform)()
|
||||||
|
|
||||||
|
@ -198,6 +202,8 @@ class psycopg_build_ext(build_ext):
|
||||||
if sys.platform == 'win32' and self.use_pg_dll:
|
if sys.platform == 'win32' and self.use_pg_dll:
|
||||||
shutil.copy(self.find_libpq_dll(), "lib")
|
shutil.copy(self.find_libpq_dll(), "lib")
|
||||||
|
|
||||||
|
## win32-specific stuff ##
|
||||||
|
|
||||||
def build_from_src(self):
|
def build_from_src(self):
|
||||||
"""Detect if building from postgres source or bin on w32 platform"""
|
"""Detect if building from postgres source or bin on w32 platform"""
|
||||||
return os.path.exists(os.path.join(self.pgdir, "src"))
|
return os.path.exists(os.path.join(self.pgdir, "src"))
|
||||||
|
|
Loading…
Reference in New Issue
Block a user