aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew McNulty <amcn102@gmail.com>2024-05-08 18:40:58 +0200
committerAndrew McNulty <amcn102@gmail.com>2024-06-11 19:47:31 +0200
commitfea7f94b6796e4ad296989c040d45ae3b4c3f444 (patch)
tree36e44089112daf85946be28877ced0dce748100a
parentf66a527a7c4280c1652f2921912d149aeeca971d (diff)
downloadmeson-fea7f94b6796e4ad296989c040d45ae3b4c3f444.zip
meson-fea7f94b6796e4ad296989c040d45ae3b4c3f444.tar.gz
meson-fea7f94b6796e4ad296989c040d45ae3b4c3f444.tar.bz2
Python: fix limited API logic under mingw
The Python Limited API support that was added in 1.2 had special handling of Windows, but the condition to check for Windows was not correct: it checked for MSVC and not for the target's OS. This causes mingw installations to not have the special handling applied. This commit fixes this to check explicitly for Windows.
-rw-r--r--mesonbuild/modules/python.py14
1 files changed, 8 insertions, 6 deletions
diff --git a/mesonbuild/modules/python.py b/mesonbuild/modules/python.py
index d195a3f..e84bee1 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'