From 60a485591c48e534f28ebe55c92f18834c4ca819 Mon Sep 17 00:00:00 2001 From: scheibelp Date: Wed, 1 Nov 2017 18:44:31 -0700 Subject: Fix user specs which include already-installed packages (#5939) * when a user-provided spec refers to an already-installed package, packages with patches applied were causing validation errors based on the recorded variants in the package's class * avoid checks on all reserved variants (not just 'patches') --- lib/spack/spack/spec.py | 5 ++++- lib/spack/spack/variant.py | 3 +++ 2 files changed, 7 insertions(+), 1 deletion(-) (limited to 'lib') diff --git a/lib/spack/spack/spec.py b/lib/spack/spack/spec.py index 2d097bc739..0752908a38 100644 --- a/lib/spack/spack/spec.py +++ b/lib/spack/spack/spec.py @@ -2225,7 +2225,10 @@ class Spec(object): if not spec.virtual: pkg_cls = spec.package_class pkg_variants = pkg_cls.variants - not_existing = set(spec.variants) - set(pkg_variants) + # reserved names are variants that may be set on any package + # but are not necessarily recorded by the package's class + not_existing = set(spec.variants) - ( + set(pkg_variants) | set(spack.directives.reserved_names)) if not_existing: raise UnknownVariantError(spec.name, not_existing) diff --git a/lib/spack/spack/variant.py b/lib/spack/spack/variant.py index 4553bf53e4..dc47b5a65f 100644 --- a/lib/spack/spack/variant.py +++ b/lib/spack/spack/variant.py @@ -31,6 +31,7 @@ import inspect import re import llnl.util.lang as lang +import spack import spack.error as error from six import StringIO @@ -592,6 +593,8 @@ def substitute_abstract_variants(spec): spec: spec on which to operate the substitution """ for name, v in spec.variants.items(): + if name in spack.directives.reserved_names: + continue pkg_variant = spec.package_class.variants[name] new_variant = pkg_variant.make_variant(v._original_value) pkg_variant.validate_or_raise(new_variant, spec.package_class) -- cgit v1.2.3-70-g09d2