mirror of
https://github.com/python/cpython.git
synced 2025-08-30 21:48:47 +00:00
bpo-36146: Refactor setup.py: PyBuildExt.add() method (GH-12097)
* Add PyBuildExt.add() which adds the extension directly to self.extensions, rather than using a temporary 'exts' local variable in detect_modules() and then add 'exts' to self.extensions * Convert 'missing' local variable from detect_modules() into PyBuildExt.missing attribute * _detect_openssl(), _decimal_ext() and _detect_nis() now call directly self.add(), rather than returning an extension (or None if not found). * Rename _decimal_ext() to _detect_decimal() for consistency with other methods.
This commit is contained in:
parent
96d81583be
commit
8058bdae3e
1 changed files with 203 additions and 226 deletions
429
setup.py
429
setup.py
|
@ -229,13 +229,17 @@ class PyBuildExt(build_ext):
|
||||||
build_ext.__init__(self, dist)
|
build_ext.__init__(self, dist)
|
||||||
self.failed = []
|
self.failed = []
|
||||||
self.failed_on_import = []
|
self.failed_on_import = []
|
||||||
|
self.missing = []
|
||||||
if '-j' in os.environ.get('MAKEFLAGS', ''):
|
if '-j' in os.environ.get('MAKEFLAGS', ''):
|
||||||
self.parallel = True
|
self.parallel = True
|
||||||
|
|
||||||
|
def add(self, ext):
|
||||||
|
self.extensions.append(ext)
|
||||||
|
|
||||||
def build_extensions(self):
|
def build_extensions(self):
|
||||||
|
|
||||||
# Detect which modules should be compiled
|
# Detect which modules should be compiled
|
||||||
missing = self.detect_modules()
|
self.detect_modules()
|
||||||
|
|
||||||
# Remove modules that are present on the disabled list
|
# Remove modules that are present on the disabled list
|
||||||
extensions = [ext for ext in self.extensions
|
extensions = [ext for ext in self.extensions
|
||||||
|
@ -331,12 +335,12 @@ class PyBuildExt(build_ext):
|
||||||
print("%-*s %-*s %-*s" % (longest, e, longest, f,
|
print("%-*s %-*s %-*s" % (longest, e, longest, f,
|
||||||
longest, g))
|
longest, g))
|
||||||
|
|
||||||
if missing:
|
if self.missing:
|
||||||
print()
|
print()
|
||||||
print("Python build finished successfully!")
|
print("Python build finished successfully!")
|
||||||
print("The necessary bits to build these optional modules were not "
|
print("The necessary bits to build these optional modules were not "
|
||||||
"found:")
|
"found:")
|
||||||
print_three_column(missing)
|
print_three_column(self.missing)
|
||||||
print("To find the necessary bits, look in setup.py in"
|
print("To find the necessary bits, look in setup.py in"
|
||||||
" detect_modules() for the module's name.")
|
" detect_modules() for the module's name.")
|
||||||
print()
|
print()
|
||||||
|
@ -374,7 +378,7 @@ class PyBuildExt(build_ext):
|
||||||
print()
|
print()
|
||||||
|
|
||||||
if any('_ssl' in l
|
if any('_ssl' in l
|
||||||
for l in (missing, self.failed, self.failed_on_import)):
|
for l in (self.missing, self.failed, self.failed_on_import)):
|
||||||
print()
|
print()
|
||||||
print("Could not build the ssl module!")
|
print("Could not build the ssl module!")
|
||||||
print("Python requires an OpenSSL 1.0.2 or 1.1 compatible "
|
print("Python requires an OpenSSL 1.0.2 or 1.1 compatible "
|
||||||
|
@ -609,8 +613,6 @@ class PyBuildExt(build_ext):
|
||||||
inc_dirs = (self.compiler.include_dirs +
|
inc_dirs = (self.compiler.include_dirs +
|
||||||
sysroot_paths(('CPPFLAGS', 'CFLAGS', 'CC'),
|
sysroot_paths(('CPPFLAGS', 'CFLAGS', 'CC'),
|
||||||
system_include_dirs))
|
system_include_dirs))
|
||||||
exts = []
|
|
||||||
missing = []
|
|
||||||
|
|
||||||
config_h = sysconfig.get_config_h_filename()
|
config_h = sysconfig.get_config_h_filename()
|
||||||
with open(config_h) as file:
|
with open(config_h) as file:
|
||||||
|
@ -650,22 +652,22 @@ class PyBuildExt(build_ext):
|
||||||
#
|
#
|
||||||
|
|
||||||
# array objects
|
# array objects
|
||||||
exts.append( Extension('array', ['arraymodule.c']) )
|
self.add(Extension('array', ['arraymodule.c']))
|
||||||
|
|
||||||
# Context Variables
|
# Context Variables
|
||||||
exts.append( Extension('_contextvars', ['_contextvarsmodule.c']) )
|
self.add(Extension('_contextvars', ['_contextvarsmodule.c']))
|
||||||
|
|
||||||
shared_math = 'Modules/_math.o'
|
shared_math = 'Modules/_math.o'
|
||||||
# complex math library functions
|
# complex math library functions
|
||||||
exts.append( Extension('cmath', ['cmathmodule.c'],
|
self.add(Extension('cmath', ['cmathmodule.c'],
|
||||||
extra_objects=[shared_math],
|
extra_objects=[shared_math],
|
||||||
depends=['_math.h', shared_math],
|
depends=['_math.h', shared_math],
|
||||||
libraries=['m']) )
|
libraries=['m']))
|
||||||
# math library functions, e.g. sin()
|
# math library functions, e.g. sin()
|
||||||
exts.append( Extension('math', ['mathmodule.c'],
|
self.add(Extension('math', ['mathmodule.c'],
|
||||||
extra_objects=[shared_math],
|
extra_objects=[shared_math],
|
||||||
depends=['_math.h', shared_math],
|
depends=['_math.h', shared_math],
|
||||||
libraries=['m']) )
|
libraries=['m']))
|
||||||
|
|
||||||
# time libraries: librt may be needed for clock_gettime()
|
# time libraries: librt may be needed for clock_gettime()
|
||||||
time_libs = []
|
time_libs = []
|
||||||
|
@ -674,48 +676,48 @@ class PyBuildExt(build_ext):
|
||||||
time_libs.append(lib)
|
time_libs.append(lib)
|
||||||
|
|
||||||
# time operations and variables
|
# time operations and variables
|
||||||
exts.append( Extension('time', ['timemodule.c'],
|
self.add(Extension('time', ['timemodule.c'],
|
||||||
libraries=time_libs) )
|
libraries=time_libs))
|
||||||
# libm is needed by delta_new() that uses round() and by accum() that
|
# libm is needed by delta_new() that uses round() and by accum() that
|
||||||
# uses modf().
|
# uses modf().
|
||||||
exts.append( Extension('_datetime', ['_datetimemodule.c'],
|
self.add(Extension('_datetime', ['_datetimemodule.c'],
|
||||||
libraries=['m']) )
|
libraries=['m']))
|
||||||
# random number generator implemented in C
|
# random number generator implemented in C
|
||||||
exts.append( Extension("_random", ["_randommodule.c"]) )
|
self.add(Extension("_random", ["_randommodule.c"]))
|
||||||
# bisect
|
# bisect
|
||||||
exts.append( Extension("_bisect", ["_bisectmodule.c"]) )
|
self.add(Extension("_bisect", ["_bisectmodule.c"]))
|
||||||
# heapq
|
# heapq
|
||||||
exts.append( Extension("_heapq", ["_heapqmodule.c"]) )
|
self.add(Extension("_heapq", ["_heapqmodule.c"]))
|
||||||
# C-optimized pickle replacement
|
# C-optimized pickle replacement
|
||||||
exts.append( Extension("_pickle", ["_pickle.c"]) )
|
self.add(Extension("_pickle", ["_pickle.c"]))
|
||||||
# atexit
|
# atexit
|
||||||
exts.append( Extension("atexit", ["atexitmodule.c"]) )
|
self.add(Extension("atexit", ["atexitmodule.c"]))
|
||||||
# _json speedups
|
# _json speedups
|
||||||
exts.append( Extension("_json", ["_json.c"],
|
self.add(Extension("_json", ["_json.c"],
|
||||||
# pycore_accu.h requires Py_BUILD_CORE_BUILTIN
|
# pycore_accu.h requires Py_BUILD_CORE_BUILTIN
|
||||||
extra_compile_args=['-DPy_BUILD_CORE_BUILTIN']) )
|
extra_compile_args=['-DPy_BUILD_CORE_BUILTIN']))
|
||||||
# Python C API test module
|
# Python C API test module
|
||||||
exts.append( Extension('_testcapi', ['_testcapimodule.c'],
|
self.add(Extension('_testcapi', ['_testcapimodule.c'],
|
||||||
depends=['testcapi_long.h']) )
|
depends=['testcapi_long.h']))
|
||||||
# Python PEP-3118 (buffer protocol) test module
|
# Python PEP-3118 (buffer protocol) test module
|
||||||
exts.append( Extension('_testbuffer', ['_testbuffer.c']) )
|
self.add(Extension('_testbuffer', ['_testbuffer.c']))
|
||||||
# Test loading multiple modules from one compiled file (http://bugs.python.org/issue16421)
|
# Test loading multiple modules from one compiled file (http://bugs.python.org/issue16421)
|
||||||
exts.append( Extension('_testimportmultiple', ['_testimportmultiple.c']) )
|
self.add(Extension('_testimportmultiple', ['_testimportmultiple.c']))
|
||||||
# Test multi-phase extension module init (PEP 489)
|
# Test multi-phase extension module init (PEP 489)
|
||||||
exts.append( Extension('_testmultiphase', ['_testmultiphase.c']) )
|
self.add(Extension('_testmultiphase', ['_testmultiphase.c']))
|
||||||
# profiler (_lsprof is for cProfile.py)
|
# profiler (_lsprof is for cProfile.py)
|
||||||
exts.append( Extension('_lsprof', ['_lsprof.c', 'rotatingtree.c']) )
|
self.add(Extension('_lsprof', ['_lsprof.c', 'rotatingtree.c']))
|
||||||
# static Unicode character database
|
# static Unicode character database
|
||||||
exts.append( Extension('unicodedata', ['unicodedata.c'],
|
self.add(Extension('unicodedata', ['unicodedata.c'],
|
||||||
depends=['unicodedata_db.h', 'unicodename_db.h']) )
|
depends=['unicodedata_db.h', 'unicodename_db.h']))
|
||||||
# _opcode module
|
# _opcode module
|
||||||
exts.append( Extension('_opcode', ['_opcode.c']) )
|
self.add(Extension('_opcode', ['_opcode.c']))
|
||||||
# asyncio speedups
|
# asyncio speedups
|
||||||
exts.append( Extension("_asyncio", ["_asynciomodule.c"]) )
|
self.add(Extension("_asyncio", ["_asynciomodule.c"]))
|
||||||
# _abc speedups
|
# _abc speedups
|
||||||
exts.append( Extension("_abc", ["_abc.c"]) )
|
self.add(Extension("_abc", ["_abc.c"]))
|
||||||
# _queue module
|
# _queue module
|
||||||
exts.append( Extension("_queue", ["_queuemodule.c"]) )
|
self.add(Extension("_queue", ["_queuemodule.c"]))
|
||||||
|
|
||||||
# Modules with some UNIX dependencies -- on by default:
|
# Modules with some UNIX dependencies -- on by default:
|
||||||
# (If you have a really backward UNIX, select and socket may not be
|
# (If you have a really backward UNIX, select and socket may not be
|
||||||
|
@ -726,41 +728,42 @@ class PyBuildExt(build_ext):
|
||||||
if (config_h_vars.get('FLOCK_NEEDS_LIBBSD', False)):
|
if (config_h_vars.get('FLOCK_NEEDS_LIBBSD', False)):
|
||||||
# May be necessary on AIX for flock function
|
# May be necessary on AIX for flock function
|
||||||
libs = ['bsd']
|
libs = ['bsd']
|
||||||
exts.append( Extension('fcntl', ['fcntlmodule.c'], libraries=libs) )
|
self.add(Extension('fcntl', ['fcntlmodule.c'],
|
||||||
|
libraries=libs))
|
||||||
# pwd(3)
|
# pwd(3)
|
||||||
exts.append( Extension('pwd', ['pwdmodule.c']) )
|
self.add(Extension('pwd', ['pwdmodule.c']))
|
||||||
# grp(3)
|
# grp(3)
|
||||||
if not VXWORKS:
|
if not VXWORKS:
|
||||||
exts.append( Extension('grp', ['grpmodule.c']) )
|
self.add(Extension('grp', ['grpmodule.c']))
|
||||||
# spwd, shadow passwords
|
# spwd, shadow passwords
|
||||||
if (config_h_vars.get('HAVE_GETSPNAM', False) or
|
if (config_h_vars.get('HAVE_GETSPNAM', False) or
|
||||||
config_h_vars.get('HAVE_GETSPENT', False)):
|
config_h_vars.get('HAVE_GETSPENT', False)):
|
||||||
exts.append( Extension('spwd', ['spwdmodule.c']) )
|
self.add(Extension('spwd', ['spwdmodule.c']))
|
||||||
else:
|
else:
|
||||||
missing.append('spwd')
|
self.missing.append('spwd')
|
||||||
|
|
||||||
# select(2); not on ancient System V
|
# select(2); not on ancient System V
|
||||||
exts.append( Extension('select', ['selectmodule.c']) )
|
self.add(Extension('select', ['selectmodule.c']))
|
||||||
|
|
||||||
# Fred Drake's interface to the Python parser
|
# Fred Drake's interface to the Python parser
|
||||||
exts.append( Extension('parser', ['parsermodule.c']) )
|
self.add(Extension('parser', ['parsermodule.c']))
|
||||||
|
|
||||||
# Memory-mapped files (also works on Win32).
|
# Memory-mapped files (also works on Win32).
|
||||||
exts.append( Extension('mmap', ['mmapmodule.c']) )
|
self.add(Extension('mmap', ['mmapmodule.c']))
|
||||||
|
|
||||||
# Lance Ellinghaus's syslog module
|
# Lance Ellinghaus's syslog module
|
||||||
# syslog daemon interface
|
# syslog daemon interface
|
||||||
exts.append( Extension('syslog', ['syslogmodule.c']) )
|
self.add(Extension('syslog', ['syslogmodule.c']))
|
||||||
|
|
||||||
# Fuzz tests.
|
# Fuzz tests.
|
||||||
exts.append( Extension(
|
self.add(Extension('_xxtestfuzz',
|
||||||
'_xxtestfuzz',
|
['_xxtestfuzz/_xxtestfuzz.c',
|
||||||
['_xxtestfuzz/_xxtestfuzz.c', '_xxtestfuzz/fuzzer.c'])
|
'_xxtestfuzz/fuzzer.c']))
|
||||||
)
|
|
||||||
|
|
||||||
# Python interface to subinterpreter C-API.
|
# Python interface to subinterpreter C-API.
|
||||||
exts.append(Extension('_xxsubinterpreters', ['_xxsubinterpretersmodule.c'],
|
self.add(Extension('_xxsubinterpreters',
|
||||||
define_macros=[('Py_BUILD_CORE', '')]))
|
['_xxsubinterpretersmodule.c'],
|
||||||
|
define_macros=[('Py_BUILD_CORE', '')]))
|
||||||
|
|
||||||
#
|
#
|
||||||
# Here ends the simple stuff. From here on, modules need certain
|
# Here ends the simple stuff. From here on, modules need certain
|
||||||
|
@ -776,8 +779,8 @@ class PyBuildExt(build_ext):
|
||||||
# 64-bit platforms.
|
# 64-bit platforms.
|
||||||
#
|
#
|
||||||
# audioop needs libm for floor() in multiple functions.
|
# audioop needs libm for floor() in multiple functions.
|
||||||
exts.append( Extension('audioop', ['audioop.c'],
|
self.add(Extension('audioop', ['audioop.c'],
|
||||||
libraries=['m']) )
|
libraries=['m']))
|
||||||
|
|
||||||
# readline
|
# readline
|
||||||
do_readline = self.compiler.find_library_file(lib_dirs, 'readline')
|
do_readline = self.compiler.find_library_file(lib_dirs, 'readline')
|
||||||
|
@ -855,12 +858,12 @@ class PyBuildExt(build_ext):
|
||||||
['/usr/lib/termcap'],
|
['/usr/lib/termcap'],
|
||||||
'termcap'):
|
'termcap'):
|
||||||
readline_libs.append('termcap')
|
readline_libs.append('termcap')
|
||||||
exts.append( Extension('readline', ['readline.c'],
|
self.add(Extension('readline', ['readline.c'],
|
||||||
library_dirs=['/usr/lib/termcap'],
|
library_dirs=['/usr/lib/termcap'],
|
||||||
extra_link_args=readline_extra_link_args,
|
extra_link_args=readline_extra_link_args,
|
||||||
libraries=readline_libs) )
|
libraries=readline_libs))
|
||||||
else:
|
else:
|
||||||
missing.append('readline')
|
self.missing.append('readline')
|
||||||
|
|
||||||
# crypt module.
|
# crypt module.
|
||||||
|
|
||||||
|
@ -870,65 +873,60 @@ class PyBuildExt(build_ext):
|
||||||
libs = []
|
libs = []
|
||||||
|
|
||||||
if not VXWORKS:
|
if not VXWORKS:
|
||||||
exts.append( Extension('_crypt', ['_cryptmodule.c'], libraries=libs) )
|
self.add(Extension('_crypt', ['_cryptmodule.c'],
|
||||||
|
libraries=libs))
|
||||||
elif self.compiler.find_library_file(lib_dirs, 'OPENSSL'):
|
elif self.compiler.find_library_file(lib_dirs, 'OPENSSL'):
|
||||||
libs = ['OPENSSL']
|
libs = ['OPENSSL']
|
||||||
exts.append( Extension('_crypt', ['_cryptmodule.c'], libraries=libs) )
|
self.add(Extension('_crypt', ['_cryptmodule.c'],
|
||||||
|
libraries=libs))
|
||||||
|
|
||||||
# CSV files
|
# CSV files
|
||||||
exts.append( Extension('_csv', ['_csv.c']) )
|
self.add(Extension('_csv', ['_csv.c']))
|
||||||
|
|
||||||
# POSIX subprocess module helper.
|
# POSIX subprocess module helper.
|
||||||
exts.append( Extension('_posixsubprocess', ['_posixsubprocess.c']) )
|
self.add(Extension('_posixsubprocess', ['_posixsubprocess.c']))
|
||||||
|
|
||||||
# socket(2)
|
# socket(2)
|
||||||
if not VXWORKS:
|
if not VXWORKS:
|
||||||
exts.append( Extension('_socket', ['socketmodule.c'],
|
self.add(Extension('_socket', ['socketmodule.c'],
|
||||||
depends = ['socketmodule.h']) )
|
depends=['socketmodule.h']))
|
||||||
elif self.compiler.find_library_file(lib_dirs, 'net'):
|
elif self.compiler.find_library_file(lib_dirs, 'net'):
|
||||||
libs = ['net']
|
libs = ['net']
|
||||||
exts.append( Extension('_socket', ['socketmodule.c'],
|
self.add(Extension('_socket', ['socketmodule.c'],
|
||||||
depends = ['socketmodule.h'], libraries=libs) )
|
depends=['socketmodule.h'],
|
||||||
|
libraries=libs))
|
||||||
|
|
||||||
# Detect SSL support for the socket module (via _ssl)
|
# Detect SSL support for the socket module (via _ssl)
|
||||||
ssl_ext, hashlib_ext = self._detect_openssl(inc_dirs, lib_dirs)
|
self._detect_openssl(inc_dirs, lib_dirs)
|
||||||
if ssl_ext is not None:
|
|
||||||
exts.append(ssl_ext)
|
|
||||||
else:
|
|
||||||
missing.append('_ssl')
|
|
||||||
if hashlib_ext is not None:
|
|
||||||
exts.append(hashlib_ext)
|
|
||||||
else:
|
|
||||||
missing.append('_hashlib')
|
|
||||||
|
|
||||||
# We always compile these even when OpenSSL is available (issue #14693).
|
# We always compile these even when OpenSSL is available (issue #14693).
|
||||||
# It's harmless and the object code is tiny (40-50 KiB per module,
|
# It's harmless and the object code is tiny (40-50 KiB per module,
|
||||||
# only loaded when actually used).
|
# only loaded when actually used).
|
||||||
exts.append( Extension('_sha256', ['sha256module.c'],
|
self.add(Extension('_sha256', ['sha256module.c'],
|
||||||
depends=['hashlib.h']) )
|
depends=['hashlib.h']))
|
||||||
exts.append( Extension('_sha512', ['sha512module.c'],
|
self.add(Extension('_sha512', ['sha512module.c'],
|
||||||
depends=['hashlib.h']) )
|
depends=['hashlib.h']))
|
||||||
exts.append( Extension('_md5', ['md5module.c'],
|
self.add(Extension('_md5', ['md5module.c'],
|
||||||
depends=['hashlib.h']) )
|
depends=['hashlib.h']))
|
||||||
exts.append( Extension('_sha1', ['sha1module.c'],
|
self.add(Extension('_sha1', ['sha1module.c'],
|
||||||
depends=['hashlib.h']) )
|
depends=['hashlib.h']))
|
||||||
|
|
||||||
blake2_deps = glob(os.path.join(os.getcwd(), srcdir,
|
blake2_deps = glob(os.path.join(os.getcwd(), srcdir,
|
||||||
'Modules/_blake2/impl/*'))
|
'Modules/_blake2/impl/*'))
|
||||||
blake2_deps.append('hashlib.h')
|
blake2_deps.append('hashlib.h')
|
||||||
|
|
||||||
exts.append( Extension('_blake2',
|
self.add(Extension('_blake2',
|
||||||
['_blake2/blake2module.c',
|
['_blake2/blake2module.c',
|
||||||
'_blake2/blake2b_impl.c',
|
'_blake2/blake2b_impl.c',
|
||||||
'_blake2/blake2s_impl.c'],
|
'_blake2/blake2s_impl.c'],
|
||||||
depends=blake2_deps) )
|
depends=blake2_deps))
|
||||||
|
|
||||||
sha3_deps = glob(os.path.join(os.getcwd(), srcdir,
|
sha3_deps = glob(os.path.join(os.getcwd(), srcdir,
|
||||||
'Modules/_sha3/kcp/*'))
|
'Modules/_sha3/kcp/*'))
|
||||||
sha3_deps.append('hashlib.h')
|
sha3_deps.append('hashlib.h')
|
||||||
exts.append( Extension('_sha3',
|
self.add(Extension('_sha3',
|
||||||
['_sha3/sha3module.c'],
|
['_sha3/sha3module.c'],
|
||||||
depends=sha3_deps))
|
depends=sha3_deps))
|
||||||
|
|
||||||
# Modules that provide persistent dictionary-like semantics. You will
|
# Modules that provide persistent dictionary-like semantics. You will
|
||||||
# probably want to arrange for at least one of them to be available on
|
# probably want to arrange for at least one of them to be available on
|
||||||
|
@ -1244,14 +1242,14 @@ class PyBuildExt(build_ext):
|
||||||
# avoid a runtime library path for a system library dir
|
# avoid a runtime library path for a system library dir
|
||||||
if sqlite_libdir and sqlite_libdir[0] in lib_dirs:
|
if sqlite_libdir and sqlite_libdir[0] in lib_dirs:
|
||||||
sqlite_libdir = None
|
sqlite_libdir = None
|
||||||
exts.append(Extension('_sqlite3', sqlite_srcs,
|
self.add(Extension('_sqlite3', sqlite_srcs,
|
||||||
define_macros=sqlite_defines,
|
define_macros=sqlite_defines,
|
||||||
include_dirs=include_dirs,
|
include_dirs=include_dirs,
|
||||||
library_dirs=sqlite_libdir,
|
library_dirs=sqlite_libdir,
|
||||||
extra_link_args=sqlite_extra_link_args,
|
extra_link_args=sqlite_extra_link_args,
|
||||||
libraries=["sqlite3",]))
|
libraries=["sqlite3",]))
|
||||||
else:
|
else:
|
||||||
missing.append('_sqlite3')
|
self.missing.append('_sqlite3')
|
||||||
|
|
||||||
dbm_setup_debug = False # verbose debug prints from this script?
|
dbm_setup_debug = False # verbose debug prints from this script?
|
||||||
dbm_order = ['gdbm']
|
dbm_order = ['gdbm']
|
||||||
|
@ -1325,33 +1323,29 @@ class PyBuildExt(build_ext):
|
||||||
libraries=dblibs)
|
libraries=dblibs)
|
||||||
break
|
break
|
||||||
if dbmext is not None:
|
if dbmext is not None:
|
||||||
exts.append(dbmext)
|
self.add(dbmext)
|
||||||
else:
|
else:
|
||||||
missing.append('_dbm')
|
self.missing.append('_dbm')
|
||||||
|
|
||||||
# Anthony Baxter's gdbm module. GNU dbm(3) will require -lgdbm:
|
# Anthony Baxter's gdbm module. GNU dbm(3) will require -lgdbm:
|
||||||
if ('gdbm' in dbm_order and
|
if ('gdbm' in dbm_order and
|
||||||
self.compiler.find_library_file(lib_dirs, 'gdbm')):
|
self.compiler.find_library_file(lib_dirs, 'gdbm')):
|
||||||
exts.append( Extension('_gdbm', ['_gdbmmodule.c'],
|
self.add(Extension('_gdbm', ['_gdbmmodule.c'],
|
||||||
libraries = ['gdbm'] ) )
|
libraries=['gdbm']))
|
||||||
else:
|
else:
|
||||||
missing.append('_gdbm')
|
self.missing.append('_gdbm')
|
||||||
|
|
||||||
# Unix-only modules
|
# Unix-only modules
|
||||||
if not MS_WINDOWS:
|
if not MS_WINDOWS:
|
||||||
if not VXWORKS:
|
if not VXWORKS:
|
||||||
# Steen Lumholt's termios module
|
# Steen Lumholt's termios module
|
||||||
exts.append( Extension('termios', ['termios.c']) )
|
self.add(Extension('termios', ['termios.c']))
|
||||||
# Jeremy Hylton's rlimit interface
|
# Jeremy Hylton's rlimit interface
|
||||||
exts.append( Extension('resource', ['resource.c']) )
|
self.add(Extension('resource', ['resource.c']))
|
||||||
else:
|
else:
|
||||||
missing.extend(['resource', 'termios'])
|
self.missing.extend(['resource', 'termios'])
|
||||||
|
|
||||||
nis = self._detect_nis(inc_dirs, lib_dirs)
|
self._detect_nis(inc_dirs, lib_dirs)
|
||||||
if nis is not None:
|
|
||||||
exts.append(nis)
|
|
||||||
else:
|
|
||||||
missing.append('nis')
|
|
||||||
|
|
||||||
# Curses support, requiring the System V version of curses, often
|
# Curses support, requiring the System V version of curses, often
|
||||||
# provided by the ncurses library.
|
# provided by the ncurses library.
|
||||||
|
@ -1380,10 +1374,10 @@ class PyBuildExt(build_ext):
|
||||||
|
|
||||||
if curses_library.startswith('ncurses'):
|
if curses_library.startswith('ncurses'):
|
||||||
curses_libs = [curses_library]
|
curses_libs = [curses_library]
|
||||||
exts.append( Extension('_curses', ['_cursesmodule.c'],
|
self.add(Extension('_curses', ['_cursesmodule.c'],
|
||||||
include_dirs=curses_includes,
|
include_dirs=curses_includes,
|
||||||
define_macros=curses_defines,
|
define_macros=curses_defines,
|
||||||
libraries = curses_libs) )
|
libraries=curses_libs))
|
||||||
elif curses_library == 'curses' and not MACOS:
|
elif curses_library == 'curses' and not MACOS:
|
||||||
# OSX has an old Berkeley curses, not good enough for
|
# OSX has an old Berkeley curses, not good enough for
|
||||||
# the _curses module.
|
# the _curses module.
|
||||||
|
@ -1394,21 +1388,21 @@ class PyBuildExt(build_ext):
|
||||||
else:
|
else:
|
||||||
curses_libs = ['curses']
|
curses_libs = ['curses']
|
||||||
|
|
||||||
exts.append( Extension('_curses', ['_cursesmodule.c'],
|
self.add(Extension('_curses', ['_cursesmodule.c'],
|
||||||
define_macros=curses_defines,
|
define_macros=curses_defines,
|
||||||
libraries = curses_libs) )
|
libraries=curses_libs))
|
||||||
else:
|
else:
|
||||||
missing.append('_curses')
|
self.missing.append('_curses')
|
||||||
|
|
||||||
# If the curses module is enabled, check for the panel module
|
# If the curses module is enabled, check for the panel module
|
||||||
if (module_enabled(exts, '_curses') and
|
if (module_enabled(self.extensions, '_curses') and
|
||||||
self.compiler.find_library_file(lib_dirs, panel_library)):
|
self.compiler.find_library_file(lib_dirs, panel_library)):
|
||||||
exts.append( Extension('_curses_panel', ['_curses_panel.c'],
|
self.add(Extension('_curses_panel', ['_curses_panel.c'],
|
||||||
include_dirs=curses_includes,
|
include_dirs=curses_includes,
|
||||||
define_macros=curses_defines,
|
define_macros=curses_defines,
|
||||||
libraries = [panel_library] + curses_libs) )
|
libraries=[panel_library, *curses_libs]))
|
||||||
else:
|
else:
|
||||||
missing.append('_curses_panel')
|
self.missing.append('_curses_panel')
|
||||||
|
|
||||||
# Andrew Kuchling's zlib module. Note that some versions of zlib
|
# Andrew Kuchling's zlib module. Note that some versions of zlib
|
||||||
# 1.1.3 have security problems. See CERT Advisory CA-2002-07:
|
# 1.1.3 have security problems. See CERT Advisory CA-2002-07:
|
||||||
|
@ -1444,16 +1438,16 @@ class PyBuildExt(build_ext):
|
||||||
zlib_extra_link_args = ('-Wl,-search_paths_first',)
|
zlib_extra_link_args = ('-Wl,-search_paths_first',)
|
||||||
else:
|
else:
|
||||||
zlib_extra_link_args = ()
|
zlib_extra_link_args = ()
|
||||||
exts.append( Extension('zlib', ['zlibmodule.c'],
|
self.add(Extension('zlib', ['zlibmodule.c'],
|
||||||
libraries = ['z'],
|
libraries=['z'],
|
||||||
extra_link_args = zlib_extra_link_args))
|
extra_link_args=zlib_extra_link_args))
|
||||||
have_zlib = True
|
have_zlib = True
|
||||||
else:
|
else:
|
||||||
missing.append('zlib')
|
self.missing.append('zlib')
|
||||||
else:
|
else:
|
||||||
missing.append('zlib')
|
self.missing.append('zlib')
|
||||||
else:
|
else:
|
||||||
missing.append('zlib')
|
self.missing.append('zlib')
|
||||||
|
|
||||||
# Helper module for various ascii-encoders. Uses zlib for an optimized
|
# Helper module for various ascii-encoders. Uses zlib for an optimized
|
||||||
# crc32 if we have it. Otherwise binascii uses its own.
|
# crc32 if we have it. Otherwise binascii uses its own.
|
||||||
|
@ -1465,10 +1459,10 @@ class PyBuildExt(build_ext):
|
||||||
extra_compile_args = []
|
extra_compile_args = []
|
||||||
libraries = []
|
libraries = []
|
||||||
extra_link_args = []
|
extra_link_args = []
|
||||||
exts.append( Extension('binascii', ['binascii.c'],
|
self.add(Extension('binascii', ['binascii.c'],
|
||||||
extra_compile_args = extra_compile_args,
|
extra_compile_args=extra_compile_args,
|
||||||
libraries = libraries,
|
libraries=libraries,
|
||||||
extra_link_args = extra_link_args) )
|
extra_link_args=extra_link_args))
|
||||||
|
|
||||||
# Gustavo Niemeyer's bz2 module.
|
# Gustavo Niemeyer's bz2 module.
|
||||||
if (self.compiler.find_library_file(lib_dirs, 'bz2')):
|
if (self.compiler.find_library_file(lib_dirs, 'bz2')):
|
||||||
|
@ -1476,18 +1470,18 @@ class PyBuildExt(build_ext):
|
||||||
bz2_extra_link_args = ('-Wl,-search_paths_first',)
|
bz2_extra_link_args = ('-Wl,-search_paths_first',)
|
||||||
else:
|
else:
|
||||||
bz2_extra_link_args = ()
|
bz2_extra_link_args = ()
|
||||||
exts.append( Extension('_bz2', ['_bz2module.c'],
|
self.add(Extension('_bz2', ['_bz2module.c'],
|
||||||
libraries = ['bz2'],
|
libraries=['bz2'],
|
||||||
extra_link_args = bz2_extra_link_args) )
|
extra_link_args=bz2_extra_link_args))
|
||||||
else:
|
else:
|
||||||
missing.append('_bz2')
|
self.missing.append('_bz2')
|
||||||
|
|
||||||
# LZMA compression support.
|
# LZMA compression support.
|
||||||
if self.compiler.find_library_file(lib_dirs, 'lzma'):
|
if self.compiler.find_library_file(lib_dirs, 'lzma'):
|
||||||
exts.append( Extension('_lzma', ['_lzmamodule.c'],
|
self.add(Extension('_lzma', ['_lzmamodule.c'],
|
||||||
libraries = ['lzma']) )
|
libraries=['lzma']))
|
||||||
else:
|
else:
|
||||||
missing.append('_lzma')
|
self.missing.append('_lzma')
|
||||||
|
|
||||||
# Interface to the Expat XML parser
|
# Interface to the Expat XML parser
|
||||||
#
|
#
|
||||||
|
@ -1539,40 +1533,38 @@ class PyBuildExt(build_ext):
|
||||||
if ret >> 8 == 0:
|
if ret >> 8 == 0:
|
||||||
extra_compile_args.append('-Wno-implicit-fallthrough')
|
extra_compile_args.append('-Wno-implicit-fallthrough')
|
||||||
|
|
||||||
exts.append(Extension('pyexpat',
|
self.add(Extension('pyexpat',
|
||||||
define_macros = define_macros,
|
define_macros=define_macros,
|
||||||
extra_compile_args = extra_compile_args,
|
extra_compile_args=extra_compile_args,
|
||||||
include_dirs = expat_inc,
|
include_dirs=expat_inc,
|
||||||
libraries = expat_lib,
|
libraries=expat_lib,
|
||||||
sources = ['pyexpat.c'] + expat_sources,
|
sources=['pyexpat.c'] + expat_sources,
|
||||||
depends = expat_depends,
|
depends=expat_depends))
|
||||||
))
|
|
||||||
|
|
||||||
# Fredrik Lundh's cElementTree module. Note that this also
|
# Fredrik Lundh's cElementTree module. Note that this also
|
||||||
# uses expat (via the CAPI hook in pyexpat).
|
# uses expat (via the CAPI hook in pyexpat).
|
||||||
|
|
||||||
if os.path.isfile(os.path.join(srcdir, 'Modules', '_elementtree.c')):
|
if os.path.isfile(os.path.join(srcdir, 'Modules', '_elementtree.c')):
|
||||||
define_macros.append(('USE_PYEXPAT_CAPI', None))
|
define_macros.append(('USE_PYEXPAT_CAPI', None))
|
||||||
exts.append(Extension('_elementtree',
|
self.add(Extension('_elementtree',
|
||||||
define_macros = define_macros,
|
define_macros=define_macros,
|
||||||
include_dirs = expat_inc,
|
include_dirs=expat_inc,
|
||||||
libraries = expat_lib,
|
libraries=expat_lib,
|
||||||
sources = ['_elementtree.c'],
|
sources=['_elementtree.c'],
|
||||||
depends = ['pyexpat.c'] + expat_sources +
|
depends=['pyexpat.c', *expat_sources,
|
||||||
expat_depends,
|
*expat_depends]))
|
||||||
))
|
|
||||||
else:
|
else:
|
||||||
missing.append('_elementtree')
|
self.missing.append('_elementtree')
|
||||||
|
|
||||||
# Hye-Shik Chang's CJKCodecs modules.
|
# Hye-Shik Chang's CJKCodecs modules.
|
||||||
exts.append(Extension('_multibytecodec',
|
self.add(Extension('_multibytecodec',
|
||||||
['cjkcodecs/multibytecodec.c']))
|
['cjkcodecs/multibytecodec.c']))
|
||||||
for loc in ('kr', 'jp', 'cn', 'tw', 'hk', 'iso2022'):
|
for loc in ('kr', 'jp', 'cn', 'tw', 'hk', 'iso2022'):
|
||||||
exts.append(Extension('_codecs_%s' % loc,
|
self.add(Extension('_codecs_%s' % loc,
|
||||||
['cjkcodecs/_codecs_%s.c' % loc]))
|
['cjkcodecs/_codecs_%s.c' % loc]))
|
||||||
|
|
||||||
# Stefan Krah's _decimal module
|
# Stefan Krah's _decimal module
|
||||||
exts.append(self._decimal_ext())
|
self._detect_decimal()
|
||||||
|
|
||||||
# Thomas Heller's _ctypes module
|
# Thomas Heller's _ctypes module
|
||||||
self.detect_ctypes(inc_dirs, lib_dirs)
|
self.detect_ctypes(inc_dirs, lib_dirs)
|
||||||
|
@ -1621,37 +1613,33 @@ class PyBuildExt(build_ext):
|
||||||
if sysconfig.get_config_var('SHM_NEEDS_LIBRT'):
|
if sysconfig.get_config_var('SHM_NEEDS_LIBRT'):
|
||||||
# need to link with librt to get shm_open()
|
# need to link with librt to get shm_open()
|
||||||
libs.append('rt')
|
libs.append('rt')
|
||||||
exts.append( Extension('_posixshmem', posixshmem_srcs,
|
self.add(Extension('_posixshmem', posixshmem_srcs,
|
||||||
define_macros={},
|
define_macros={},
|
||||||
libraries=libs,
|
libraries=libs,
|
||||||
include_dirs=["Modules/_multiprocessing"]))
|
include_dirs=["Modules/_multiprocessing"]))
|
||||||
|
|
||||||
exts.append ( Extension('_multiprocessing', multiprocessing_srcs,
|
self.add(Extension('_multiprocessing', multiprocessing_srcs,
|
||||||
define_macros=list(macros.items()),
|
define_macros=list(macros.items()),
|
||||||
include_dirs=["Modules/_multiprocessing"]))
|
include_dirs=["Modules/_multiprocessing"]))
|
||||||
# End multiprocessing
|
# End multiprocessing
|
||||||
|
|
||||||
# Platform-specific libraries
|
# Platform-specific libraries
|
||||||
if HOST_PLATFORM.startswith(('linux', 'freebsd', 'gnukfreebsd')):
|
if HOST_PLATFORM.startswith(('linux', 'freebsd', 'gnukfreebsd')):
|
||||||
exts.append( Extension('ossaudiodev', ['ossaudiodev.c']) )
|
self.add(Extension('ossaudiodev', ['ossaudiodev.c']))
|
||||||
else:
|
else:
|
||||||
missing.append('ossaudiodev')
|
self.missing.append('ossaudiodev')
|
||||||
|
|
||||||
if MACOS:
|
if MACOS:
|
||||||
exts.append(
|
self.add(Extension('_scproxy', ['_scproxy.c'],
|
||||||
Extension('_scproxy', ['_scproxy.c'],
|
extra_link_args=[
|
||||||
extra_link_args=[
|
'-framework', 'SystemConfiguration',
|
||||||
'-framework', 'SystemConfiguration',
|
'-framework', 'CoreFoundation']))
|
||||||
'-framework', 'CoreFoundation',
|
|
||||||
]))
|
|
||||||
|
|
||||||
self.extensions.extend(exts)
|
|
||||||
|
|
||||||
# Call the method for detecting whether _tkinter can be compiled
|
# Call the method for detecting whether _tkinter can be compiled
|
||||||
self.detect_tkinter(inc_dirs, lib_dirs)
|
self.detect_tkinter(inc_dirs, lib_dirs)
|
||||||
|
|
||||||
if '_tkinter' not in [e.name for e in self.extensions]:
|
if '_tkinter' not in [e.name for e in self.extensions]:
|
||||||
missing.append('_tkinter')
|
self.missing.append('_tkinter')
|
||||||
|
|
||||||
# Build the _uuid module if possible
|
# Build the _uuid module if possible
|
||||||
uuid_incs = find_file("uuid.h", inc_dirs, ["/usr/include/uuid"])
|
uuid_incs = find_file("uuid.h", inc_dirs, ["/usr/include/uuid"])
|
||||||
|
@ -1664,7 +1652,7 @@ class PyBuildExt(build_ext):
|
||||||
libraries=uuid_libs,
|
libraries=uuid_libs,
|
||||||
include_dirs=uuid_incs))
|
include_dirs=uuid_incs))
|
||||||
else:
|
else:
|
||||||
missing.append('_uuid')
|
self.missing.append('_uuid')
|
||||||
|
|
||||||
## # Uncomment these lines if you want to play with xxmodule.c
|
## # Uncomment these lines if you want to play with xxmodule.c
|
||||||
## ext = Extension('xx', ['xxmodule.c'])
|
## ext = Extension('xx', ['xxmodule.c'])
|
||||||
|
@ -1675,8 +1663,6 @@ class PyBuildExt(build_ext):
|
||||||
define_macros=[('Py_LIMITED_API', '0x03050000')])
|
define_macros=[('Py_LIMITED_API', '0x03050000')])
|
||||||
self.extensions.append(ext)
|
self.extensions.append(ext)
|
||||||
|
|
||||||
return missing
|
|
||||||
|
|
||||||
def detect_tkinter_explicitly(self):
|
def detect_tkinter_explicitly(self):
|
||||||
# Build _tkinter using explicit locations for Tcl/Tk.
|
# Build _tkinter using explicit locations for Tcl/Tk.
|
||||||
#
|
#
|
||||||
|
@ -2035,7 +2021,7 @@ class PyBuildExt(build_ext):
|
||||||
# for dlopen, see bpo-32647
|
# for dlopen, see bpo-32647
|
||||||
ext.libraries.append('dl')
|
ext.libraries.append('dl')
|
||||||
|
|
||||||
def _decimal_ext(self):
|
def _detect_decimal(self):
|
||||||
extra_compile_args = []
|
extra_compile_args = []
|
||||||
undef_macros = []
|
undef_macros = []
|
||||||
if '--with-system-libmpdec' in sysconfig.get_config_var("CONFIG_ARGS"):
|
if '--with-system-libmpdec' in sysconfig.get_config_var("CONFIG_ARGS"):
|
||||||
|
@ -2142,17 +2128,14 @@ class PyBuildExt(build_ext):
|
||||||
|
|
||||||
# Uncomment for extra functionality:
|
# Uncomment for extra functionality:
|
||||||
#define_macros.append(('EXTRA_FUNCTIONALITY', 1))
|
#define_macros.append(('EXTRA_FUNCTIONALITY', 1))
|
||||||
ext = Extension (
|
self.add(Extension('_decimal',
|
||||||
'_decimal',
|
include_dirs=include_dirs,
|
||||||
include_dirs=include_dirs,
|
libraries=libraries,
|
||||||
libraries=libraries,
|
define_macros=define_macros,
|
||||||
define_macros=define_macros,
|
undef_macros=undef_macros,
|
||||||
undef_macros=undef_macros,
|
extra_compile_args=extra_compile_args,
|
||||||
extra_compile_args=extra_compile_args,
|
sources=sources,
|
||||||
sources=sources,
|
depends=depends))
|
||||||
depends=depends
|
|
||||||
)
|
|
||||||
return ext
|
|
||||||
|
|
||||||
def _detect_openssl(self, inc_dirs, lib_dirs):
|
def _detect_openssl(self, inc_dirs, lib_dirs):
|
||||||
config_vars = sysconfig.get_config_vars()
|
config_vars = sysconfig.get_config_vars()
|
||||||
|
@ -2191,29 +2174,24 @@ class PyBuildExt(build_ext):
|
||||||
ssl_incs.extend(krb5_h)
|
ssl_incs.extend(krb5_h)
|
||||||
|
|
||||||
if config_vars.get("HAVE_X509_VERIFY_PARAM_SET1_HOST"):
|
if config_vars.get("HAVE_X509_VERIFY_PARAM_SET1_HOST"):
|
||||||
ssl_ext = Extension(
|
self.add(Extension('_ssl', ['_ssl.c'],
|
||||||
'_ssl', ['_ssl.c'],
|
include_dirs=openssl_includes,
|
||||||
include_dirs=openssl_includes,
|
library_dirs=openssl_libdirs,
|
||||||
library_dirs=openssl_libdirs,
|
libraries=openssl_libs,
|
||||||
libraries=openssl_libs,
|
depends=['socketmodule.h']))
|
||||||
depends=['socketmodule.h']
|
|
||||||
)
|
|
||||||
else:
|
else:
|
||||||
ssl_ext = None
|
self.missing.append('_ssl')
|
||||||
|
|
||||||
hashlib_ext = Extension(
|
self.add(Extension('_hashlib', ['_hashopenssl.c'],
|
||||||
'_hashlib', ['_hashopenssl.c'],
|
depends=['hashlib.h'],
|
||||||
depends=['hashlib.h'],
|
include_dirs=openssl_includes,
|
||||||
include_dirs=openssl_includes,
|
library_dirs=openssl_libdirs,
|
||||||
library_dirs=openssl_libdirs,
|
libraries=openssl_libs))
|
||||||
libraries=openssl_libs,
|
|
||||||
)
|
|
||||||
|
|
||||||
return ssl_ext, hashlib_ext
|
|
||||||
|
|
||||||
def _detect_nis(self, inc_dirs, lib_dirs):
|
def _detect_nis(self, inc_dirs, lib_dirs):
|
||||||
if MS_WINDOWS or CYGWIN or HOST_PLATFORM == 'qnx6':
|
if MS_WINDOWS or CYGWIN or HOST_PLATFORM == 'qnx6':
|
||||||
return None
|
self.missing.append('nis')
|
||||||
|
return
|
||||||
|
|
||||||
libs = []
|
libs = []
|
||||||
library_dirs = []
|
library_dirs = []
|
||||||
|
@ -2232,7 +2210,8 @@ class PyBuildExt(build_ext):
|
||||||
)
|
)
|
||||||
if rpcsvc_inc is None or rpc_inc is None:
|
if rpcsvc_inc is None or rpc_inc is None:
|
||||||
# not found
|
# not found
|
||||||
return None
|
self.missing.append('nis')
|
||||||
|
return
|
||||||
includes_dirs.extend(rpcsvc_inc)
|
includes_dirs.extend(rpcsvc_inc)
|
||||||
includes_dirs.extend(rpc_inc)
|
includes_dirs.extend(rpc_inc)
|
||||||
|
|
||||||
|
@ -2249,12 +2228,10 @@ class PyBuildExt(build_ext):
|
||||||
if self.compiler.find_library_file(lib_dirs, 'tirpc'):
|
if self.compiler.find_library_file(lib_dirs, 'tirpc'):
|
||||||
libs.append('tirpc')
|
libs.append('tirpc')
|
||||||
|
|
||||||
return Extension(
|
self.add(Extension('nis', ['nismodule.c'],
|
||||||
'nis', ['nismodule.c'],
|
libraries=libs,
|
||||||
libraries=libs,
|
library_dirs=library_dirs,
|
||||||
library_dirs=library_dirs,
|
include_dirs=includes_dirs))
|
||||||
include_dirs=includes_dirs
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
class PyBuildInstall(install):
|
class PyBuildInstall(install):
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue