From af2f07852cd490d10cf6fc0a67f4e6d83e699006 Mon Sep 17 00:00:00 2001 From: Massimiliano Culpo Date: Wed, 25 Aug 2021 19:56:16 +0200 Subject: environment: match concrete specs only if they have the same build hash (#25575) see #25563 When we have a concrete environment and we ask to install a concrete spec from a file, currently Spack returns a list of specs that are all the one that match the argument DAG hash. Instead we want to compare build hashes, which also account for build-only dependencies. --- lib/spack/spack/environment.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'lib') diff --git a/lib/spack/spack/environment.py b/lib/spack/spack/environment.py index dbe7318517..23644dabd9 100644 --- a/lib/spack/spack/environment.py +++ b/lib/spack/spack/environment.py @@ -1602,7 +1602,22 @@ class Environment(object): # Dependency-only specs will have value None matches = {} + if not isinstance(spec, spack.spec.Spec): + spec = spack.spec.Spec(spec) + for user_spec, concretized_user_spec in self.concretized_specs(): + # Deal with concrete specs differently + if spec.concrete: + # Matching a concrete spec is more restrictive + # than just matching the dag hash + is_match = ( + spec in concretized_user_spec and + concretized_user_spec[spec.name].build_hash() == spec.build_hash() + ) + if is_match: + matches[spec] = spec + continue + if concretized_user_spec.satisfies(spec): matches[concretized_user_spec] = user_spec for dep_spec in concretized_user_spec.traverse(root=False): -- cgit v1.2.3-70-g09d2