From 67cd92e6a32a1962f1cfde331a509ea968ac246e Mon Sep 17 00:00:00 2001 From: Greg Becker Date: Wed, 3 Nov 2021 00:11:31 -0700 Subject: 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. --- .../packages/conditional-variant-pkg/package.py | 24 ++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 var/spack/repos/builtin.mock/packages/conditional-variant-pkg/package.py (limited to 'var') 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 -- cgit v1.2.3-70-g09d2