summaryrefslogtreecommitdiff
path: root/setup.py
diff options
context:
space:
mode:
Diffstat (limited to 'setup.py')
-rw-r--r--setup.py458
1 files changed, 249 insertions, 209 deletions
diff --git a/setup.py b/setup.py
index 4fe1f4577c..6b47451bed 100644
--- a/setup.py
+++ b/setup.py
@@ -6,9 +6,9 @@ __version__ = "$Revision$"
import sys, os, imp, re, optparse
from glob import glob
from platform import machine as platform_machine
+import sysconfig
from distutils import log
-from distutils import sysconfig
from distutils import text_file
from distutils.errors import *
from distutils.core import Extension, setup
@@ -17,6 +17,9 @@ from distutils.command.install import install
from distutils.command.install_lib import install_lib
from distutils.spawn import find_executable
+# Were we compiled --with-pydebug or with #define Py_DEBUG?
+COMPILED_WITH_PYDEBUG = hasattr(sys, 'gettotalrefcount')
+
# This global variable is used to hold the list of modules to be disabled.
disabled_module_list = []
@@ -164,73 +167,60 @@ class PyBuildExt(build_ext):
if not srcdir:
# Maybe running on Windows but not using CYGWIN?
raise ValueError("No source directory; cannot proceed.")
-
- # Figure out the location of the source code for extension modules
- # (This logic is copied in distutils.test.test_sysconfig,
- # so building in a separate directory does not break test_distutils.)
- moddir = os.path.join(os.getcwd(), srcdir, 'Modules')
- moddir = os.path.normpath(moddir)
- srcdir, tail = os.path.split(moddir)
- srcdir = os.path.normpath(srcdir)
- moddir = os.path.normpath(moddir)
-
- moddirlist = [moddir]
- incdirlist = ['./Include']
+ srcdir = os.path.abspath(srcdir)
+ moddirlist = [os.path.join(srcdir, 'Modules')]
# Platform-dependent module source and include directories
+ incdirlist = []
platform = self.get_platform()
- if platform in ('darwin', 'mac') and ("--disable-toolbox-glue" not in
+ if platform == 'darwin' and ("--disable-toolbox-glue" not in
sysconfig.get_config_var("CONFIG_ARGS")):
# Mac OS X also includes some mac-specific modules
- macmoddir = os.path.join(os.getcwd(), srcdir, 'Mac/Modules')
+ macmoddir = os.path.join(srcdir, 'Mac/Modules')
moddirlist.append(macmoddir)
- incdirlist.append('./Mac/Include')
-
- alldirlist = moddirlist + incdirlist
+ incdirlist.append(os.path.join(srcdir, 'Mac/Include'))
# Fix up the paths for scripts, too
self.distribution.scripts = [os.path.join(srcdir, filename)
for filename in self.distribution.scripts]
# Python header files
- headers = glob("Include/*.h") + ["pyconfig.h"]
-
+ headers = [sysconfig.get_config_h_filename()]
+ headers += glob(os.path.join(sysconfig.get_path('platinclude'), "*.h"))
for ext in self.extensions[:]:
ext.sources = [ find_module_file(filename, moddirlist)
for filename in ext.sources ]
if ext.depends is not None:
- ext.depends = [find_module_file(filename, alldirlist)
+ ext.depends = [find_module_file(filename, moddirlist)
for filename in ext.depends]
else:
ext.depends = []
# re-compile extensions if a header file has been changed
ext.depends.extend(headers)
- ext.include_dirs.append( '.' ) # to get config.h
- for incdir in incdirlist:
- ext.include_dirs.append( os.path.join(srcdir, incdir) )
+ # platform specific include directories
+ ext.include_dirs.extend(incdirlist)
# If a module has already been built statically,
# don't build it here
if ext.name in sys.builtin_module_names:
self.extensions.remove(ext)
- if platform != 'mac':
- # Parse Modules/Setup and Modules/Setup.local to figure out which
- # modules are turned on in the file.
- remove_modules = []
- for filename in ('Modules/Setup', 'Modules/Setup.local'):
- input = text_file.TextFile(filename, join_lines=1)
- while 1:
- line = input.readline()
- if not line: break
- line = line.split()
- remove_modules.append(line[0])
- input.close()
-
- for ext in self.extensions[:]:
- if ext.name in remove_modules:
- self.extensions.remove(ext)
+ # Parse Modules/Setup and Modules/Setup.local to figure out which
+ # modules are turned on in the file.
+ remove_modules = []
+ for filename in ('Modules/Setup', 'Modules/Setup.local'):
+ input = text_file.TextFile(filename, join_lines=1)
+ while 1:
+ line = input.readline()
+ if not line: break
+ line = line.split()
+ remove_modules.append(line[0])
+ input.close()
+
+ for ext in self.extensions[:]:
+ if ext.name in remove_modules:
+ self.extensions.remove(ext)
# When you run "make CC=altcc" or something similar, you really want
# those environment variables passed into the setup.py phase. Here's
@@ -261,7 +251,8 @@ class PyBuildExt(build_ext):
if missing:
print
- print "Failed to find the necessary bits to build these modules:"
+ print ("Python build finished, but the necessary bits to build "
+ "these modules were not found:")
print_three_column(missing)
print ("To find the necessary bits, look in setup.py in"
" detect_modules() for the module's name.")
@@ -354,10 +345,33 @@ class PyBuildExt(build_ext):
return platform
return sys.platform
+ def add_multiarch_paths(self):
+ # Debian/Ubuntu multiarch support.
+ # https://wiki.ubuntu.com/MultiarchSpec
+ if not find_executable('dpkg-architecture'):
+ return
+ tmpfile = os.path.join(self.build_temp, 'multiarch')
+ if not os.path.exists(self.build_temp):
+ os.makedirs(self.build_temp)
+ ret = os.system(
+ 'dpkg-architecture -qDEB_HOST_MULTIARCH > %s 2> /dev/null' %
+ tmpfile)
+ try:
+ if ret >> 8 == 0:
+ with open(tmpfile) as fp:
+ multiarch_path_component = fp.readline().strip()
+ add_dir_to_list(self.compiler.library_dirs,
+ '/usr/lib/' + multiarch_path_component)
+ add_dir_to_list(self.compiler.include_dirs,
+ '/usr/include/' + multiarch_path_component)
+ finally:
+ os.unlink(tmpfile)
+
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')
+ self.add_multiarch_paths()
# Add paths specified in the environment variables LDFLAGS and
# CPPFLAGS for header and library files.
@@ -393,7 +407,12 @@ class PyBuildExt(build_ext):
for directory in reversed(options.dirs):
add_dir_to_list(dir_list, directory)
- if os.path.normpath(sys.prefix) != '/usr':
+ if os.path.normpath(sys.prefix) != '/usr' \
+ and not sysconfig.get_config_var('PYTHONFRAMEWORK'):
+ # OSX note: Don't add LIBDIR and INCLUDEDIR to building a framework
+ # (PYTHONFRAMEWORK is set) to avoid # linking problems when
+ # building a framework with different architectures than
+ # the one that is currently installed (issue #7473)
add_dir_to_list(self.compiler.library_dirs,
sysconfig.get_config_var("LIBDIR"))
add_dir_to_list(self.compiler.include_dirs,
@@ -419,7 +438,7 @@ class PyBuildExt(build_ext):
config_h_vars = sysconfig.parse_config_h(open(config_h))
platform = self.get_platform()
- (srcdir,) = sysconfig.get_config_vars('srcdir')
+ srcdir = sysconfig.get_config_var('srcdir')
# Check for AtheOS which has libraries in non-standard locations
if platform == 'atheos':
@@ -451,7 +470,7 @@ class PyBuildExt(build_ext):
# Check for MacOS X, which doesn't need libm.a at all
math_libs = ['m']
- if platform in ['darwin', 'beos', 'mac']:
+ if platform in ['darwin', 'beos']:
math_libs = []
# XXX Omitted modules: gl, pure, dl, SGI-specific modules
@@ -462,16 +481,17 @@ class PyBuildExt(build_ext):
#
# Some modules that are normally always on:
- exts.append( Extension('_weakref', ['_weakref.c']) )
+ #exts.append( Extension('_weakref', ['_weakref.c']) )
# array objects
exts.append( Extension('array', ['arraymodule.c']) )
# complex math library functions
- exts.append( Extension('cmath', ['cmathmodule.c'],
+ exts.append( Extension('cmath', ['cmathmodule.c', '_math.c'],
+ depends=['_math.h'],
libraries=math_libs) )
-
# math library functions, e.g. sin()
- exts.append( Extension('math', ['mathmodule.c'],
+ exts.append( Extension('math', ['mathmodule.c', '_math.c'],
+ depends=['_math.h'],
libraries=math_libs) )
# fast string operations implemented in C
exts.append( Extension('strop', ['stropmodule.c']) )
@@ -495,10 +515,11 @@ class PyBuildExt(build_ext):
exts.append( Extension("_heapq", ["_heapqmodule.c"]) )
# operator.add() and similar goodies
exts.append( Extension('operator', ['operator.c']) )
- # Python 3.0 _fileio module
- exts.append( Extension("_fileio", ["_fileio.c"]) )
- # Python 3.0 _bytesio module
- exts.append( Extension("_bytesio", ["_bytesio.c"]) )
+ # Python 3.1 _io library
+ exts.append( Extension("_io",
+ ["_io/bufferedio.c", "_io/bytesio.c", "_io/fileio.c",
+ "_io/iobase.c", "_io/_iomodule.c", "_io/stringio.c", "_io/textio.c"],
+ depends=["_io/_iomodule.h"], include_dirs=["Modules/_io"]))
# _functools
exts.append( Extension("_functools", ["_functoolsmodule.c"]) )
# _json speedups
@@ -536,20 +557,21 @@ class PyBuildExt(build_ext):
# supported...)
# fcntl(2) and ioctl(2)
- exts.append( Extension('fcntl', ['fcntlmodule.c']) )
- if platform not in ['mac']:
- # pwd(3)
- exts.append( Extension('pwd', ['pwdmodule.c']) )
- # grp(3)
- exts.append( Extension('grp', ['grpmodule.c']) )
- # spwd, shadow passwords
- if (config_h_vars.get('HAVE_GETSPNAM', False) or
- config_h_vars.get('HAVE_GETSPENT', False)):
- exts.append( Extension('spwd', ['spwdmodule.c']) )
- else:
- missing.append('spwd')
+ libs = []
+ if (config_h_vars.get('FLOCK_NEEDS_LIBBSD', False)):
+ # May be necessary on AIX for flock function
+ libs = ['bsd']
+ exts.append( Extension('fcntl', ['fcntlmodule.c'], libraries=libs) )
+ # pwd(3)
+ exts.append( Extension('pwd', ['pwdmodule.c']) )
+ # grp(3)
+ exts.append( Extension('grp', ['grpmodule.c']) )
+ # spwd, shadow passwords
+ if (config_h_vars.get('HAVE_GETSPNAM', False) or
+ config_h_vars.get('HAVE_GETSPENT', False)):
+ exts.append( Extension('spwd', ['spwdmodule.c']) )
else:
- missing.extend(['pwd', 'grp', 'spwd'])
+ missing.append('spwd')
# select(2); not on ancient System V
exts.append( Extension('select', ['selectmodule.c']) )
@@ -562,17 +584,14 @@ class PyBuildExt(build_ext):
exts.append( Extension('cPickle', ['cPickle.c']) )
# Memory-mapped files (also works on Win32).
- if platform not in ['atheos', 'mac']:
+ if platform not in ['atheos']:
exts.append( Extension('mmap', ['mmapmodule.c']) )
else:
missing.append('mmap')
# Lance Ellinghaus's syslog module
- if platform not in ['mac']:
- # syslog daemon interface
- exts.append( Extension('syslog', ['syslogmodule.c']) )
- else:
- missing.append('syslog')
+ # syslog daemon interface
+ exts.append( Extension('syslog', ['syslogmodule.c']) )
# George Neville-Neil's timing module:
# Deprecated in PEP 4 http://www.python.org/peps/pep-0004.html
@@ -621,13 +640,9 @@ class PyBuildExt(build_ext):
break
# Issue 7384: If readline is already linked against curses,
# use the same library for the readline and curses modules.
- # Disabled since applications relying on ncursesw might break.
- #
- # if 'curses' in readline_termcap_library:
- # curses_library = readline_termcap_library
- # elif self.compiler.find_library_file(lib_dirs, 'ncursesw'):
- # (...)
- if self.compiler.find_library_file(lib_dirs, 'ncursesw'):
+ if 'curses' in readline_termcap_library:
+ curses_library = readline_termcap_library
+ elif self.compiler.find_library_file(lib_dirs, 'ncursesw'):
curses_library = 'ncursesw'
elif self.compiler.find_library_file(lib_dirs, 'ncurses'):
curses_library = 'ncurses'
@@ -662,8 +677,8 @@ class PyBuildExt(build_ext):
elif curses_library:
readline_libs.append(curses_library)
elif self.compiler.find_library_file(lib_dirs +
- ['/usr/lib/termcap'],
- 'termcap'):
+ ['/usr/lib/termcap'],
+ 'termcap'):
readline_libs.append('termcap')
exts.append( Extension('readline', ['readline.c'],
library_dirs=['/usr/lib/termcap'],
@@ -672,16 +687,13 @@ class PyBuildExt(build_ext):
else:
missing.append('readline')
- if platform not in ['mac']:
- # crypt module.
+ # crypt module.
- if self.compiler.find_library_file(lib_dirs, 'crypt'):
- libs = ['crypt']
- else:
- libs = []
- exts.append( Extension('crypt', ['cryptmodule.c'], libraries=libs) )
+ if self.compiler.find_library_file(lib_dirs, 'crypt'):
+ libs = ['crypt']
else:
- missing.append('crypt')
+ libs = []
+ exts.append( Extension('crypt', ['cryptmodule.c'], libraries=libs) )
# CSV files
exts.append( Extension('_csv', ['_csv.c']) )
@@ -739,19 +751,24 @@ class PyBuildExt(build_ext):
print "IOError while reading opensshv.h:", msg
pass
-
- if (ssl_incs is not None and
- ssl_libs is not None and
- openssl_ver >= 0x00907000):
- # The _hashlib module wraps optimized implementations
- # of hash functions from the OpenSSL library.
- exts.append( Extension('_hashlib', ['_hashopenssl.c'],
- include_dirs = ssl_incs,
- library_dirs = ssl_libs,
- libraries = ['ssl', 'crypto']) )
- # these aren't strictly missing since they are unneeded.
- #missing.extend(['_sha', '_md5'])
- else:
+ min_openssl_ver = 0x00907000
+ have_any_openssl = ssl_incs is not None and ssl_libs is not None
+ have_usable_openssl = (have_any_openssl and
+ openssl_ver >= min_openssl_ver)
+
+ if have_any_openssl:
+ if have_usable_openssl:
+ # The _hashlib module wraps optimized implementations
+ # of hash functions from the OpenSSL library.
+ exts.append( Extension('_hashlib', ['_hashopenssl.c'],
+ include_dirs = ssl_incs,
+ library_dirs = ssl_libs,
+ libraries = ['ssl', 'crypto']) )
+ else:
+ print ("warning: openssl 0x%08x is too old for _hashlib" %
+ openssl_ver)
+ missing.append('_hashlib')
+ if COMPILED_WITH_PYDEBUG or not have_usable_openssl:
# The _sha module implements the SHA1 hash algorithm.
exts.append( Extension('_sha', ['shamodule.c']) )
# The _md5 module implements the RSA Data Security, Inc. MD5
@@ -760,9 +777,9 @@ class PyBuildExt(build_ext):
exts.append( Extension('_md5',
sources = ['md5module.c', 'md5.c'],
depends = ['md5.h']) )
- missing.append('_hashlib')
- if (openssl_ver < 0x00908000):
+ min_sha2_openssl_ver = 0x00908000
+ if COMPILED_WITH_PYDEBUG or openssl_ver < min_sha2_openssl_ver:
# OpenSSL doesn't do these until 0.9.8 so we'll bring our own hash
exts.append( Extension('_sha256', ['sha256module.c']) )
exts.append( Extension('_sha512', ['sha512module.c']) )
@@ -782,8 +799,8 @@ class PyBuildExt(build_ext):
# a release. Most open source OSes come with one or more
# versions of BerkeleyDB already installed.
- max_db_ver = (4, 7)
- min_db_ver = (3, 3)
+ max_db_ver = (4, 8)
+ min_db_ver = (4, 1)
db_setup_debug = False # verbose debug prints from this script?
def allow_db_ver(db_ver):
@@ -941,7 +958,7 @@ class PyBuildExt(build_ext):
tmp.append(dn)
db_dirs_to_check = tmp
- # Look for a version specific db-X.Y before an ambiguoius dbX
+ # Look for a version specific db-X.Y before an ambiguous 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?
@@ -1061,12 +1078,14 @@ class PyBuildExt(build_ext):
else:
sqlite_defines.append(('MODULE_NAME', '\\"sqlite3\\"'))
+ # Comment this out if you want the sqlite3 module to be able to load extensions.
+ sqlite_defines.append(("SQLITE_OMIT_LOAD_EXTENSION", "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
+ # for dynamic libraries on the entire path.
+ # This way a statically linked custom sqlite gets picked up
# before the dynamic library in /usr/lib.
sqlite_extra_link_args = ('-Wl,-search_paths_first',)
else:
@@ -1120,53 +1139,87 @@ class PyBuildExt(build_ext):
else:
missing.append('bsddb185')
+ dbm_order = ['gdbm']
# The standard Unix dbm module:
if platform not in ['cygwin']:
- if find_file("ndbm.h", inc_dirs, []) is not None:
- # Some systems have -lndbm, others don't
- if self.compiler.find_library_file(lib_dirs, 'ndbm'):
- ndbm_libs = ['ndbm']
- else:
- ndbm_libs = []
- exts.append( Extension('dbm', ['dbmmodule.c'],
- define_macros=[('HAVE_NDBM_H',None)],
- libraries = ndbm_libs ) )
- elif self.compiler.find_library_file(lib_dirs, 'gdbm'):
- gdbm_libs = ['gdbm']
- if self.compiler.find_library_file(lib_dirs, 'gdbm_compat'):
- gdbm_libs.append('gdbm_compat')
- if find_file("gdbm/ndbm.h", inc_dirs, []) is not None:
- exts.append( Extension(
- 'dbm', ['dbmmodule.c'],
- define_macros=[('HAVE_GDBM_NDBM_H',None)],
- libraries = gdbm_libs ) )
- elif find_file("gdbm-ndbm.h", inc_dirs, []) is not None:
- exts.append( Extension(
- 'dbm', ['dbmmodule.c'],
- define_macros=[('HAVE_GDBM_DASH_NDBM_H',None)],
- libraries = gdbm_libs ) )
- else:
- missing.append('dbm')
- elif 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_BERKDB_H',None),
- ('DB_DBM_HSEARCH',None)],
- libraries=dblibs))
+ config_args = [arg.strip("'")
+ for arg in sysconfig.get_config_var("CONFIG_ARGS").split()]
+ dbm_args = [arg for arg in config_args
+ if arg.startswith('--with-dbmliborder=')]
+ if dbm_args:
+ dbm_order = [arg.split('=')[-1] for arg in dbm_args][-1].split(":")
+ else:
+ dbm_order = "ndbm:gdbm:bdb".split(":")
+ dbmext = None
+ for cand in dbm_order:
+ if cand == "ndbm":
+ if find_file("ndbm.h", inc_dirs, []) is not None:
+ # Some systems have -lndbm, others don't
+ if self.compiler.find_library_file(lib_dirs,
+ 'ndbm'):
+ ndbm_libs = ['ndbm']
+ else:
+ ndbm_libs = []
+ print "building dbm using ndbm"
+ dbmext = Extension('dbm', ['dbmmodule.c'],
+ define_macros=[
+ ('HAVE_NDBM_H',None),
+ ],
+ libraries=ndbm_libs)
+ break
+
+ elif cand == "gdbm":
+ if self.compiler.find_library_file(lib_dirs, 'gdbm'):
+ gdbm_libs = ['gdbm']
+ if self.compiler.find_library_file(lib_dirs,
+ 'gdbm_compat'):
+ gdbm_libs.append('gdbm_compat')
+ if find_file("gdbm/ndbm.h", inc_dirs, []) is not None:
+ print "building dbm using gdbm"
+ dbmext = Extension(
+ 'dbm', ['dbmmodule.c'],
+ define_macros=[
+ ('HAVE_GDBM_NDBM_H', None),
+ ],
+ libraries = gdbm_libs)
+ break
+ if find_file("gdbm-ndbm.h", inc_dirs, []) is not None:
+ print "building dbm using gdbm"
+ dbmext = Extension(
+ 'dbm', ['dbmmodule.c'],
+ define_macros=[
+ ('HAVE_GDBM_DASH_NDBM_H', None),
+ ],
+ libraries = gdbm_libs)
+ break
+ elif cand == "bdb":
+ if db_incs is not None:
+ print "building dbm using bdb"
+ dbmext = Extension('dbm', ['dbmmodule.c'],
+ library_dirs=dblib_dir,
+ runtime_library_dirs=dblib_dir,
+ include_dirs=db_incs,
+ define_macros=[
+ ('HAVE_BERKDB_H', None),
+ ('DB_DBM_HSEARCH', None),
+ ],
+ libraries=dblibs)
+ break
+ if dbmext is not None:
+ exts.append(dbmext)
else:
missing.append('dbm')
# Anthony Baxter's gdbm module. GNU dbm(3) will require -lgdbm:
- if (self.compiler.find_library_file(lib_dirs, 'gdbm')):
+ if ('gdbm' in dbm_order and
+ self.compiler.find_library_file(lib_dirs, 'gdbm')):
exts.append( Extension('gdbm', ['gdbmmodule.c'],
libraries = ['gdbm'] ) )
else:
missing.append('gdbm')
# Unix-only modules
- if platform not in ['mac', 'win32']:
+ if platform not in ['win32']:
# Steen Lumholt's termios module
exts.append( Extension('termios', ['termios.c']) )
# Jeremy Hylton's rlimit interface
@@ -1295,28 +1348,35 @@ class PyBuildExt(build_ext):
# Interface to the Expat XML parser
#
- # Expat was written by James Clark and is now maintained by a
- # group of developers on SourceForge; see www.libexpat.org for
- # more information. The pyexpat module was written by Paul
- # Prescod after a prototype by Jack Jansen. The Expat source
- # is included in Modules/expat/. Usage of a system
- # shared libexpat.so/expat.dll is not advised.
+ # Expat was written by James Clark and is now maintained by a group of
+ # developers on SourceForge; see www.libexpat.org for more information.
+ # The pyexpat module was written by Paul Prescod after a prototype by
+ # Jack Jansen. The Expat source is included in Modules/expat/. Usage
+ # of a system shared libexpat.so is possible with --with-system-expat
+ # configure option.
#
# 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'),
- ]
+ if '--with-system-expat' in sysconfig.get_config_var("CONFIG_ARGS"):
+ expat_inc = []
+ define_macros = []
+ expat_lib = ['expat']
+ expat_sources = []
+ else:
+ expat_inc = [os.path.join(os.getcwd(), srcdir, 'Modules', 'expat')]
+ define_macros = [
+ ('HAVE_EXPAT_CONFIG_H', '1'),
+ ]
+ expat_lib = []
+ expat_sources = ['expat/xmlparse.c',
+ 'expat/xmlrole.c',
+ 'expat/xmltok.c']
exts.append(Extension('pyexpat',
define_macros = define_macros,
- include_dirs = [expatinc],
- sources = ['pyexpat.c',
- 'expat/xmlparse.c',
- 'expat/xmlrole.c',
- 'expat/xmltok.c',
- ],
+ include_dirs = expat_inc,
+ libraries = expat_lib,
+ sources = ['pyexpat.c'] + expat_sources
))
# Fredrik Lundh's cElementTree module. Note that this also
@@ -1326,7 +1386,8 @@ class PyBuildExt(build_ext):
define_macros.append(('USE_PYEXPAT_CAPI', None))
exts.append(Extension('_elementtree',
define_macros = define_macros,
- include_dirs = [expatinc],
+ include_dirs = expat_inc,
+ libraries = expat_lib,
sources = ['_elementtree.c'],
))
else:
@@ -1364,56 +1425,29 @@ class PyBuildExt(build_ext):
libraries = ['ws2_32']
elif platform == 'darwin': # Mac OSX
- macros = dict(
- HAVE_SEM_OPEN=1,
- HAVE_SEM_TIMEDWAIT=0,
- HAVE_FD_TRANSFER=1,
- HAVE_BROKEN_SEM_GETVALUE=1
- )
+ macros = dict()
libraries = []
elif platform == 'cygwin': # Cygwin
- macros = dict(
- HAVE_SEM_OPEN=1,
- HAVE_SEM_TIMEDWAIT=1,
- HAVE_FD_TRANSFER=0,
- HAVE_BROKEN_SEM_UNLINK=1
- )
+ macros = dict()
libraries = []
elif platform in ('freebsd4', 'freebsd5', 'freebsd6', 'freebsd7', 'freebsd8'):
# FreeBSD's P1003.1b semaphore support is very experimental
# and has many known problems. (as of June 2008)
- macros = dict( # FreeBSD
- HAVE_SEM_OPEN=0,
- HAVE_SEM_TIMEDWAIT=0,
- HAVE_FD_TRANSFER=1,
- )
+ macros = dict()
libraries = []
elif platform.startswith('openbsd'):
- macros = dict( # OpenBSD
- HAVE_SEM_OPEN=0, # Not implemented
- HAVE_SEM_TIMEDWAIT=0,
- HAVE_FD_TRANSFER=1,
- )
+ macros = dict()
libraries = []
elif platform.startswith('netbsd'):
- macros = dict( # at least NetBSD 5
- HAVE_SEM_OPEN=1,
- HAVE_SEM_TIMEDWAIT=0,
- HAVE_FD_TRANSFER=1,
- HAVE_BROKEN_SEM_GETVALUE=1
- )
+ macros = dict()
libraries = []
else: # Linux and other unices
- macros = dict(
- HAVE_SEM_OPEN=1,
- HAVE_SEM_TIMEDWAIT=1,
- HAVE_FD_TRANSFER=1
- )
+ macros = dict()
libraries = ['rt']
if platform == 'win32':
@@ -1428,8 +1462,8 @@ class PyBuildExt(build_ext):
multiprocessing_srcs = [ '_multiprocessing/multiprocessing.c',
'_multiprocessing/socket_connection.c'
]
-
- if macros.get('HAVE_SEM_OPEN', False):
+ if (sysconfig.get_config_var('HAVE_SEM_OPEN') and not
+ sysconfig.get_config_var('POSIX_SEMAPHORES_NOT_ENABLED')):
multiprocessing_srcs.append('_multiprocessing/semaphore.c')
if sysconfig.get_config_var('WITH_THREAD'):
@@ -1449,8 +1483,9 @@ class PyBuildExt(build_ext):
else:
missing.append('linuxaudiodev')
- if platform in ('linux2', 'freebsd4', 'freebsd5', 'freebsd6',
- 'freebsd7', 'freebsd8'):
+ if (platform in ('linux2', 'freebsd4', 'freebsd5', 'freebsd6',
+ 'freebsd7', 'freebsd8')
+ or platform.startswith("gnukfreebsd")):
exts.append( Extension('ossaudiodev', ['ossaudiodev.c']) )
else:
missing.append('ossaudiodev')
@@ -1675,10 +1710,12 @@ 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']:
- tklib = self.compiler.find_library_file(lib_dirs, 'tk' + version)
- tcllib = self.compiler.find_library_file(lib_dirs, 'tcl' + version)
+ for version in ['8.6', '86', '8.5', '85', '8.4', '84', '8.3', '83',
+ '8.2', '82', '8.1', '81', '8.0', '80']:
+ tklib = self.compiler.find_library_file(lib_dirs,
+ 'tk' + version)
+ tcllib = self.compiler.find_library_file(lib_dirs,
+ 'tcl' + version)
if tklib and tcllib:
# Exit the loop when we've found the Tcl/Tk libraries
break
@@ -1737,11 +1774,11 @@ class PyBuildExt(build_ext):
# Check for BLT extension
if self.compiler.find_library_file(lib_dirs + added_lib_dirs,
- 'BLT8.0'):
+ 'BLT8.0'):
defs.append( ('WITH_BLT', 1) )
libs.append('BLT8.0')
elif self.compiler.find_library_file(lib_dirs + added_lib_dirs,
- 'BLT'):
+ 'BLT'):
defs.append( ('WITH_BLT', 1) )
libs.append('BLT')
@@ -1779,7 +1816,7 @@ class PyBuildExt(build_ext):
def configure_ctypes_darwin(self, ext):
# Darwin (OS X) uses preconfigured files, in
# the Modules/_ctypes/libffi_osx directory.
- (srcdir,) = sysconfig.get_config_vars('srcdir')
+ srcdir = sysconfig.get_config_var('srcdir')
ffi_srcdir = os.path.abspath(os.path.join(srcdir, 'Modules',
'_ctypes', 'libffi_osx'))
sources = [os.path.join(ffi_srcdir, p)
@@ -1808,7 +1845,7 @@ class PyBuildExt(build_ext):
if sys.platform == 'darwin':
return self.configure_ctypes_darwin(ext)
- (srcdir,) = sysconfig.get_config_vars('srcdir')
+ srcdir = sysconfig.get_config_var('srcdir')
ffi_builddir = os.path.join(self.build_temp, 'libffi')
ffi_srcdir = os.path.abspath(os.path.join(srcdir, 'Modules',
'_ctypes', 'libffi'))
@@ -1836,7 +1873,8 @@ class PyBuildExt(build_ext):
return False
fficonfig = {}
- exec open(ffi_configfile) in fficonfig
+ with open(ffi_configfile) as f:
+ exec f in fficonfig
# Add .S (preprocessed assembly) to C compiler source extensions.
self.compiler.src_extensions.append('.S')
@@ -1861,11 +1899,11 @@ class PyBuildExt(build_ext):
'_ctypes/callbacks.c',
'_ctypes/callproc.c',
'_ctypes/stgdict.c',
- '_ctypes/cfield.c',
- '_ctypes/malloc_closure.c']
+ '_ctypes/cfield.c']
depends = ['_ctypes/ctypes.h']
if sys.platform == 'darwin':
+ sources.append('_ctypes/malloc_closure.c')
sources.append('_ctypes/darwin/dlfcn_simple.c')
extra_compile_args.append('-DMACOSX')
include_dirs.append('_ctypes/darwin')
@@ -1905,7 +1943,9 @@ class PyBuildExt(build_ext):
# in /usr/include/ffi
inc_dirs.append('/usr/include/ffi')
- ffi_inc = find_file('ffi.h', [], inc_dirs)
+ ffi_inc = [sysconfig.get_config_var("LIBFFI_INCLUDEDIR")]
+ if not ffi_inc or ffi_inc[0] == '':
+ ffi_inc = find_file('ffi.h', [], inc_dirs)
if ffi_inc is not None:
ffi_h = ffi_inc[0] + '/ffi.h'
fp = open(ffi_h)