From 6ff717f39583a56be427bb04bf53bf304d74c534 Mon Sep 17 00:00:00 2001 From: Vanessasaurus <814322+vsoch@users.noreply.github.com> Date: Sun, 14 Mar 2021 13:00:15 -0600 Subject: 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 --- lib/spack/spack/solver/asp.py | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) (limited to 'lib') 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)) -- cgit v1.2.3-60-g2f50