diff options
author | Federico Di Gregorio <fog@initd.org> | 2006-01-05 04:19:01 +0000 |
---|---|---|
committer | Federico Di Gregorio <fog@initd.org> | 2006-01-05 04:19:01 +0000 |
commit | d5674253ca184e9ddedec34a3475104dbc6e2962 (patch) | |
tree | 3b199b732e6a8cbcf135a4305f3646d9a72687c1 | |
parent | c79e92e9284c59fe8161e57b14a473bc0687335b (diff) | |
download | psycopg2-d5674253ca184e9ddedec34a3475104dbc6e2962.tar.gz |
We now use pg_config in setup.py (closes: #70).
-rw-r--r-- | ChangeLog | 5 | ||||
-rw-r--r-- | setup.cfg | 17 | ||||
-rw-r--r-- | setup.py | 40 |
3 files changed, 40 insertions, 22 deletions
@@ -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> * Preparing release 2 beta 7. @@ -20,16 +20,23 @@ use_decimal=0 # uncommenting the following line and setting its value to the right path. #mx_include_dir= -# "include_dirs" is the preferred method for locating postgresql headers, -# but some extra checks on sys.platform will still be done in setup.py. +# "pg_config" is the preferred method to locate PostgreSQL headers and +# 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: -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): -#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): -#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 # path like /usr/lib), just add the right path in "library_dirs" and any extra @@ -49,6 +49,7 @@ Operating System :: Unix import os import sys import shutil +import popen2 from distutils.core import setup, Extension from distutils.errors import DistutilsFileError from distutils.command.build_ext import build_ext @@ -81,7 +82,9 @@ class psycopg_build_ext(build_ext): ('use-pg-dll', None, "Build against libpq.dll (win32 only)"), ('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[:] @@ -95,7 +98,15 @@ class psycopg_build_ext(build_ext): self.use_pydatetime = 1 self.use_pg_dll = 1 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): """Return the c compiler to compile extensions. @@ -111,7 +122,7 @@ class psycopg_build_ext(build_ext): if self.get_compiler().compiler_type == "mingw32" \ and 'msvcr71' in self.compiler.dll_libraries: self.compiler.dll_libraries.remove('msvcr71') - + build_ext.build_extensions(self) def finalize_win32(self): @@ -164,28 +175,21 @@ class psycopg_build_ext(build_ext): self.libraries.append(self.get_lib("pq")) def finalize_darwin(self): - """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") + """Finalize build system configuration on darwin platform.""" self.libraries.append('ssl') self.libraries.append('crypto') def finalize_options(self): """Complete the build system configuation.""" build_ext.finalize_options(self) - + + self.include_dirs.append(".") 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): getattr(self, "finalize_" + sys.platform)() @@ -198,6 +202,8 @@ class psycopg_build_ext(build_ext): 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")) |