From ecdf192f4642ac777fa2948b3fe8f236a3f4553c Mon Sep 17 00:00:00 2001 From: Thomas Heijligen Date: Fri, 15 Oct 2021 11:24:02 +0200 Subject: 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 --- mesonbuild/dependencies/base.py | 4 ++-- mesonbuild/dependencies/detect.py | 2 +- mesonbuild/interpreter/dependencyfallbacks.py | 2 +- mesonbuild/modules/python.py | 3 +-- 4 files changed, 5 insertions(+), 6 deletions(-) diff --git a/mesonbuild/dependencies/base.py b/mesonbuild/dependencies/base.py index 02ef30c..6881a34 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 dbb43ab..e47c338 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 7d3a7d8..417c8cd 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 f479ab9..fc28b9a 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: -- cgit v1.1