summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Kuhn <suraia@ikkoku.de>2016-12-30 23:11:39 +0100
committerTodd Gamblin <tgamblin@llnl.gov>2016-12-30 14:11:39 -0800
commita42f340d375cbc781e7a113f3b3afa2e4e3124ed (patch)
treecc37dd629c177785f8383c68fa1458819af6520c
parentd52c44cba9c5a56c38340157bfa8382a54e17ca5 (diff)
downloadspack-a42f340d375cbc781e7a113f3b3afa2e4e3124ed.tar.gz
spack-a42f340d375cbc781e7a113f3b3afa2e4e3124ed.tar.bz2
spack-a42f340d375cbc781e7a113f3b3afa2e4e3124ed.tar.xz
spack-a42f340d375cbc781e7a113f3b3afa2e4e3124ed.zip
Allow setting default variants (#2644)
-rw-r--r--lib/spack/spack/preferred_packages.py11
1 files changed, 9 insertions, 2 deletions
diff --git a/lib/spack/spack/preferred_packages.py b/lib/spack/spack/preferred_packages.py
index 08f9c3cfa8..dc6cb3e921 100644
--- a/lib/spack/spack/preferred_packages.py
+++ b/lib/spack/spack/preferred_packages.py
@@ -154,10 +154,17 @@ class PreferredPackages(object):
def spec_preferred_variants(self, pkgname):
"""Return a VariantMap of preferred variants and their values"""
- variants = self.preferred.get(pkgname, {}).get('variants', '')
+ for pkg in (pkgname, 'all'):
+ variants = self.preferred.get(pkg, {}).get('variants', '')
+ if variants:
+ break
if not isinstance(variants, basestring):
variants = " ".join(variants)
- return spack.spec.Spec("%s %s" % (pkgname, variants)).variants
+ pkg = spack.repo.get(pkgname)
+ spec = spack.spec.Spec("%s %s" % (pkgname, variants))
+ # Only return variants that are actually supported by the package
+ return dict((name, variant) for name, variant in spec.variants.items()
+ if name in pkg.variants)
def version_compare(self, pkgname, a, b):
"""Return less-than-0, 0, or greater than 0 if version a of pkgname is