diff --git a/lib/spack/spack/modules/lmod.py b/lib/spack/spack/modules/lmod.py index 76fcc05eeab..f869ab9f0b8 100644 --- a/lib/spack/spack/modules/lmod.py +++ b/lib/spack/spack/modules/lmod.py @@ -97,14 +97,16 @@ class LmodConfiguration(BaseConfiguration): default_projections = {"all": "{name}/{version}"} + compiler: Optional[spack.spec.Spec] + def __init__(self, spec: spack.spec.Spec, module_set_name: str, explicit: bool) -> None: super().__init__(spec, module_set_name, explicit) # FIXME (compiler as nodes): make this a bit more robust candidates = collections.defaultdict(list) for node in spec.traverse(deptype=("link", "run")): - candidates["c"].extend(node.dependencies(virtuals="c")) - candidates["cxx"].extend(node.dependencies(virtuals="c")) + candidates["c"].extend(node.dependencies(virtuals=("c",))) + candidates["cxx"].extend(node.dependencies(virtuals=("c",))) # FIXME (compiler as nodes): decide what to do when we have more than one C compiler if candidates["c"] and len(set(candidates["c"])) == 1: @@ -224,7 +226,7 @@ def provides(self): # All the other tokens in the hierarchy must be virtual dependencies for x in self.hierarchy_tokens: if self.spec.package.provides(x): - provides[x] = self.spec[x] + provides[x] = self.spec return provides @property diff --git a/lib/spack/spack/spec.py b/lib/spack/spack/spec.py index 185a555c36e..3f3087c1b48 100644 --- a/lib/spack/spack/spec.py +++ b/lib/spack/spack/spec.py @@ -3776,16 +3776,10 @@ def __getitem__(self, name: str): self.edges_to_dependencies(depflag=dt.BUILD | dt.TEST), ) - # Consider runtime dependencies and direct build/test deps before transitive dependencies, - # and prefer matches closest to the root. + # Consider runtime dependencies and direct build/test deps only try: child: Spec = next( - e.spec - for e in itertools.chain( - (e for e in order() if e.spec.name == name or name in e.virtuals), - # for historical reasons - (e for e in order() if e.spec.concrete and e.spec.package.provides(name)), - ) + e.spec for e in order() if e.spec.name == name or name in e.virtuals ) except StopIteration: raise KeyError(f"No spec with name {name} in {self}")