diff options
author | Christian Heimes <christian@python.org> | 2021-10-22 13:36:28 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-10-22 13:36:28 (GMT) |
commit | 03e9f5dc751b8c441a85f428abc3f432ffe46345 (patch) | |
tree | 3ea47646a3402f2ad8bdda2366bd9a214899ff44 /setup.py | |
parent | 86dfb55d2e091cf633dbd7aabcd49d96fb1f9d81 (diff) | |
download | cpython-03e9f5dc751b8c441a85f428abc3f432ffe46345.zip cpython-03e9f5dc751b8c441a85f428abc3f432ffe46345.tar.gz cpython-03e9f5dc751b8c441a85f428abc3f432ffe46345.tar.bz2 |
bpo-43974: Move Py_BUILD_CORE_MODULE into module code (GH-29157)
setup.py no longer defines Py_BUILD_CORE_MODULE. Instead every
module defines the macro before #include "Python.h" unless
Py_BUILD_CORE_BUILTIN is already defined.
Py_BUILD_CORE_BUILTIN is defined for every module that is built by
Modules/Setup.
The PR also simplifies Modules/Setup. Makefile and makesetup
already define Py_BUILD_CORE_BUILTIN and include Modules/internal
for us.
Signed-off-by: Christian Heimes <christian@python.org>
Diffstat (limited to 'setup.py')
-rw-r--r-- | setup.py | 68 |
1 files changed, 20 insertions, 48 deletions
@@ -899,8 +899,7 @@ class PyBuildExt(build_ext): # # array objects - self.add(Extension('array', ['arraymodule.c'], - extra_compile_args=['-DPy_BUILD_CORE_MODULE'])) + self.add(Extension('array', ['arraymodule.c'])) # Context Variables self.add(Extension('_contextvars', ['_contextvarsmodule.c'])) @@ -909,14 +908,12 @@ class PyBuildExt(build_ext): # math library functions, e.g. sin() self.add(Extension('math', ['mathmodule.c'], - extra_compile_args=['-DPy_BUILD_CORE_MODULE'], extra_objects=[shared_math], depends=['_math.h', shared_math], libraries=['m'])) # complex math library functions self.add(Extension('cmath', ['cmathmodule.c'], - extra_compile_args=['-DPy_BUILD_CORE_MODULE'], extra_objects=[shared_math], depends=['_math.h', shared_math], libraries=['m'])) @@ -933,44 +930,33 @@ class PyBuildExt(build_ext): # libm is needed by delta_new() that uses round() and by accum() that # uses modf(). self.add(Extension('_datetime', ['_datetimemodule.c'], - libraries=['m'], - extra_compile_args=['-DPy_BUILD_CORE_MODULE'])) + libraries=['m'])) # zoneinfo module - self.add(Extension('_zoneinfo', ['_zoneinfo.c'], - extra_compile_args=['-DPy_BUILD_CORE_MODULE'])) + self.add(Extension('_zoneinfo', ['_zoneinfo.c'])) # random number generator implemented in C - self.add(Extension("_random", ["_randommodule.c"], - extra_compile_args=['-DPy_BUILD_CORE_MODULE'])) + self.add(Extension("_random", ["_randommodule.c"])) # bisect self.add(Extension("_bisect", ["_bisectmodule.c"])) # heapq - self.add(Extension("_heapq", ["_heapqmodule.c"], - extra_compile_args=['-DPy_BUILD_CORE_MODULE'])) + self.add(Extension("_heapq", ["_heapqmodule.c"])) # C-optimized pickle replacement - self.add(Extension("_pickle", ["_pickle.c"], - extra_compile_args=['-DPy_BUILD_CORE_MODULE'])) + self.add(Extension("_pickle", ["_pickle.c"])) # _json speedups - self.add(Extension("_json", ["_json.c"], - extra_compile_args=['-DPy_BUILD_CORE_MODULE'])) + self.add(Extension("_json", ["_json.c"])) # profiler (_lsprof is for cProfile.py) - self.add(Extension('_lsprof', ['_lsprof.c', 'rotatingtree.c'], - extra_compile_args=['-DPy_BUILD_CORE_MODULE'])) + self.add(Extension('_lsprof', ['_lsprof.c', 'rotatingtree.c'])) # static Unicode character database self.add(Extension('unicodedata', ['unicodedata.c'], - depends=['unicodedata_db.h', 'unicodename_db.h'], - extra_compile_args=['-DPy_BUILD_CORE_MODULE'])) + depends=['unicodedata_db.h', 'unicodename_db.h'])) # _opcode module self.add(Extension('_opcode', ['_opcode.c'])) # asyncio speedups - self.add(Extension("_asyncio", ["_asynciomodule.c"], - extra_compile_args=['-DPy_BUILD_CORE_MODULE'])) + self.add(Extension("_asyncio", ["_asynciomodule.c"])) # _abc speedups - self.add(Extension("_abc", ["_abc.c"], - extra_compile_args=['-DPy_BUILD_CORE_MODULE'])) + self.add(Extension("_abc", ["_abc.c"])) # _queue module - self.add(Extension("_queue", ["_queuemodule.c"], - extra_compile_args=['-DPy_BUILD_CORE_MODULE'])) + self.add(Extension("_queue", ["_queuemodule.c"])) # _statistics module self.add(Extension("_statistics", ["_statisticsmodule.c"])) # _typing module @@ -1012,8 +998,7 @@ class PyBuildExt(build_ext): self.add(Extension('syslog', ['syslogmodule.c'])) # Python interface to subinterpreter C-API. - self.add(Extension('_xxsubinterpreters', ['_xxsubinterpretersmodule.c'], - extra_compile_args=['-DPy_BUILD_CORE_MODULE'])) + self.add(Extension('_xxsubinterpreters', ['_xxsubinterpretersmodule.c'])) # # Here ends the simple stuff. From here on, modules need certain @@ -1036,8 +1021,7 @@ class PyBuildExt(build_ext): self.add(Extension('_csv', ['_csv.c'])) # POSIX subprocess module helper. - self.add(Extension('_posixsubprocess', ['_posixsubprocess.c'], - extra_compile_args=['-DPy_BUILD_CORE_MODULE'])) + self.add(Extension('_posixsubprocess', ['_posixsubprocess.c'])) def detect_test_extensions(self): # Python C API test module @@ -1045,8 +1029,7 @@ class PyBuildExt(build_ext): depends=['testcapi_long.h'])) # Python Internal C API test module - self.add(Extension('_testinternalcapi', ['_testinternalcapi.c'], - extra_compile_args=['-DPy_BUILD_CORE_MODULE'])) + self.add(Extension('_testinternalcapi', ['_testinternalcapi.c'])) # Python PEP-3118 (buffer protocol) test module self.add(Extension('_testbuffer', ['_testbuffer.c'])) @@ -1055,8 +1038,7 @@ class PyBuildExt(build_ext): self.add(Extension('_testimportmultiple', ['_testimportmultiple.c'])) # Test multi-phase extension module init (PEP 489) - self.add(Extension('_testmultiphase', ['_testmultiphase.c'], - extra_compile_args=['-DPy_BUILD_CORE_MODULE'])) + self.add(Extension('_testmultiphase', ['_testmultiphase.c'])) # Fuzz tests. self.add(Extension('_xxtestfuzz', @@ -1187,7 +1169,6 @@ class PyBuildExt(build_ext): if curses_library.startswith('ncurses'): curses_libs = [curses_library] self.add(Extension('_curses', ['_cursesmodule.c'], - extra_compile_args=['-DPy_BUILD_CORE_MODULE'], include_dirs=curses_includes, define_macros=curses_defines, libraries=curses_libs)) @@ -1202,7 +1183,6 @@ class PyBuildExt(build_ext): curses_libs = ['curses'] self.add(Extension('_curses', ['_cursesmodule.c'], - extra_compile_args=['-DPy_BUILD_CORE_MODULE'], define_macros=curses_defines, libraries=curses_libs)) else: @@ -1722,7 +1702,7 @@ class PyBuildExt(build_ext): # Helper module for various ascii-encoders. Uses zlib for an optimized # crc32 if we have it. Otherwise binascii uses its own. - extra_compile_args = ['-DPy_BUILD_CORE_MODULE'] + extra_compile_args = [] if have_zlib: extra_compile_args.append('-DUSE_ZLIB_CRC32') libraries = ['z'] @@ -2230,7 +2210,7 @@ class PyBuildExt(build_ext): self.use_system_libffi = '--with-system-ffi' in sysconfig.get_config_var("CONFIG_ARGS") include_dirs = [] - extra_compile_args = ['-DPy_BUILD_CORE_MODULE'] + extra_compile_args = [] extra_link_args = [] sources = ['_ctypes/_ctypes.c', '_ctypes/callbacks.c', @@ -2324,7 +2304,7 @@ class PyBuildExt(build_ext): def detect_decimal(self): # Stefan Krah's _decimal module - extra_compile_args = ['-DPy_BUILD_CORE_MODULE'] + extra_compile_args = [] undef_macros = [] if '--with-system-libmpdec' in sysconfig.get_config_var("CONFIG_ARGS"): include_dirs = [] @@ -2482,7 +2462,6 @@ class PyBuildExt(build_ext): library_dirs=openssl_libdirs, libraries=openssl_libs, runtime_library_dirs=runtime_library_dirs, - extra_compile_args=['-DPy_BUILD_CORE_MODULE'], ) # This static linking is NOT OFFICIALLY SUPPORTED. @@ -2545,28 +2524,24 @@ class PyBuildExt(build_ext): self.add(Extension( '_sha256', ['sha256module.c'], depends=['hashlib.h'], - extra_compile_args=['-DPy_BUILD_CORE_MODULE'], )) if "sha512" in configured: self.add(Extension( '_sha512', ['sha512module.c'], depends=['hashlib.h'], - extra_compile_args=['-DPy_BUILD_CORE_MODULE'], )) if "md5" in configured: self.add(Extension( '_md5', ['md5module.c'], depends=['hashlib.h'], - extra_compile_args=['-DPy_BUILD_CORE_MODULE'], )) if "sha1" in configured: self.add(Extension( '_sha1', ['sha1module.c'], depends=['hashlib.h'], - extra_compile_args=['-DPy_BUILD_CORE_MODULE'], )) if "blake2" in configured: @@ -2582,7 +2557,6 @@ class PyBuildExt(build_ext): '_blake2/blake2s_impl.c' ], depends=blake2_deps, - extra_compile_args=['-DPy_BUILD_CORE_MODULE'], )) if "sha3" in configured: @@ -2594,7 +2568,6 @@ class PyBuildExt(build_ext): '_sha3', ['_sha3/sha3module.c'], depends=sha3_deps, - extra_compile_args=['-DPy_BUILD_CORE_MODULE'], )) def detect_nis(self): @@ -2750,8 +2723,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', ['_struct.c'], - extra_compile_args=['-DPy_BUILD_CORE_MODULE'])], + ext_modules=[Extension('_struct', ['_struct.c'])], # If you change the scripts installed here, you also need to # check the PyBuildScripts command above, and change the links |