diff options
author | Greg Becker <becker33@llnl.gov> | 2021-11-03 00:11:31 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-11-03 08:11:31 +0100 |
commit | 67cd92e6a32a1962f1cfde331a509ea968ac246e (patch) | |
tree | 2a946505d7d0169a36f80b10391f05fba279f78f /var | |
parent | 78c08fccd56d073a336eeee3dd4548d81101c920 (diff) | |
download | spack-67cd92e6a32a1962f1cfde331a509ea968ac246e.tar.gz spack-67cd92e6a32a1962f1cfde331a509ea968ac246e.tar.bz2 spack-67cd92e6a32a1962f1cfde331a509ea968ac246e.tar.xz spack-67cd92e6a32a1962f1cfde331a509ea968ac246e.zip |
Allow conditional variants (#24858)
A common question from users has been how to model variants
that are new in new versions of a package, or variants that are
dependent on other variants. Our stock answer so far has been
an unsatisfying combination of "just have it do nothing in the old
version" and "tell Spack it conflicts".
This PR enables conditional variants, on any spec condition. The
syntax is straightforward, and matches that of previous features.
Diffstat (limited to 'var')
-rw-r--r-- | var/spack/repos/builtin.mock/packages/conditional-variant-pkg/package.py | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/var/spack/repos/builtin.mock/packages/conditional-variant-pkg/package.py b/var/spack/repos/builtin.mock/packages/conditional-variant-pkg/package.py new file mode 100644 index 0000000000..1b7a2c3afe --- /dev/null +++ b/var/spack/repos/builtin.mock/packages/conditional-variant-pkg/package.py @@ -0,0 +1,24 @@ +# Copyright 2013-2021 Lawrence Livermore National Security, LLC and other +# Spack Project Developers. See the top-level COPYRIGHT file for details. +# +# SPDX-License-Identifier: (Apache-2.0 OR MIT) + +class ConditionalVariantPkg(Package): + """This package is used to test conditional variants.""" + homepage = "http://www.example.com/conditional-variant-pkg" + url = "http://www.unit-test-should-replace-this-url/conditional-variant-1.0.tar.gz" + + version('1.0', '0123456789abcdef0123456789abcdef') + version('2.0', 'abcdef0123456789abcdef0123456789') + + variant('version_based', default=True, when='@2.0:', + description="Check that version constraints work") + + variant('variant_based', default=False, when='+version_based', + description="Check that variants can depend on variants") + + variant('two_whens', default=False, when='@1.0') + variant('two_whens', default=False, when='+variant_based') + + def install(self, spec, prefix): + assert False |