summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVanessasaurus <814322+vsoch@users.noreply.github.com>2021-03-14 13:00:15 -0600
committerGitHub <noreply@github.com>2021-03-14 19:00:15 +0000
commit6ff717f39583a56be427bb04bf53bf304d74c534 (patch)
tree65e3a38011d869f77af9bde6120ea4ca9cbfce1b
parentd22bad13b114e08ed611ede29b2f06eb4311c827 (diff)
downloadspack-6ff717f39583a56be427bb04bf53bf304d74c534.tar.gz
spack-6ff717f39583a56be427bb04bf53bf304d74c534.tar.bz2
spack-6ff717f39583a56be427bb04bf53bf304d74c534.tar.xz
spack-6ff717f39583a56be427bb04bf53bf304d74c534.zip
do not validate variants of concrete specs in solver setup (#22272)
Currently, regardless of a spec being concrete or not, we validate its variants in `spec_clauses` (part of `SpackSolverSetup`). This PR skips the check if the spec is concrete. The reason we want to do this is so that the solver setup class (really, `spec_clauses`) can be used for cases when we just want the logic statements / facts (is that what they are called?) and we don't need to re-validate an already concrete spec. We can't change existing concrete specs, and we have to be able to handle them *even if they violate constraints in the current spack*. This happens in practice if we are doing the validation for a spec produced by a different spack install. Signed-off-by: vsoch <vsoch@users.noreply.github.com>
-rw-r--r--lib/spack/spack/solver/asp.py21
1 files changed, 11 insertions, 10 deletions
diff --git a/lib/spack/spack/solver/asp.py b/lib/spack/spack/solver/asp.py
index 975dbfcc91..01536f267f 100644
--- a/lib/spack/spack/solver/asp.py
+++ b/lib/spack/spack/solver/asp.py
@@ -966,16 +966,17 @@ class SpackSolverSetup(object):
if value == '*':
continue
- # validate variant value
- reserved_names = spack.directives.reserved_names
- if not spec.virtual and vname not in reserved_names:
- try:
- variant_def = spec.package.variants[vname]
- except KeyError:
- msg = 'variant "{0}" not found in package "{1}"'
- raise RuntimeError(msg.format(vname, spec.name))
- else:
- variant_def.validate_or_raise(variant, spec.package)
+ # validate variant value only if spec not concrete
+ if not spec.concrete:
+ reserved_names = spack.directives.reserved_names
+ if not spec.virtual and vname not in reserved_names:
+ try:
+ variant_def = spec.package.variants[vname]
+ except KeyError:
+ msg = 'variant "{0}" not found in package "{1}"'
+ raise RuntimeError(msg.format(vname, spec.name))
+ else:
+ variant_def.validate_or_raise(variant, spec.package)
clauses.append(f.variant_value(spec.name, vname, value))