summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorTodd Gamblin <tgamblin@llnl.gov>2016-03-23 01:32:54 -0700
committerTodd Gamblin <tgamblin@llnl.gov>2016-03-23 01:32:54 -0700
commit38350ae33d29e108803cebdf13b90b6898947328 (patch)
tree4b8cd5e6195bbbb151ba14299a45642a7e377ef0 /lib
parentc4134ee71e43a6a2a38822e25cc72ca73efdcfea (diff)
downloadspack-38350ae33d29e108803cebdf13b90b6898947328.tar.gz
spack-38350ae33d29e108803cebdf13b90b6898947328.tar.bz2
spack-38350ae33d29e108803cebdf13b90b6898947328.tar.xz
spack-38350ae33d29e108803cebdf13b90b6898947328.zip
resurrect preferred=True option for packages lost in merge of externals support.
- Pyton 2.7.11 is preferred again.
Diffstat (limited to 'lib')
-rw-r--r--lib/spack/spack/concretize.py4
-rw-r--r--lib/spack/spack/preferred_packages.py4
-rw-r--r--lib/spack/spack/test/concretize.py9
3 files changed, 14 insertions, 3 deletions
diff --git a/lib/spack/spack/concretize.py b/lib/spack/spack/concretize.py
index 2e576743ec..ed9bf79868 100644
--- a/lib/spack/spack/concretize.py
+++ b/lib/spack/spack/concretize.py
@@ -159,6 +159,10 @@ class DefaultConcretizer(object):
if any(v.satisfies(sv) for sv in spec.versions)],
cmp=cmp_versions)
+ def prefer_key(v):
+ return pkg.versions.get(Version(v)).get('preferred', False)
+ valid_versions.sort(key=prefer_key, reverse=True)
+
if valid_versions:
spec.versions = ver([valid_versions[0]])
else:
diff --git a/lib/spack/spack/preferred_packages.py b/lib/spack/spack/preferred_packages.py
index f0a5382dc9..4d8526c75f 100644
--- a/lib/spack/spack/preferred_packages.py
+++ b/lib/spack/spack/preferred_packages.py
@@ -150,9 +150,7 @@ class PreferredPackages(object):
def version_compare(self, pkgname, a, b):
"""Return less-than-0, 0, or greater than 0 if version a of pkgname is
respecively less-than, equal-to, or greater-than version b of pkgname.
- Versions marked 'preferred=True' in package.py take precedence over any
- versions not marked preferred.
- """
+ One version is less-than another if it is preferred over the other."""
return self._spec_compare(pkgname, 'version', a, b, True, None)
diff --git a/lib/spack/spack/test/concretize.py b/lib/spack/spack/test/concretize.py
index 08cce09674..9cd8c969ae 100644
--- a/lib/spack/spack/test/concretize.py
+++ b/lib/spack/spack/test/concretize.py
@@ -24,6 +24,7 @@
##############################################################################
import spack
from spack.spec import Spec, CompilerSpec
+from spack.version import ver
from spack.concretize import find_spec
from spack.test.mock_packages_test import *
@@ -77,6 +78,14 @@ class ConcretizeTest(MockPackagesTest):
self.check_concretize('mpich')
+ def test_concretize_preferred_version(self):
+ spec = self.check_concretize('python')
+ self.assertEqual(spec.versions, ver('2.7.11'))
+
+ spec = self.check_concretize('python@3.5.1')
+ self.assertEqual(spec.versions, ver('3.5.1'))
+
+
def test_concretize_with_virtual(self):
self.check_concretize('mpileaks ^mpi')
self.check_concretize('mpileaks ^mpi@:1.1')