bpo-45548: Some test modules must be built as shared libs (GH-29268)

Some test cases don't work when test modules are static extensions.

Add dependency on Modules/config.c to trigger a rebuild whenever a
module build type is changed.

``makesetup`` puts shared extensions into ``Modules/`` directory. Create
symlinks from pybuilddir so the extensions can be imported.

Note: It is not possible to use the content of pybuilddir.txt as a build
target. Makefile evaluates target variables in the first pass. The
pybuilddir.txt file does not exist at that point.
This commit is contained in:
Christian Heimes 2021-10-29 18:49:57 +03:00 committed by GitHub
parent d9575218d7
commit f0150ac94a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 41 additions and 13 deletions

View file

@ -426,12 +426,13 @@ class PyBuildExt(build_ext):
# re-compile extensions if a header file has been changed
ext.depends.extend(headers)
def remove_configured_extensions(self):
def handle_configured_extensions(self):
# The sysconfig variables built by makesetup that list the already
# built modules and the disabled modules as configured by the Setup
# files.
sysconf_built = sysconfig.get_config_var('MODBUILT_NAMES').split()
sysconf_dis = sysconfig.get_config_var('MODDISABLED_NAMES').split()
sysconf_built = set(sysconfig.get_config_var('MODBUILT_NAMES').split())
sysconf_shared = set(sysconfig.get_config_var('MODSHARED_NAMES').split())
sysconf_dis = set(sysconfig.get_config_var('MODDISABLED_NAMES').split())
mods_built = []
mods_disabled = []
@ -449,11 +450,15 @@ class PyBuildExt(build_ext):
mods_configured]
# Remove the shared libraries built by a previous build.
for ext in mods_configured:
# Don't remove shared extensions which have been built
# by Modules/Setup
if ext.name in sysconf_shared:
continue
fullpath = self.get_ext_fullpath(ext.name)
if os.path.exists(fullpath):
if os.path.lexists(fullpath):
os.unlink(fullpath)
return (mods_built, mods_disabled)
return mods_built, mods_disabled
def set_compiler_executables(self):
# When you run "make CC=altcc" or something similar, you really want
@ -478,7 +483,7 @@ class PyBuildExt(build_ext):
self.remove_disabled()
self.update_sources_depends()
mods_built, mods_disabled = self.remove_configured_extensions()
mods_built, mods_disabled = self.handle_configured_extensions()
self.set_compiler_executables()
if LIST_MODULE_NAMES: