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
pull/9458/head
Thomas Heijligen 3 years ago committed by Xavier Claessens
parent 67e841720c
commit ecdf192f46
  1. 4
      mesonbuild/dependencies/base.py
  2. 2
      mesonbuild/dependencies/detect.py
  3. 2
      mesonbuild/interpreter/dependencyfallbacks.py
  4. 3
      mesonbuild/modules/python.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,

@ -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,

@ -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:

@ -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:

Loading…
Cancel
Save