diff options
author | 2021-01-19 23:04:49 +0100 | |
---|---|---|
committer | 2021-01-19 23:04:49 +0100 | |
commit | cad8020cb83ec6d904f874c0e4f599e651022196 (patch) | |
tree | 7db4f105af783ecd5ac60488b081d945bcea14b3 /setup.py | |
parent | bpo-41713: Remove PyOS_InitInterrupts() from python3dll.c (GH-24257) (diff) | |
download | cpython-cad8020cb83ec6d904f874c0e4f599e651022196.tar.gz cpython-cad8020cb83ec6d904f874c0e4f599e651022196.tar.bz2 cpython-cad8020cb83ec6d904f874c0e4f599e651022196.zip |
bpo-42955: Add Python/module_names.h (GH-24258)
Add a private list of all stdlib modules: _Py_module_names.
* Add Tools/scripts/generate_module_names.py script.
* Makefile: Add "make regen-module-names" command.
* setup.py: Add --list-module-names option.
* GitHub Action and Travis CI also runs "make regen-module-names",
not ony "make regen-all", to ensure that the module names remains
up to date.
Diffstat (limited to 'setup.py')
-rw-r--r-- | setup.py | 51 |
1 files changed, 35 insertions, 16 deletions
@@ -46,6 +46,9 @@ TEST_EXTENSIONS = (sysconfig.get_config_var('TEST_MODULES') == 'yes') # This global variable is used to hold the list of modules to be disabled. DISABLED_MODULE_LIST = [] +# --list-module-names option used by Tools/scripts/generate_module_names.py +LIST_MODULE_NAMES = False + def get_platform(): # Cross compiling @@ -447,12 +450,20 @@ class PyBuildExt(build_ext): # Detect which modules should be compiled self.detect_modules() - self.remove_disabled() + if not LIST_MODULE_NAMES: + self.remove_disabled() self.update_sources_depends() mods_built, mods_disabled = self.remove_configured_extensions() self.set_compiler_executables() + if LIST_MODULE_NAMES: + for ext in self.extensions: + print(ext.name) + for name in self.missing: + print(name) + return + build_ext.build_extensions(self) if SUBPROCESS_BOOTSTRAP: @@ -1118,6 +1129,7 @@ class PyBuildExt(build_ext): # bpo-31904: crypt() function is not provided by VxWorks. # DES_crypt() OpenSSL provides is too weak to implement # the encryption. + self.missing.append('_crypt') return if self.compiler.find_library_file(self.lib_dirs, 'crypt'): @@ -1125,8 +1137,7 @@ class PyBuildExt(build_ext): else: libs = [] - self.add(Extension('_crypt', ['_cryptmodule.c'], - libraries=libs)) + self.add(Extension('_crypt', ['_cryptmodule.c'], libraries=libs)) def detect_socket(self): # socket(2) @@ -1735,27 +1746,29 @@ class PyBuildExt(build_ext): if MS_WINDOWS: multiprocessing_srcs = ['_multiprocessing/multiprocessing.c', '_multiprocessing/semaphore.c'] - else: multiprocessing_srcs = ['_multiprocessing/multiprocessing.c'] 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('HAVE_SHM_OPEN') and - sysconfig.get_config_var('HAVE_SHM_UNLINK')): - posixshmem_srcs = ['_multiprocessing/posixshmem.c'] - libs = [] - if sysconfig.get_config_var('SHM_NEEDS_LIBRT'): - # need to link with librt to get shm_open() - libs.append('rt') - self.add(Extension('_posixshmem', posixshmem_srcs, - define_macros={}, - libraries=libs, - include_dirs=["Modules/_multiprocessing"])) - self.add(Extension('_multiprocessing', multiprocessing_srcs, include_dirs=["Modules/_multiprocessing"])) + if (not MS_WINDOWS and + sysconfig.get_config_var('HAVE_SHM_OPEN') and + sysconfig.get_config_var('HAVE_SHM_UNLINK')): + posixshmem_srcs = ['_multiprocessing/posixshmem.c'] + libs = [] + if sysconfig.get_config_var('SHM_NEEDS_LIBRT'): + # need to link with librt to get shm_open() + libs.append('rt') + self.add(Extension('_posixshmem', posixshmem_srcs, + define_macros={}, + libraries=libs, + include_dirs=["Modules/_multiprocessing"])) + else: + self.missing.append('_posixshmem') + def detect_uuid(self): # Build the _uuid module if possible uuid_incs = find_file("uuid.h", self.inc_dirs, ["/usr/include/uuid"]) @@ -2549,6 +2562,12 @@ class PyBuildScripts(build_scripts): def main(): + global LIST_MODULE_NAMES + + if "--list-module-names" in sys.argv: + LIST_MODULE_NAMES = True + sys.argv.remove("--list-module-names") + set_compiler_flags('CFLAGS', 'PY_CFLAGS_NODIST') set_compiler_flags('LDFLAGS', 'PY_LDFLAGS_NODIST') |