$OpenBSD: patch-setup_py,v 1.7 2011/07/18 15:32:18 naddy Exp $ --- setup.py.orig Thu Oct 16 12:58:19 2008 +++ setup.py Mon Jul 18 08:20:35 2011 @@ -17,6 +17,11 @@ 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 = [] +def usrlocal(p): + return os.path.join(os.environ['LOCALBASE'], p) +def usrx11r6(p): + return os.path.join(os.environ['X11BASE'], p) + def add_dir_to_list(dirlist, dir): """Add the directory 'dir' to the list 'dirlist' (at the front) if 1) 'dir' is not already in 'dirlist' @@ -244,8 +249,8 @@ class PyBuildExt(build_ext): 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_dir_to_list(self.compiler.library_dirs, usrlocal('lib')) + add_dir_to_list(self.compiler.include_dirs, usrlocal('include')) # Add paths specified in the environment variables LDFLAGS and # CPPFLAGS for header and library files. @@ -522,8 +527,6 @@ class PyBuildExt(build_ext): depends = ['socketmodule.h']) ) # Detect SSL support for the socket module (via _ssl) search_for_ssl_incs_in = [ - '/usr/local/ssl/include', - '/usr/contrib/ssl/include/' ] ssl_incs = find_file('openssl/ssl.h', inc_dirs, search_for_ssl_incs_in @@ -534,9 +537,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): @@ -609,12 +610,12 @@ class PyBuildExt(build_ext): # a release. Most open source OSes come with one or more # versions of BerkeleyDB already installed. - max_db_ver = (4, 5) + max_db_ver = (4, 7) # NOTE: while the _bsddb.c code links against BerkeleyDB 4.6.x # we leave that version disabled by default as it has proven to be # quite a buggy library release on many platforms. min_db_ver = (3, 3) - db_setup_debug = False # verbose debug prints from this script? + db_setup_debug = True # 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. @@ -660,6 +661,7 @@ class PyBuildExt(build_ext): std_variants.append(os.path.join(dn, "db3.%d"%x)) db_inc_paths = std_variants + db_inc_paths + db_inc_paths = [ usrlocal('include/db4') ] db_ver_inc_map = {} @@ -700,7 +702,7 @@ class PyBuildExt(build_ext): 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 + if db_setup_debug: print "db.h: no version in", d db_found_vers = db_ver_inc_map.keys() db_found_vers.sort() @@ -717,12 +719,14 @@ class PyBuildExt(build_ext): os.path.join(db_incdir, '..', '..', 'lib'), ] db_dirs_to_check = filter(os.path.isdir, db_dirs_to_check) + db_dirs_to_check = [ usrlocal('lib/db4') ] # 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'), ('db%d%d' % db_ver), ('db%d' % db_ver[0])): dblib_file = self.compiler.find_library_file( @@ -768,6 +772,7 @@ class PyBuildExt(build_ext): '/usr/local/include/sqlite', '/usr/local/include/sqlite3', ] + sqlite_inc_paths = [ usrlocal('include') ] MIN_SQLITE_VERSION_NUMBER = (3, 0, 8) MIN_SQLITE_VERSION = ".".join([str(x) for x in MIN_SQLITE_VERSION_NUMBER]) @@ -805,6 +810,7 @@ class PyBuildExt(build_ext): os.path.join(sqlite_incdir, '..', '..', 'lib64'), os.path.join(sqlite_incdir, '..', '..', 'lib'), ] + sqlite_dirs_to_check = [ usrlocal('lib') ] sqlite_libfile = self.compiler.find_library_file( sqlite_dirs_to_check + lib_dirs, 'sqlite3') sqlite_libdir = [os.path.abspath(os.path.dirname(sqlite_libfile))] @@ -858,7 +864,7 @@ class PyBuildExt(build_ext): # the more recent berkeleydb's db.h file first in the include path # when attempting to compile and it will fail. f = "/usr/include/db.h" - if os.path.exists(f) and not db_incs: + 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: @@ -1020,10 +1026,8 @@ class PyBuildExt(build_ext): define_macros = define_macros, include_dirs = [expatinc], sources = ['pyexpat.c', - 'expat/xmlparse.c', - 'expat/xmlrole.c', - 'expat/xmltok.c', - ], + ], + libraries = ['expat'], )) # Fredrik Lundh's cElementTree module. Note that this also @@ -1063,6 +1067,9 @@ class PyBuildExt(build_ext): if platform in ('linux2', 'freebsd4', 'freebsd5', 'freebsd6', 'freebsd7'): exts.append( Extension('ossaudiodev', ['ossaudiodev.c']) ) + elif platform.startswith('openbsd'): + exts.append( Extension('ossaudiodev', ['ossaudiodev.c'], + libraries = ['ossaudio'],) ) if platform == 'sunos5': # SunOS specific modules @@ -1195,7 +1202,7 @@ class PyBuildExt(build_ext): # For 8.4a2, the X11 headers are not included. Rather than include a # complicated search, this is a hard-coded path. It could bail out # if X11 libs are not found... - include_dirs.append('/usr/X11R6/include') + include_dirs.append(usrx11r6('include')) frameworks = ['-framework', 'Tcl', '-framework', 'Tk'] ext = Extension('_tkinter', ['_tkinter.c', 'tkappinit.c'], @@ -1224,8 +1231,7 @@ class PyBuildExt(build_ext): # The versions with dots are used on Unix, and the versions without # dots on Windows, for detection by cygwin. tcllib = tklib = tcl_includes = tk_includes = None - for version in ['8.5', '85', '8.4', '84', '8.3', '83', '8.2', - '82', '8.1', '81', '8.0', '80']: + for version in ['85']: tklib = self.compiler.find_library_file(lib_dirs, 'tk' + version) tcllib = self.compiler.find_library_file(lib_dirs, 'tcl' + version) if tklib and tcllib: @@ -1266,17 +1272,9 @@ class PyBuildExt(build_ext): if platform == 'sunos5': include_dirs.append('/usr/openwin/include') added_lib_dirs.append('/usr/openwin/lib') - elif os.path.exists('/usr/X11R6/include'): - include_dirs.append('/usr/X11R6/include') - added_lib_dirs.append('/usr/X11R6/lib64') - added_lib_dirs.append('/usr/X11R6/lib') - elif os.path.exists('/usr/X11R5/include'): - include_dirs.append('/usr/X11R5/include') - added_lib_dirs.append('/usr/X11R5/lib') - else: - # Assume default location for X11 - include_dirs.append('/usr/X11/include') - added_lib_dirs.append('/usr/X11/lib') + elif True: + include_dirs.append(usrx11r6('include')) + added_lib_dirs.append(usrx11r6('lib')) # If Cygwin, then verify that X is installed before proceeding if platform == 'cygwin': @@ -1536,8 +1534,7 @@ def main(): ext_modules=[Extension('_struct', ['_struct.c'])], # Scripts to install - scripts = ['Tools/scripts/pydoc', 'Tools/scripts/idle', - 'Lib/smtpd.py'] + scripts = [] ) # --install-platlib