diff options
author | Massimiliano Culpo <massimiliano.culpo@gmail.com> | 2021-03-27 22:22:11 +0100 |
---|---|---|
committer | Greg Becker <becker33@llnl.gov> | 2021-03-29 16:06:11 -0700 |
commit | 4079bbce97950adfde394a276d710132af23f6e2 (patch) | |
tree | cf197c3d996eb5209ca7e0df84102bc01a9f0cca /lib | |
parent | 4ed5c366fa20ed473973b4e2256344465a701ed3 (diff) | |
download | spack-4079bbce97950adfde394a276d710132af23f6e2.tar.gz spack-4079bbce97950adfde394a276d710132af23f6e2.tar.bz2 spack-4079bbce97950adfde394a276d710132af23f6e2.tar.xz spack-4079bbce97950adfde394a276d710132af23f6e2.zip |
Externals are preferred even when they have non-default variant values
fixes #22596
Variants which are specified in an external spec are not
scored negatively if they encode a non-default value.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/spack/spack/solver/concretize.lp | 19 | ||||
-rw-r--r-- | lib/spack/spack/test/concretize.py | 10 | ||||
-rw-r--r-- | lib/spack/spack/test/data/config/packages.yaml | 5 |
3 files changed, 33 insertions, 1 deletions
diff --git a/lib/spack/spack/solver/concretize.lp b/lib/spack/spack/solver/concretize.lp index 8fdc0acb77..cbde0076fb 100644 --- a/lib/spack/spack/solver/concretize.lp +++ b/lib/spack/spack/solver/concretize.lp @@ -368,23 +368,40 @@ variant_value(Package, Variant, Value) variant(Package, Variant), variant_set(Package, Variant, Value). -% prefer default values. +% The rules below allow us to prefer default values for variants +% whenever possible. If a variant is set in a spec, or if it is +% specified in an external, we score it as if it was a default value. variant_not_default(Package, Variant, Value, 1) :- variant_value(Package, Variant, Value), not variant_default_value(Package, Variant, Value), not variant_set(Package, Variant, Value), + not external_with_variant_set(Package, Variant, Value), node(Package). +% We are using the default value for a variant variant_not_default(Package, Variant, Value, 0) :- variant_value(Package, Variant, Value), variant_default_value(Package, Variant, Value), node(Package). +% The variant is set in the spec variant_not_default(Package, Variant, Value, 0) :- variant_value(Package, Variant, Value), variant_set(Package, Variant, Value), node(Package). +% The variant is set in an external spec +external_with_variant_set(Package, Variant, Value) + :- variant_value(Package, Variant, Value), + condition_requirement(ID, "variant_value", Package, Variant, Value), + possible_external(ID, Package, _), + external(Package), + node(Package). + +variant_not_default(Package, Variant, Value, 0) + :- variant_value(Package, Variant, Value), + external_with_variant_set(Package, Variant, Value), + node(Package). % The default value for a variant in a package is what is written % in the package.py file, unless some preference is set in packages.yaml diff --git a/lib/spack/spack/test/concretize.py b/lib/spack/spack/test/concretize.py index 9070f8bb67..78b7ca9491 100644 --- a/lib/spack/spack/test/concretize.py +++ b/lib/spack/spack/test/concretize.py @@ -1173,3 +1173,13 @@ class TestConcretize(object): s = Spec('mvapich2').concretized() assert set(s.variants['file_systems'].value) == set(['ufs', 'nfs']) + + @pytest.mark.regression('22596') + def test_external_with_non_default_variant_as_dependency(self): + # This package depends on another that is registered as an external + # with 'buildable: true' and a variant with a non-default value set + s = Spec('trigger-external-non-default-variant').concretized() + + assert '~foo' in s['external-non-default-variant'] + assert '~bar' in s['external-non-default-variant'] + assert s['external-non-default-variant'].external diff --git a/lib/spack/spack/test/data/config/packages.yaml b/lib/spack/spack/test/data/config/packages.yaml index 6ad8200837..496c3623cc 100644 --- a/lib/spack/spack/test/data/config/packages.yaml +++ b/lib/spack/spack/test/data/config/packages.yaml @@ -41,3 +41,8 @@ packages: externals: - spec: old-external@1.0.0 prefix: /usr + 'external-non-default-variant': + buildable: True + externals: + - spec: external-non-default-variant@3.8.7~foo~bar + prefix: /usr |