diff options
| author | Jussi Pakkanen <jpakkane@gmail.com> | 2024-06-12 00:23:14 +0300 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-06-12 00:23:14 +0300 |
| commit | 0352c900bc33ae2796d1e0881986f2163b7e256d (patch) | |
| tree | 4025059959d0eafe947a61ee3a0d0d1fe269bc3c /mesonbuild/modules/python.py | |
| parent | 1d4c0311119fc23d1c40435626030c5c98af7b26 (diff) | |
| parent | 328011f77a1cef00655a697cd2e503a97754b745 (diff) | |
| download | meson-0352c900bc33ae2796d1e0881986f2163b7e256d.tar.gz | |
Merge pull request #13171 from amcn/mingw-python-limited-api
Python: Fix limited API under mingw
Diffstat (limited to 'mesonbuild/modules/python.py')
| -rw-r--r-- | mesonbuild/modules/python.py | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/mesonbuild/modules/python.py b/mesonbuild/modules/python.py index d195a3fa5..e84bee187 100644 --- a/mesonbuild/modules/python.py +++ b/mesonbuild/modules/python.py @@ -184,13 +184,9 @@ class PythonInstallation(_ExternalProgramHolder['PythonExternalProgram']): new_cpp_args.append(limited_api_definition) kwargs['cpp_args'] = new_cpp_args - # When compiled under MSVC, Python's PC/pyconfig.h forcibly inserts pythonMAJOR.MINOR.lib - # into the linker path when not running in debug mode via a series #pragma comment(lib, "") - # directives. We manually override these here as this interferes with the intended - # use of the 'limited_api' kwarg + # On Windows, the limited API DLL is python3.dll, not python3X.dll. for_machine = kwargs['native'] - compilers = self.interpreter.environment.coredata.compilers[for_machine] - if any(compiler.get_id() == 'msvc' for compiler in compilers.values()): + if self.interpreter.environment.machines[for_machine].is_windows(): pydep_copy = copy.copy(pydep) pydep_copy.find_libpy_windows(self.env, limited_api=True) if not pydep_copy.found(): @@ -199,6 +195,12 @@ class PythonInstallation(_ExternalProgramHolder['PythonExternalProgram']): new_deps.remove(pydep) new_deps.append(pydep_copy) + # When compiled under MSVC, Python's PC/pyconfig.h forcibly inserts pythonMAJOR.MINOR.lib + # into the linker path when not running in debug mode via a series #pragma comment(lib, "") + # directives. We manually override these here as this interferes with the intended + # use of the 'limited_api' kwarg + compilers = self.interpreter.environment.coredata.compilers[for_machine] + if any(compiler.get_id() == 'msvc' for compiler in compilers.values()): pyver = pydep.version.replace('.', '') python_windows_debug_link_exception = f'/NODEFAULTLIB:python{pyver}_d.lib' python_windows_release_link_exception = f'/NODEFAULTLIB:python{pyver}.lib' |
