$OpenBSD: patch-setup_py,v 1.3 2007/04/28 10:06:25 bernd Exp $ --- setup.py.orig Sun Oct 8 19:41:25 2006 +++ setup.py Tue Apr 24 14:01:43 2007 @@ -521,141 +521,13 @@ class PyBuildExt(build_ext): # of available releases can be found at # # http://www.sleepycat.com/update/index.html - - max_db_ver = (4, 4) - min_db_ver = (3, 2) - db_setup_debug = False # verbose debug prints from this script? - - # construct a list of paths to look for the header file in on - # top of the normal inc_dirs. - db_inc_paths = [ - '/usr/include/db4', - '/usr/local/include/db4', - '/opt/sfw/include/db4', - '/sw/include/db4', - '/usr/include/db3', - '/usr/local/include/db3', - '/opt/sfw/include/db3', - '/sw/include/db3', - ] - # 4.x minor number specific paths - for x in (0,1,2,3,4): - db_inc_paths.append('/usr/include/db4%d' % x) - db_inc_paths.append('/usr/include/db4.%d' % x) - db_inc_paths.append('/usr/local/BerkeleyDB.4.%d/include' % x) - db_inc_paths.append('/usr/local/include/db4%d' % x) - db_inc_paths.append('/pkg/db-4.%d/include' % x) - db_inc_paths.append('/opt/db-4.%d/include' % x) - # 3.x minor number specific paths - for x in (2,3): - db_inc_paths.append('/usr/include/db3%d' % x) - db_inc_paths.append('/usr/local/BerkeleyDB.3.%d/include' % x) - db_inc_paths.append('/usr/local/include/db3%d' % x) - db_inc_paths.append('/pkg/db-3.%d/include' % x) - db_inc_paths.append('/opt/db-3.%d/include' % x) - - # Add some common subdirectories for Sleepycat DB to the list, - # based on the standard include directories. This way DB3/4 gets - # picked up when it is installed in a non-standard prefix and - # the user has added that prefix into inc_dirs. - std_variants = [] - for dn in inc_dirs: - std_variants.append(os.path.join(dn, 'db3')) - std_variants.append(os.path.join(dn, 'db4')) - for x in (0,1,2,3,4): - std_variants.append(os.path.join(dn, "db4%d"%x)) - std_variants.append(os.path.join(dn, "db4.%d"%x)) - for x in (2,3): - std_variants.append(os.path.join(dn, "db3%d"%x)) - std_variants.append(os.path.join(dn, "db3.%d"%x)) - - db_inc_paths = std_variants + db_inc_paths - - db_ver_inc_map = {} - - class db_found(Exception): pass - try: - # See whether there is a Sleepycat header in the standard - # search path. - for d in inc_dirs + db_inc_paths: - f = os.path.join(d, "db.h") - if db_setup_debug: print "db: looking for db.h in", f - if os.path.exists(f): - f = open(f).read() - m = re.search(r"#define\WDB_VERSION_MAJOR\W(\d+)", f) - if m: - db_major = int(m.group(1)) - m = re.search(r"#define\WDB_VERSION_MINOR\W(\d+)", f) - db_minor = int(m.group(1)) - db_ver = (db_major, db_minor) - - if ( (not db_ver_inc_map.has_key(db_ver)) and - (db_ver <= max_db_ver and db_ver >= min_db_ver) ): - # save the include directory with the db.h version - # (first occurrance only) - db_ver_inc_map[db_ver] = d - print "db.h: found", db_ver, "in", d - else: - # we already found a header for this library version - if db_setup_debug: print "db.h: ignoring", d - else: - # ignore this header, it didn't contain a version number - if db_setup_debug: print "db.h: unsupported version", db_ver, "in", d - - db_found_vers = db_ver_inc_map.keys() - db_found_vers.sort() - - while db_found_vers: - db_ver = db_found_vers.pop() - db_incdir = db_ver_inc_map[db_ver] - - # check lib directories parallel to the location of the header - db_dirs_to_check = [ - os.path.join(db_incdir, '..', 'lib64'), - os.path.join(db_incdir, '..', 'lib'), - os.path.join(db_incdir, '..', '..', 'lib64'), - os.path.join(db_incdir, '..', '..', 'lib'), - ] - db_dirs_to_check = filter(os.path.isdir, db_dirs_to_check) - - # Look for a version specific db-X.Y before an ambiguoius dbX - # XXX should we -ever- look for a dbX name? Do any - # systems really not name their library by version and - # symlink to more general names? - for dblib in (('db-%d.%d' % db_ver), - ('db%d%d' % db_ver), - ('db%d' % db_ver[0])): - dblib_file = self.compiler.find_library_file( - db_dirs_to_check + lib_dirs, dblib ) - if dblib_file: - dblib_dir = [ os.path.abspath(os.path.dirname(dblib_file)) ] - raise db_found - else: - if db_setup_debug: print "db lib: ", dblib, "not found" - - except db_found: - print "db lib: using", db_ver, dblib - if db_setup_debug: print "db: lib dir", dblib_dir, "inc dir", db_incdir - db_incs = [db_incdir] - dblibs = [dblib] - # We add the runtime_library_dirs argument because the - # BerkeleyDB lib we're linking against often isn't in the - # system dynamic library search path. 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). + if !!USE_BSDDB!!: exts.append(Extension('_bsddb', ['_bsddb.c'], - library_dirs=dblib_dir, - runtime_library_dirs=dblib_dir, - include_dirs=db_incs, - libraries=dblibs)) - else: - if db_setup_debug: print "db: no appropriate library found" - db_incs = None - dblibs = [] - dblib_dir = None + library_dirs=["!!LOCALBASE!!/lib/db4"], + runtime_library_dirs=["!!LOCALBASE!!/lib/db4"], + include_dirs=["!!LOCALBASE!!/include/db4"], + libraries=["db"])) - # 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 @@ -704,7 +576,7 @@ class PyBuildExt(build_ext): libraries=dblibs)) # Anthony Baxter's gdbm module. GNU dbm(3) will require -lgdbm: - if (self.compiler.find_library_file(lib_dirs, 'gdbm')): + if !!USE_GDBM!!: exts.append( Extension('gdbm', ['gdbmmodule.c'], libraries = ['gdbm'] ) ) @@ -791,7 +663,7 @@ class PyBuildExt(build_ext): libraries = ['z']) ) # Gustavo Niemeyer's bz2 module. - if (self.compiler.find_library_file(lib_dirs, 'bz2')): + if !!USE_BZ2!!: exts.append( Extension('bz2', ['bz2module.c'], libraries = ['bz2']) ) @@ -806,19 +678,19 @@ class PyBuildExt(build_ext): # # More information on Expat can be found at www.libexpat.org. # - expatinc = os.path.join(os.getcwd(), srcdir, 'Modules', 'expat') - define_macros = [ - ('HAVE_EXPAT_CONFIG_H', '1'), - ] - exts.append(Extension('pyexpat', - define_macros = define_macros, - include_dirs = [expatinc], - sources = ['pyexpat.c', - 'expat/xmlparse.c', - 'expat/xmlrole.c', - 'expat/xmltok.c', - ], - )) + if !!USE_EXPAT!!: + expatinc = os.path.join(os.getcwd(), srcdir, 'Modules', 'expat') + define_macros = [ + ('HAVE_EXPAT_CONFIG_H', '1'), + ] + exts.append(Extension('pyexpat', + define_macros = define_macros, + include_dirs = ["!!X11BASE!!/include", expatinc], + library_dirs = ["!!X11BASE!!/lib"], + sources = ['pyexpat.c', + ], + libraries = ["expat"] + )) # Hye-Shik Chang's CJKCodecs modules. if have_unicode: @@ -954,7 +826,16 @@ class PyBuildExt(build_ext): self.extensions.extend(exts) # Call the method for detecting whether _tkinter can be compiled - self.detect_tkinter(inc_dirs, lib_dirs) + if !!USE_TKINTER!!: + ext = Extension('_tkinter', ['_tkinter.c', 'tkappinit.c'], + define_macros=[('WITH_APPINIT', 1)], + include_dirs = ["!!LOCALBASE!!/include/tcl8.4", + "!!LOCALBASE!!/include/tk8.4", + "!!X11BASE!!/include"], + libraries = ["tk84", "tcl84", "X11"], + library_dirs = ["!!LOCALBASE!!/lib", "!!X11BASE!!/lib"], + ) + self.extensions.append(ext) def detect_tkinter_darwin(self, inc_dirs, lib_dirs): # The _tkinter module, using frameworks. Since frameworks are quite @@ -1224,8 +1105,7 @@ def main(): ext_modules=[Extension('struct', ['structmodule.c'])], # Scripts to install - scripts = ['Tools/scripts/pydoc', 'Tools/scripts/idle', - 'Lib/smtpd.py'] + scripts = [] ) # --install-platlib