aboutsummaryrefslogtreecommitdiff
path: root/mesonbuild/modules
diff options
context:
space:
mode:
authorEli Schwartz <eschwartz@archlinux.org>2022-06-19 00:51:54 -0400
committerJussi Pakkanen <jpakkane@gmail.com>2022-06-19 21:44:17 +0300
commit22dcb692adefea7d51e480e36a53446cc0777c01 (patch)
tree5282233fbdc4c870027469cdcee28dd6feac26c8 /mesonbuild/modules
parent43c60318fd28d23772cbc7a2b2e3152f6ec59e68 (diff)
downloadmeson-22dcb692adefea7d51e480e36a53446cc0777c01.zip
meson-22dcb692adefea7d51e480e36a53446cc0777c01.tar.gz
meson-22dcb692adefea7d51e480e36a53446cc0777c01.tar.bz2
python module: implicitly add python dep to extensions
If there isn't a preexisting dependency on python, append one. It's almost assuredly needed, so just do the right thing out of the box.
Diffstat (limited to 'mesonbuild/modules')
-rw-r--r--mesonbuild/modules/python.py28
1 files changed, 19 insertions, 9 deletions
diff --git a/mesonbuild/modules/python.py b/mesonbuild/modules/python.py
index e5509d9..47dc674 100644
--- a/mesonbuild/modules/python.py
+++ b/mesonbuild/modules/python.py
@@ -516,16 +516,26 @@ class PythonInstallation(ExternalProgramHolder):
kwargs['install_dir'] = os.path.join(self.platlib_install_path, subdir)
- # 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:
- new_deps = []
- for dep in mesonlib.extract_as_list(kwargs, 'dependencies'):
- if isinstance(dep, _PythonDependencyBase):
+ 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)
- kwargs['dependencies'] = new_deps
+ new_deps.append(dep)
+ if not has_pydep:
+ pydep = self._dependency_method_impl({})
+ if not pydep.found():
+ raise mesonlib.MesonException('Python dependency not found')
+ new_deps.append(pydep)
+ FeatureNew.single_use('python_installation.extension_module with implicit dependency on python',
+ '0.63.0', self.subproject, 'use python_installation.dependency()',
+ self.current_node)
+ kwargs['dependencies'] = new_deps
# msys2's python3 has "-cpython-36m.dll", we have to be clever
# FIXME: explain what the specific cleverness is here