From: Gerhard H?r. <gha...@us...> - 2002-09-16 05:39:53
|
Update of /cvsroot/pypgsql/pypgsql In directory usw-pr-cvs1:/tmp/cvs-serv9795 Modified Files: setup.py Added Files: setup.config Log Message: 16SEP2002 gh Total rework of setup.py to work out of the box for most popular platforms. --- NEW FILE: setup.config --- # This file is for customizing the pyPgSQL build process. On most platforms, # pyPgSQL will build ok with the semi-intelligent setup.py. If you have a # platform that's not supported by default in setup.py, or you want any # nonstandard settings, like building against your own PostgreSQL instead of # the default PostgreSQL of your OS, you'll have to edit this file. # If you want to use this file, you MUST uncomment and set the following two # variables: # include_dirs = ["/usr/local/postgresql70/include"] # library_dirs = ["/usr/local/postgresql70/lib"] # Additionally, you CAN modifiy sources, pypgsql_rt_dirs and optional_libs: # sources += ["support_for_weird_platform.c"] # pypgsql_rt_dirs = library_dirs # optional_libs += ["ssl", "crypto"] Index: setup.py =================================================================== RCS file: /cvsroot/pypgsql/pypgsql/setup.py,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -d -r1.16 -r1.17 *** setup.py 8 Sep 2002 16:38:27 -0000 1.16 --- setup.py 16 Sep 2002 05:39:50 -0000 1.17 *************** *** 4,8 **** # Name: setup.py | # | ! # Synopsys: python setup.py build # Build the module. | # python setup.py install # Install the module. | # | --- 4,8 ---- # Name: setup.py | # | ! # Synopsis: python setup.py build # Build the module. | # python setup.py install # Install the module. | # | *************** *** 12,23 **** # | # Description: Setup script (using the distutils framework) for | ! # pyPgSQL Version 2.2. | ! # | ! # Note: This script requires the distutils package (standard in | ! # Python 1.6 or later). For earlier versions of Python, | ! # you can download distutils from: | ! # http://www.python.org/sigs/distutils-sig/download.html | #=======================================================================| ! # Copyright 2001 by Gerhard Haering. | # All rights reserved. | # | --- 12,18 ---- # | # Description: Setup script (using the distutils framework) for | ! # pyPgSQL. | #=======================================================================| ! # Copyright 2001, 2002 by Gerhard Haering. | # All rights reserved. | # | *************** *** 42,46 **** # Ini Name | # --- ----------------------------------------------------------------- | ! # gh Gerhard Haering <ge...@bi...> | # bga Billy G. Allie <bil...@mu...> | #=======================================================================| --- 37,41 ---- # Ini Name | # --- ----------------------------------------------------------------- | ! # gh Gerhard Haering <ger...@gm...> | # bga Billy G. Allie <bil...@mu...> | #=======================================================================| *************** *** 49,54 **** # Date Ini Description | # --------- --- ------------------------------------------------------- | # 29AUG2001 gh Reflected changed PostgreSQL win32 build process (Post- | ! # greSQL now built with mingw32) | # 28AUG2001 bga Add include_dirs and lib_dirs for building on cygwin. | # This change should allow pyPgSQL to build 'out of the | --- 44,52 ---- # Date Ini Description | # --------- --- ------------------------------------------------------- | + # 16SEP2002 gh Total rework to make setup.py work out of the box for | + # most popular platforms, while still allowing flexibi- | + # lity through setup.config. | # 29AUG2001 gh Reflected changed PostgreSQL win32 build process (Post- | ! # greSQL now built with mingw32) | # 28AUG2001 bga Add include_dirs and lib_dirs for building on cygwin. | # This change should allow pyPgSQL to build 'out of the | *************** *** 64,154 **** # 01JUN2001 gh Initial version created by Gerhard Haering. | #-----------------------------------------------------------------------+ ! import sys from distutils.core import setup from distutils.extension import Extension ! __version__ = "2.2" # Define the runtime library path for this module. It starts out as None. ! pypgsql_rt_dirs = None ! ! # You may have to adjust include_dirs and library_dirs if they are differant ! # on your system ! ! include_dirs = [ "/usr/local/pgsql/include" ] ! # include_dirs = [ "/usr/local/include/pgsql" ] # Common alternative ! # include_dirs = [ "/usr/include/pgsql" ] # Common alternative ! ! library_dirs = [ "/usr/local/pgsql/lib" ] # Common alternative ! # library_dirs = [ "/usr/local/lib/pgsql" ] # Common alternative ! # library_dirs = [ "/usr/lib/pgsql" ] ! ! optional_libs = [ "pq" ] ! ! sources = [ "libpqmodule.c", "pgboolean.c", ! "pgint2object.c", "pgint8object.c", ! "pgversion.c", "pglargeobject.c", ! "pgnotify.c", "pgconnection.c", ! "pgresult.c", "pymemstrdup.c" ] ! ! if sys.platform == "win32": ! # This works with the PostgreSQL source tree, so it's a bit ugly ... ! # You will probably have to change win_pg_build_root for your system. ! ! win_pg_build_root = "h:/src/postgresql-7.2.1/" ! include_dirs = [ win_pg_build_root + "src/include", ! win_pg_build_root + "/src/include/libpq", ! win_pg_build_root + "src", ! win_pg_build_root + "src/interfaces/libpq" ] ! library_dirs = [ win_pg_build_root + "src/interfaces/libpq/" ] ! optional_libs = [ "wsock32", "advapi32" ] ! optional_libs += [ "pq", "wsock32" ] ! data_files = [] ! sources = sources + [ "windows/strtoll.c", ! "windows/strtoull.c", ! "windows/strtok.c" ] ! modname="pyPgSQL.libpq.libpq" ! else: ! if sys.platform[:6] == "cygwin": ! sources = sources + [ "windows/strtoll.c", ! "windows/strtoull.c", ! "windows/strtok.c" ] ! include_dirs = [ "/usr/include/postgresql" ] ! library_dirs = [ "/usr/lib" ] ! # XXX: This is an ugly hack to make bdist_rpm find the include files. ! include_dirs.append("../" * 5) ! data_files = [] ! pypgsql_rt_dirs = library_dirs ! modname="pyPgSQL.libpq.libpqmodule" ! setup ( ! name = "pyPgSQL", ! version = __version__, ! description = \ ! "pyPgSQL - A Python DB-API 2.0 compliant interface to PostgreSQL.", ! author = "Billy G. Allie", ! author_email = "bal...@so...", ! url = "http://pypgsql.sourceforge.net/", ! licence = "Python", ! packages = [ "pyPgSQL", "pyPgSQL.libpq" ], ! ext_modules = [Extension( ! name=modname, ! sources = sources, ! include_dirs = include_dirs, ! library_dirs = library_dirs, ! runtime_library_dirs = pypgsql_rt_dirs, ! libraries = optional_libs ! )], ! data_files = data_files ! ) --- 62,201 ---- # 01JUN2001 gh Initial version created by Gerhard Haering. | #-----------------------------------------------------------------------+ ! import os, os.path, sys from distutils.core import setup from distutils.extension import Extension ! __version__ = "2.3" # Define the runtime library path for this module. It starts out as None. ! class UnknownPlatformError(Exception): ! pass ! def getLinuxDistribution(): ! f = open("/etc/issue") ! issue = f.read() ! f.close() ! if issue.find("Debian GNU") >= 0: ! return "Debian" ! elif issue.find("Red Hat Linux") >= 0: ! return "Redhat" ! elif issue.find("SuSE Linux") >= 0: ! return "SuSE" ! elif issue.find("Mandrake") >= 0: ! return "Mandrake" ! else: ! return "unknown" ! class Config: ! def __init__(self): ! # Default settings, may be overriden for specific platforms ! self.pypgsql_rt_dirs = None ! self.optional_libs = ["pq"] ! self.modname = "pyPgSQL.libpq.libpqmodule" ! self.sources = ["libpqmodule.c", "pgboolean.c", ! "pgint2object.c", "pgint8object.c", ! "pgversion.c", "pglargeobject.c", ! "pgnotify.c", "pgconnection.c", ! "pgresult.c", "pymemstrdup.c", ! "port/strtoll.c", "port/strtoull.c", ! "port/strtok.c"] ! imported_locals = {} ! execfile("setup.config", {}, imported_locals) ! self.use_custom = len(imported_locals) > 0 ! if self.use_custom: ! for k, v in imported_locals.items(): ! self.__dict__[k] = v ! def main(): ! cfg = Config() ! if cfg.use_custom: ! pass ! elif sys.platform == "linux2": ! distribution = getLinuxDistribution() ! if distribution == "Redhat": ! cfg.include_dirs = ["/usr/include"] ! cfg.library_dirs = ["/usr/lib"] ! elif distribution == "Debian": ! cfg.include_dirs = ["/usr/include/postgresql"] ! cfg.library_dirs = ["/usr/lib"] ! elif distribution in ("SuSE", "Mandrake"): ! cfg.include_dirs = ["/usr/include/pgsql"] ! cfg.library_dirs = ["/usr/lib"] ! else: ! raise UnknownPlatformError, "Unknown Linux distribution." ! # XXX: This is an ugly hack to make bdist_rpm find the include files. ! cfg.include_dirs.append("../" * 5) ! elif sys.platform == "freebsd4": ! LOCALBASE = os.environ.get('LOCALBASE', '/usr/local') ! cfg.include_dirs = ['%s/include' % LOCALBASE] ! cfg.library_dirs = ['%s/lib' % LOCALBASE] ! elif sys.platform == "openbsd3": ! LOCALBASE = os.environ.get('LOCALBASE', '/usr/local') ! cfg.include_dirs = ['%s/include/postgresql' % LOCALBASE] ! cfg.library_dirs = ['%s/lib' % LOCALBASE] ! elif sys.platform == "netbsd1": ! LOCALBASE = os.environ.get('LOCALBASE', '/usr/pkg') ! cfg.include_dirs = ['%s/include/pgsql' % LOCALBASE] ! cfg.library_dirs = ['%s/lib' % LOCALBASE] ! elif sys.platform == "cygwin": ! cfg.include_dirs = ["/usr/include/postgresql"] ! cfg.library_dirs = ["/usr/lib"] ! elif sys.platform == "darwin": # Mac OS X ! cfg.include_dirs = ["/usr/local/pgsql/include"] ! cfg.library_dirs = ["/usr/local/pgsql/lib"] ! cfg.optional_libs += ["ssl", "crypto"] ! elif sys.platform == "win32": ! # This works with the PostgreSQL source tree, so it's a bit ugly ... ! win_pg_build_root = os.getenv("PG_SRC", "../postgresql") ! cfg.include_dirs = [os.path.join(win_pg_build_root, p) for p in ! ["src/include", ! "src/include/libpq", ! "src", ! "src/interfaces/libpq"]] ! cfg.library_dirs = [win_pg_build_root + "/src/interfaces/libpq/"] ! cfg.optional_libs += ["wsock32", "advapi32"] ! cfg.modname="pyPgSQL.libpq.libpq" ! else: ! raise UnknownPlatformError, "Unknown platform." ! setup ( ! name = "pyPgSQL", ! version = __version__, ! description = \ ! "pyPgSQL - A Python DB-API 2.0 compliant interface to PostgreSQL.", ! author = "Billy G. Allie", ! author_email = "bal...@so...", ! url = "http://pypgsql.sourceforge.net/", ! licence = "Python", ! packages = ["pyPgSQL", "pyPgSQL.libpq"], ! ext_modules = [Extension( ! name=cfg.modname, ! sources = cfg.sources, ! include_dirs = cfg.include_dirs, ! library_dirs = cfg.library_dirs, ! runtime_library_dirs = cfg.pypgsql_rt_dirs, ! libraries = cfg.optional_libs ! )] ! ) ! if __name__ == "__main__": ! try: ! main() ! except UnknownPlatformError, reason: ! print "Cannot build pyPgSQL:", reason ! print ! print "setup.py can't guess the correct settings for your platform." ! print ! print "Please manually edit setup.conf appropriately for your platform." ! print "If you have any problems, please ask on the pypgsql-users mailing list." ! print ! print "Once you've managed to build pyPgSQL on your platform, please submit a" ! print "patch to setup.py so that we can support your platform by default in" ! print "the future. The pyPgSQL developers are happy to assist you in doing so." |