aboutsummaryrefslogtreecommitdiff
path: root/mesonbuild/modules/python.py
diff options
context:
space:
mode:
authorEli Schwartz <eschwartz@archlinux.org>2022-11-23 15:46:51 -0500
committerEli Schwartz <eschwartz@archlinux.org>2022-11-24 11:50:20 -0500
commitbf832743441a1171518d7a436164c989be679410 (patch)
tree3b429c7a9bff5ea983ab0f48b58a5d3663d8bfbe /mesonbuild/modules/python.py
parentc05b2ba231bae7c4f1671980ca0faa7d2018dce8 (diff)
downloadmeson-bf832743441a1171518d7a436164c989be679410.zip
meson-bf832743441a1171518d7a436164c989be679410.tar.gz
meson-bf832743441a1171518d7a436164c989be679410.tar.bz2
python module: fix broken non-embed dependency
The `py.dependency(embed: false)` method is supposed to consistently provide a distutils-like `python.pc` / `python-embed.pc` interface regardless of Python version. It handles both pkg-config and sysconfig scraping. For the latter, we respect the value of self.link_libpython as determined by distutils, and construct a fully custom dependency. For the former, we blindly assume pkg-config is correct. It isn't correct, not until Python 3.8 when embed was added. Before then, we need to process the pkg-config dependency based on link_libpython. We did this, but only inside the extension_module method, which is obviously wrong. Delete the special casing from extension_module, and handle it inside the dependency. Fixes #11097
Diffstat (limited to 'mesonbuild/modules/python.py')
-rw-r--r--mesonbuild/modules/python.py24
1 files changed, 13 insertions, 11 deletions
diff --git a/mesonbuild/modules/python.py b/mesonbuild/modules/python.py
index 98808c4..71a25d5 100644
--- a/mesonbuild/modules/python.py
+++ b/mesonbuild/modules/python.py
@@ -121,6 +121,17 @@ class PythonPkgConfigDependency(PkgConfigDependency, _PythonDependencyBase):
if libpc and not self.is_found:
mlog.debug(f'"python-{self.version}" could not be found in LIBPC, this is likely due to a relocated python installation')
+ # The "-embed" version of python.pc was introduced in 3.8, and distutils
+ # extension linking was changed to be considered a non embed usage. Before
+ # then, this dependency always uses the embed=True file because that is the
+ # only one that exists,
+ #
+ # On macOS and some Linux distros (Debian) distutils doesn't link extensions
+ # against libpython, even on 3.7 and below. We call into distutils and
+ # mirror its behavior. See https://github.com/mesonbuild/meson/issues/4117
+ if not self.embed and not self.link_libpython and mesonlib.version_compare(self.version, '< 3.8'):
+ self.link_args = []
+
class PythonFrameworkDependency(ExtraFrameworkDependency, _PythonDependencyBase):
@@ -529,17 +540,8 @@ class PythonInstallation(ExternalProgramHolder):
kwargs['install_dir'] = self._get_install_dir_impl(False, subdir)
- new_deps = []
- has_pydep = False
- for dep in mesonlib.extract_as_list(kwargs, 'dependencies'):
- if isinstance(dep, _PythonDependencyBase):
- has_pydep = True
- # On macOS and some Linux distros (Debian) distutils doesn't link
- # extensions against libpython. We call into distutils and mirror its
- # behavior. See https://github.com/mesonbuild/meson/issues/4117
- if not self.link_libpython:
- dep = dep.get_partial_dependency(compile_args=True)
- new_deps.append(dep)
+ new_deps = mesonlib.extract_as_list(kwargs, 'dependencies')
+ has_pydep = any(isinstance(dep, _PythonDependencyBase) for dep in new_deps)
if not has_pydep:
pydep = self._dependency_method_impl({})
if not pydep.found():