pkgsrc/lang/python23/patches/patch-am
recht 0f312c17dc Rework bdb detection: Since we're using buildlink we could save rely
on the variables it sets (eg. BDB_TYPE). While at bl3ify.
Thanks to minskim@ for fixes and testing.
2004-04-13 22:48:41 +00:00

350 lines
17 KiB
Text

$NetBSD: patch-am,v 1.5 2004/04/13 22:48:41 recht Exp $
--- setup.py.orig 2003-10-21 15:01:21.000000000 -0500
+++ setup.py
@@ -15,7 +15,7 @@ from distutils.command.install import in
from distutils.command.install_lib import install_lib
# This global variable is used to hold the list of modules to be disabled.
-disabled_module_list = []
+disabled_module_list = ["_bsddb", "_curses", "_curses_panel", "_tkinter", "gdbm", "mpz", "pyexpat", "readline"]
def add_dir_to_list(dirlist, dir):
"""Add the directory 'dir' to the list 'dirlist' (at the front) if
@@ -240,9 +240,15 @@ class PyBuildExt(build_ext):
return sys.platform
def detect_modules(self):
- # Ensure that /usr/local is always used
- add_dir_to_list(self.compiler.library_dirs, '/usr/local/lib')
- add_dir_to_list(self.compiler.include_dirs, '/usr/local/include')
+ # Add the buildlink directories for pkgsrc
+ if os.environ.has_key('BUILDLINK_DIR'):
+ dir = os.environ['BUILDLINK_DIR']
+ libdir = dir + '/lib'
+ incdir = dir + '/include'
+ if libdir not in self.compiler.library_dirs:
+ self.compiler.library_dirs.insert(0, libdir)
+ if incdir not in self.compiler.include_dirs:
+ self.compiler.include_dirs.insert(0, incdir)
# fink installs lots of goodies in /sw/... - make sure we
# check there
@@ -436,9 +442,7 @@ class PyBuildExt(build_ext):
depends = ['socketmodule.h']) )
# Detect SSL support for the socket module (via _ssl)
ssl_incs = find_file('openssl/ssl.h', inc_dirs,
- ['/usr/local/ssl/include',
- '/usr/contrib/ssl/include/'
- ]
+ []
)
if ssl_incs is not None:
krb5_h = find_file('krb5.h', inc_dirs,
@@ -446,9 +450,7 @@ class PyBuildExt(build_ext):
if krb5_h:
ssl_incs += krb5_h
ssl_libs = find_library_file(self.compiler, 'ssl',lib_dirs,
- ['/usr/local/ssl/lib',
- '/usr/contrib/ssl/lib/'
- ] )
+ [] )
if (ssl_incs is not None and
ssl_libs is not None):
@@ -479,116 +481,162 @@ class PyBuildExt(build_ext):
# when sorted in reverse order, keys for this dict must appear in the
# order you wish to search - e.g., search for db4 before db3
- db_try_this = {
- 'db4': {'libs': ('db-4.2', 'db42', 'db-4.1', 'db41', 'db-4.0', 'db4',),
- 'libdirs': ('/usr/local/BerkeleyDB.4.2/lib',
- '/usr/local/BerkeleyDB.4.1/lib',
- '/usr/local/BerkeleyDB.4.0/lib',
- '/usr/local/lib',
- '/opt/sfw',
- '/sw/lib',
- ),
- 'incdirs': ('/usr/local/BerkeleyDB.4.2/include',
- '/usr/local/include/db42',
- '/usr/local/BerkeleyDB.4.1/include',
- '/usr/local/include/db41',
- '/usr/local/BerkeleyDB.4.0/include',
- '/usr/local/include/db4',
- '/opt/sfw/include/db4',
- '/sw/include/db4',
- '/usr/include/db4',
- )},
- 'db3': {'libs': ('db-3.3', 'db-3.2', 'db-3.1', 'db3',),
- 'libdirs': ('/usr/local/BerkeleyDB.3.3/lib',
- '/usr/local/BerkeleyDB.3.2/lib',
- '/usr/local/BerkeleyDB.3.1/lib',
- '/usr/local/lib',
- '/opt/sfw/lib',
- '/sw/lib',
- ),
- 'incdirs': ('/usr/local/BerkeleyDB.3.3/include',
- '/usr/local/BerkeleyDB.3.2/include',
- '/usr/local/BerkeleyDB.3.1/include',
- '/usr/local/include/db3',
- '/opt/sfw/include/db3',
- '/sw/include/db3',
- '/usr/include/db3',
- )},
- }
-
- db_search_order = db_try_this.keys()
- db_search_order.sort()
- db_search_order.reverse()
+ #db_try_this = {
+ #'db4': {'libs': ('db-4.2', 'db42', 'db-4.1', 'db41', 'db-4.0', 'db4',),
+ #'libdirs': ('/usr/local/BerkeleyDB.4.2/lib',
+ #'/usr/local/BerkeleyDB.4.1/lib',
+ #'/usr/local/BerkeleyDB.4.0/lib',
+ #'/usr/local/lib',
+ #'/opt/sfw',
+ #'/sw/lib',
+ #),
+ #'incdirs': ('/usr/local/BerkeleyDB.4.2/include',
+ #'/usr/local/include/db42',
+ #'/usr/local/BerkeleyDB.4.1/include',
+ #'/usr/local/include/db41',
+ #'/usr/local/BerkeleyDB.4.0/include',
+ #'/usr/local/include/db4',
+ #'/opt/sfw/include/db4',
+ #'/sw/include/db4',
+ #'/usr/include/db4',
+ #)},
+ #'db3': {'libs': ('db-3.3', 'db-3.2', 'db-3.1', 'db3',),
+ #'libdirs': ('/usr/local/BerkeleyDB.3.3/lib',
+ #'/usr/local/BerkeleyDB.3.2/lib',
+ #'/usr/local/BerkeleyDB.3.1/lib',
+ #'/usr/local/lib',
+ #'/opt/sfw/lib',
+ #'/sw/lib',
+ #),
+ #'incdirs': ('/usr/local/BerkeleyDB.3.3/include',
+ #'/usr/local/BerkeleyDB.3.2/include',
+ #'/usr/local/BerkeleyDB.3.1/include',
+ #'/usr/local/include/db3',
+ #'/opt/sfw/include/db3',
+ #'/sw/include/db3',
+ #'/usr/include/db3',
+ #)},
+ #}
+
+ #db_search_order = db_try_this.keys()
+ #db_search_order.sort()
+ #db_search_order.reverse()
+
+ #class found(Exception): pass
+ #try:
+ ## See whether there is a Sleepycat header in the standard
+ ## search path.
+ #std_dbinc = None
+ #for d in inc_dirs:
+ #f = os.path.join(d, "db.h")
+ #if os.path.exists(f):
+ #f = open(f).read()
+ #m = re.search(r"#define\WDB_VERSION_MAJOR\W([1-9]+)", f)
+ #if m:
+ #std_dbinc = 'db' + m.group(1)
+ #for dbkey in db_search_order:
+ #dbd = db_try_this[dbkey]
+ #for dblib in dbd['libs']:
+ ## Prefer version-specific includes over standard
+ ## include locations.
+ #db_incs = find_file('db.h', [], dbd['incdirs'])
+ #dblib_dir = find_library_file(self.compiler,
+ #dblib,
+ #lib_dirs,
+ #list(dbd['libdirs']))
+ #if (db_incs or dbkey == std_dbinc) and \
+ #dblib_dir is not None:
+ #dblibs = [dblib]
+ #raise found
+ #except found:
+ #dblibs = [dblib]
+ ## A default source build puts Berkeley DB in something like
+ ## /usr/local/Berkeley.3.3 and the lib dir under that isn't
+ ## normally on ld.so's search path, unless the sysadmin has hacked
+ ## /etc/ld.so.conf. We add the directory to runtime_library_dirs
+ ## so the proper -R/--rpath flags get passed to the linker. This
+ ## is usually correct and most trouble free, but may cause problems
+ ## in some unusual system configurations (e.g. the directory is on
+ ## an NFS server that goes away).
+ #exts.append(Extension('_bsddb', ['_bsddb.c'],
+ #library_dirs=dblib_dir,
+ #runtime_library_dirs=dblib_dir,
+ #include_dirs=db_incs,
+ #libraries=dblibs))
+ #else:
+ #db_incs = None
+ #dblibs = []
+ #dblib_dir = None
- class found(Exception): pass
+ # Look for Berkeley db 1.85. Note that it is built as a different
+ # module name so it can be included even when later versions are
+ # available. A very restrictive search is performed to avoid
+ # accidentally building this module with a later version of the
+ # underlying db library. May BSD-ish Unixes incorporate db 1.85
+ # symbols into libc and place the include file in /usr/include.
+ #f = "/usr/include/db.h"
+ #if os.path.exists(f):
+ #data = open(f).read()
+ #m = re.search(r"#s*define\s+HASHVERSION\s+2\s*", data)
+ #if m is not None:
+ ## bingo - old version used hash file format version 2
+ #### XXX this should be fixed to not be platform-dependent
+ #### but I don't have direct access to an osf1 platform and
+ #### seemed to be muffing the search somehow
+ #libraries = platform == "osf1" and ['db'] or None
+ #if libraries is not None:
+ #exts.append(Extension('bsddb185', ['bsddbmodule.c'],
+ #libraries=libraries))
+ #else:
+ #exts.append(Extension('bsddb185', ['bsddbmodule.c']))
+
+ # rely on pkgsrc for Berkeley DB
+ class NotFound(Exception): pass
try:
- # See whether there is a Sleepycat header in the standard
- # search path.
- std_dbinc = None
- for d in inc_dirs:
- f = os.path.join(d, "db.h")
+ bdb_type = os.environ['PY_BDB_TYPE']
+ db_incs = [os.environ['PY_BDB_INCDIRS']]
+ dblib_dir = None
+ dblibs = None
+
+ # check if need to use the db_185.h compat header
+ bsddb185_define_macros=[]
+ if bdb_type == "db2" or bdb_type == "db3" or bdb_type == "db4":
+ bsddb185_define_macros=[('HAVE_DB_185_H',1)]
+ dblib_dir = [os.environ['PY_BDB_LIBDIRS']]
+
+ else:
+ # check if db_incs/db.h really is db 1.85
+ f = "%s/db.h" % db_incs[0]
+
if os.path.exists(f):
- f = open(f).read()
- m = re.search(r"#define\WDB_VERSION_MAJOR\W([1-9]+)", f)
- if m:
- std_dbinc = 'db' + m.group(1)
- for dbkey in db_search_order:
- dbd = db_try_this[dbkey]
- for dblib in dbd['libs']:
- # Prefer version-specific includes over standard
- # include locations.
- db_incs = find_file('db.h', [], dbd['incdirs'])
- dblib_dir = find_library_file(self.compiler,
- dblib,
- lib_dirs,
- list(dbd['libdirs']))
- if (db_incs or dbkey == std_dbinc) and \
- dblib_dir is not None:
- dblibs = [dblib]
- raise found
- except found:
- dblibs = [dblib]
- # A default source build puts Berkeley DB in something like
- # /usr/local/Berkeley.3.3 and the lib dir under that isn't
- # normally on ld.so's search path, unless the sysadmin has hacked
- # /etc/ld.so.conf. We add the directory to runtime_library_dirs
- # so the proper -R/--rpath flags get passed to the linker. This
- # is usually correct and most trouble free, but may cause problems
- # in some unusual system configurations (e.g. the directory is on
- # an NFS server that goes away).
- exts.append(Extension('_bsddb', ['_bsddb.c'],
+ data = open(f).read()
+ m = re.search(r"#s*define\s+HASHVERSION\s+2\s*", data)
+ if m is None:
+ # check for 1.85 compat header
+ if os.path.exists("%s/db_185.h" % db_incs[0]):
+ bsddb185_define_macros=[('HAVE_DB_185_H',1)]
+ else:
+ raise NotFound
+ try:
+ bltransform = os.environ['PY_BDB_TRANSFORM']
+ m = re.search(r"l:db:(db.)\s*", bltransform)
+ if m is not None and m.group(1) is not None:
+ dblibs = [m.group(1)]
+ except:
+ pass
+
+ # build the bsddb185 extension module
+ exts.append(Extension('bsddb185', ['bsddbmodule.c'],
library_dirs=dblib_dir,
runtime_library_dirs=dblib_dir,
include_dirs=db_incs,
+ define_macros=bsddb185_define_macros,
libraries=dblibs))
- else:
+ except:
db_incs = None
dblibs = []
- dblib_dir = None
-
-
- # Look for Berkeley db 1.85. Note that it is built as a different
- # module name so it can be included even when later versions are
- # available. A very restrictive search is performed to avoid
- # accidentally building this module with a later version of the
- # underlying db library. May BSD-ish Unixes incorporate db 1.85
- # symbols into libc and place the include file in /usr/include.
- f = "/usr/include/db.h"
- if os.path.exists(f):
- data = open(f).read()
- m = re.search(r"#s*define\s+HASHVERSION\s+2\s*", data)
- if m is not None:
- # bingo - old version used hash file format version 2
- ### XXX this should be fixed to not be platform-dependent
- ### but I don't have direct access to an osf1 platform and
- ### seemed to be muffing the search somehow
- libraries = platform == "osf1" and ['db'] or None
- if libraries is not None:
- exts.append(Extension('bsddb185', ['bsddbmodule.c'],
- libraries=libraries))
- else:
- exts.append(Extension('bsddb185', ['bsddbmodule.c']))
-
+ dblib_dir = None
+
# The standard Unix dbm module:
if platform not in ['cygwin']:
if find_file("ndbm.h", inc_dirs, []) is not None:
@@ -600,6 +648,13 @@ class PyBuildExt(build_ext):
exts.append( Extension('dbm', ['dbmmodule.c'],
define_macros=[('HAVE_NDBM_H',None)],
libraries = ndbm_libs ) )
+ elif find_file("ndbm.h", db_incs, []) is not None:
+ exts.append( Extension('dbm', ['dbmmodule.c'],
+ library_dirs=dblib_dir,
+ runtime_library_dirs=dblib_dir,
+ include_dirs=db_incs,
+ define_macros=[('HAVE_NDBM_H',None)],
+ libraries=dblibs))
elif (self.compiler.find_library_file(lib_dirs, 'gdbm')
and find_file("gdbm/ndbm.h", inc_dirs, []) is not None):
exts.append( Extension('dbm', ['dbmmodule.c'],
@@ -770,7 +825,7 @@ class PyBuildExt(build_ext):
# Linux-specific modules
exts.append( Extension('linuxaudiodev', ['linuxaudiodev.c']) )
- if platform in ('linux2', 'freebsd4'):
+ if platform in ('linux2', 'freebsd4', 'freebsd5'):
exts.append( Extension('ossaudiodev', ['ossaudiodev.c']) )
if platform == 'sunos5':
@@ -1140,7 +1195,7 @@ def main():
ext_modules=[Extension('struct', ['structmodule.c'])],
# Scripts to install
- scripts = ['Tools/scripts/pydoc', 'Tools/scripts/idle']
+ scripts = ['Tools/scripts/pydoc2.3']
)
# --install-platlib