--- setuptools-68.0.0/setuptools/command/build_ext.py.orig 2023-06-19 17:52:37.000000000 +0200 +++ setuptools-68.0.0/setuptools/command/build_ext.py 2023-08-21 18:39:55.475275100 +0200 @@ -340,6 +340,18 @@ if os.path.exists(stub_file) and not self.dry_run: os.unlink(stub_file) + def get_libraries(self, ext): + libraries = _build_ext.get_libraries(self, ext) + if getattr(ext, 'py_limited_api') and self.plat_name.startswith('mingw'): + # XXX Since gcc/clang don't support linking specific libraries via + # pragma like CPython does with MSVC (see PC/pyconfig.h in cpython), + # and because py_limited_api is a setuptools feature and not a + # distutils one, this is the only place where we can check and force + # it to link against python3 instead of python3.x + versioned = 'python' + get_config_var('LDVERSION') + return ['python3' if l == versioned else l for l in libraries] + return libraries + if use_stubs or os.name == 'nt': # Build shared libraries