summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorMassimiliano Culpo <massimiliano.culpo@gmail.com>2021-08-25 19:56:16 +0200
committerGitHub <noreply@github.com>2021-08-25 10:56:16 -0700
commitaf2f07852cd490d10cf6fc0a67f4e6d83e699006 (patch)
treedfa3cb8b2a1c4ee1a2e63b37202627ff703092a8 /lib
parente2e7b0788fa7ae6749e846166d08b871db7340c7 (diff)
downloadspack-af2f07852cd490d10cf6fc0a67f4e6d83e699006.tar.gz
spack-af2f07852cd490d10cf6fc0a67f4e6d83e699006.tar.bz2
spack-af2f07852cd490d10cf6fc0a67f4e6d83e699006.tar.xz
spack-af2f07852cd490d10cf6fc0a67f4e6d83e699006.zip
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.
Diffstat (limited to 'lib')
-rw-r--r--lib/spack/spack/environment.py15
1 files changed, 15 insertions, 0 deletions
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):