summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Heijligen <src@posteo.de>2021-10-15 11:24:02 +0200
committerXavier Claessens <xclaesse@gmail.com>2021-10-26 09:36:22 -0400
commitecdf192f4642ac777fa2948b3fe8f236a3f4553c (patch)
treeb9e7351e000c39125dc20fcbbcc6820e0380cfc1
parent67e841720c2f8e05ac6c617566c1272a53b47510 (diff)
downloadmeson-ecdf192f4642ac777fa2948b3fe8f236a3f4553c.tar.gz
dep.name(): return dependency name even if dependency is not found
The dep.name() function schould always return the name of the dependency as documented. No matter if it was found or not. https://mesonbuild.com/Reference-manual_returned_dep.html#depfound
-rw-r--r--mesonbuild/dependencies/base.py4
-rw-r--r--mesonbuild/dependencies/detect.py2
-rw-r--r--mesonbuild/interpreter/dependencyfallbacks.py2
-rw-r--r--mesonbuild/modules/python.py3
4 files changed, 5 insertions, 6 deletions
diff --git a/mesonbuild/dependencies/base.py b/mesonbuild/dependencies/base.py
index 02ef30cb3..6881a34af 100644
--- a/mesonbuild/dependencies/base.py
+++ b/mesonbuild/dependencies/base.py
@@ -394,10 +394,10 @@ class ExternalDependency(Dependency, HasNativeKwarg):
class NotFoundDependency(Dependency):
- def __init__(self, environment: 'Environment') -> None:
+ def __init__(self, name: str, environment: 'Environment') -> None:
super().__init__(DependencyTypeName('not-found'), {})
self.env = environment
- self.name = 'not-found'
+ self.name = name
self.is_found = False
def get_partial_dependency(self, *, compile_args: bool = False,
diff --git a/mesonbuild/dependencies/detect.py b/mesonbuild/dependencies/detect.py
index dbb43ab7a..e47c33891 100644
--- a/mesonbuild/dependencies/detect.py
+++ b/mesonbuild/dependencies/detect.py
@@ -162,7 +162,7 @@ def find_external_dependency(name: str, env: 'Environment', kwargs: T.Dict[str,
raise DependencyException('Dependency "%s" not found' % (name) +
(', tried %s' % (tried) if tried else ''))
- return NotFoundDependency(env)
+ return NotFoundDependency(name, env)
def _build_external_dependency_list(name: str, env: 'Environment', for_machine: MachineChoice,
diff --git a/mesonbuild/interpreter/dependencyfallbacks.py b/mesonbuild/interpreter/dependencyfallbacks.py
index 7d3a7d8c9..417c8cd9d 100644
--- a/mesonbuild/interpreter/dependencyfallbacks.py
+++ b/mesonbuild/interpreter/dependencyfallbacks.py
@@ -270,7 +270,7 @@ class DependencyFallbacksHolder(MesonInterpreterObject):
FeatureNew.single_use('OpenMP Dependency', '0.46.0', self.subproject)
def _notfound_dependency(self) -> NotFoundDependency:
- return NotFoundDependency(self.environment)
+ return NotFoundDependency(self.names[0] if self.names else '', self.environment)
@staticmethod
def _check_version(wanted: T.Optional[str], found: str) -> bool:
diff --git a/mesonbuild/modules/python.py b/mesonbuild/modules/python.py
index f479ab97c..fc28b9a3b 100644
--- a/mesonbuild/modules/python.py
+++ b/mesonbuild/modules/python.py
@@ -494,10 +494,9 @@ class PythonInstallation(ExternalProgramHolder):
@noPosargs
def dependency_method(self, args: T.List['TYPE_var'], kwargs: 'TYPE_kwargs') -> 'Dependency':
disabled, required, feature = extract_required_kwarg(kwargs, self.subproject)
-
# it's theoretically (though not practically) possible for the else clse
# to not bind dep, let's ensure it is.
- dep: 'Dependency' = NotFoundDependency(self.interpreter.environment)
+ dep: 'Dependency' = NotFoundDependency('python', self.interpreter.environment)
if disabled:
mlog.log('Dependency', mlog.bold('python'), 'skipped: feature', mlog.bold(feature), 'disabled')
else: