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.
This commit is contained in:
Massimiliano Culpo 2021-08-25 19:56:16 +02:00 committed by GitHub
parent e2e7b0788f
commit af2f07852c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1602,7 +1602,22 @@ def matching_spec(self, spec):
# 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):