diff options
Diffstat (limited to 'setup.py')
-rw-r--r-- | setup.py | 78 |
1 files changed, 55 insertions, 23 deletions
@@ -317,6 +317,23 @@ class PyBuildExt(build_ext): if platform in ['osf1', 'unixware7', 'openunix8']: lib_dirs += ['/usr/ccs/lib'] + if platform == 'darwin': + # This should work on any unixy platform ;-) + # If the user has bothered specifying additional -I and -L flags + # in OPT and LDFLAGS we might as well use them here. + # NOTE: using shlex.split would technically be more correct, but + # also gives a bootstrap problem. Let's hope nobody uses directories + # with whitespace in the name to store libraries. + cflags, ldflags = sysconfig.get_config_vars( + 'CFLAGS', 'LDFLAGS') + for item in cflags.split(): + if item.startswith('-I'): + inc_dirs.append(item[2:]) + + for item in ldflags.split(): + if item.startswith('-L'): + lib_dirs.append(item[2:]) + # Check for MacOS X, which doesn't need libm.a at all math_libs = ['m'] if platform in ['darwin', 'beos', 'mac']: @@ -459,6 +476,16 @@ class PyBuildExt(build_ext): if find_file('readline/rlconf.h', inc_dirs, []) is None: do_readline = False if do_readline: + if sys.platform == 'darwin': + # In every directory on the search path search for a dynamic + # library and then a static library, instead of first looking + # for dynamic libraries on the entiry path. + # This way a staticly linked custom readline gets picked up + # before the (broken) dynamic library in /usr/lib. + readline_extra_link_args = ('-Wl,-search_paths_first',) + else: + readline_extra_link_args = () + readline_libs = ['readline'] if self.compiler.find_library_file(lib_dirs, 'ncursesw'): @@ -474,6 +501,7 @@ class PyBuildExt(build_ext): readline_libs.append('termcap') exts.append( Extension('readline', ['readline.c'], library_dirs=['/usr/lib/termcap'], + extra_link_args=readline_extra_link_args, libraries=readline_libs) ) if platform not in ['mac']: # crypt module. @@ -708,7 +736,11 @@ class PyBuildExt(build_ext): MIN_SQLITE_VERSION_NUMBER = (3, 0, 8) MIN_SQLITE_VERSION = ".".join([str(x) for x in MIN_SQLITE_VERSION_NUMBER]) - for d in sqlite_inc_paths + inc_dirs: + + # Scan the default include directories before the SQLite specific + # ones. This allows one to override the copy of sqlite on OSX, + # where /usr/include contains an old version of sqlite. + for d in inc_dirs + sqlite_inc_paths: f = os.path.join(d, "sqlite3.h") if os.path.exists(f): if sqlite_setup_debug: print "sqlite: found %s"%f @@ -743,10 +775,8 @@ class PyBuildExt(build_ext): sqlite_libdir = [os.path.abspath(os.path.dirname(sqlite_libfile))] if sqlite_incdir and sqlite_libdir: - sqlite_srcs = ['_sqlite/adapters.c', - '_sqlite/cache.c', + sqlite_srcs = ['_sqlite/cache.c', '_sqlite/connection.c', - '_sqlite/converters.c', '_sqlite/cursor.c', '_sqlite/microprotocols.c', '_sqlite/module.c', @@ -755,17 +785,22 @@ class PyBuildExt(build_ext): '_sqlite/statement.c', '_sqlite/util.c', ] - PYSQLITE_VERSION = "2.2.0" sqlite_defines = [] if sys.platform != "win32": sqlite_defines.append(('MODULE_NAME', '"sqlite3"')) else: sqlite_defines.append(('MODULE_NAME', '\\"sqlite3\\"')) - sqlite_defines.append(('PY_MAJOR_VERSION', - str(sys.version_info[0]))) - sqlite_defines.append(('PY_MINOR_VERSION', - str(sys.version_info[1]))) + + if sys.platform == 'darwin': + # In every directory on the search path search for a dynamic + # library and then a static library, instead of first looking + # for dynamic libraries on the entiry path. + # This way a staticly linked custom sqlite gets picked up + # before the dynamic library in /usr/lib. + sqlite_extra_link_args = ('-Wl,-search_paths_first',) + else: + sqlite_extra_link_args = () exts.append(Extension('_sqlite3', sqlite_srcs, define_macros=sqlite_defines, @@ -773,6 +808,7 @@ class PyBuildExt(build_ext): sqlite_incdir], library_dirs=sqlite_libdir, runtime_library_dirs=sqlite_libdir, + extra_link_args=sqlite_extra_link_args, libraries=["sqlite3",])) # Look for Berkeley db 1.85. Note that it is built as a different @@ -921,20 +957,11 @@ class PyBuildExt(build_ext): # # More information on Expat can be found at www.libexpat.org. # - if sys.byteorder == "little": - xmlbo = "1234" - else: - xmlbo = "4321" expatinc = os.path.join(os.getcwd(), srcdir, 'Modules', 'expat') define_macros = [ - ('XML_NS', '1'), - ('XML_DTD', '1'), - ('BYTEORDER', xmlbo), - ('XML_CONTEXT_BYTES','1024'), - ] - for feature_macro in ['HAVE_MEMMOVE', 'HAVE_BCOPY']: - if config_h_vars.has_key(feature_macro): - define_macros.append((feature_macro, '1')) + ('HAVE_EXPAT_CONFIG_H', '1'), + ] + exts.append(Extension('pyexpat', define_macros = define_macros, include_dirs = [expatinc], @@ -1275,7 +1302,12 @@ class PyBuildExt(build_ext): '_ctypes', 'libffi')) ffi_configfile = os.path.join(ffi_builddir, 'fficonfig.py') - if self.force or not os.path.exists(ffi_configfile): + from distutils.dep_util import newer_group + + config_sources = [os.path.join(ffi_srcdir, fname) + for fname in os.listdir(ffi_srcdir)] + if self.force or newer_group(config_sources, + ffi_configfile): from distutils.dir_util import mkpath mkpath(ffi_builddir) config_args = [] @@ -1456,7 +1488,7 @@ def main(): 'install_lib':PyBuildInstallLib}, # The struct module is defined here, because build_ext won't be # called unless there's at least one extension module defined. - ext_modules=[Extension('struct', ['structmodule.c'])], + ext_modules=[Extension('_struct', ['_struct.c'])], # Scripts to install scripts = ['Tools/scripts/pydoc', 'Tools/scripts/idle', |