diff options
author | Todd Gamblin <tgamblin@llnl.gov> | 2015-12-21 15:35:47 -0800 |
---|---|---|
committer | Todd Gamblin <tgamblin@llnl.gov> | 2015-12-21 15:35:47 -0800 |
commit | fe0fdf60b46716fa20318c627ea80ff4e3398263 (patch) | |
tree | 44566c2013fc4336da6baee40948b66070688f2a /lib | |
parent | c3aaf005e2ec2844fa02a60414978692b67727a4 (diff) | |
download | spack-fe0fdf60b46716fa20318c627ea80ff4e3398263.tar.gz spack-fe0fdf60b46716fa20318c627ea80ff4e3398263.tar.bz2 spack-fe0fdf60b46716fa20318c627ea80ff4e3398263.tar.xz spack-fe0fdf60b46716fa20318c627ea80ff4e3398263.zip |
Add ability to prefer particular versions in packages.
- Adding `preferred=True` to a version directive will change its sort
order in concretization.
- This provides us a rudimentary ability to keep the Spack stack
stable as new versions are added.
- Having multiple stacks will come next, but this at least allows us
to specify default versions of things instead of always taking the
newest.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/spack/spack/concretize.py | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/lib/spack/spack/concretize.py b/lib/spack/spack/concretize.py index d9419da784..85cdb202d5 100644 --- a/lib/spack/spack/concretize.py +++ b/lib/spack/spack/concretize.py @@ -40,7 +40,6 @@ import spack.error from spack.version import * - class DefaultConcretizer(object): """This class doesn't have any state, it just provides some methods for concretization. You can subclass it to override just some of the @@ -68,9 +67,17 @@ class DefaultConcretizer(object): # If there are known available versions, return the most recent # version that satisfies the spec pkg = spec.package + + # Key function to sort versions first by whether they were + # marked `preferred=True`, then by most recent. + def preferred_key(v): + prefer = pkg.versions[v].get('preferred', False) + return (prefer, v) + valid_versions = sorted( [v for v in pkg.versions - if any(v.satisfies(sv) for sv in spec.versions)]) + if any(v.satisfies(sv) for sv in spec.versions)], + key=preferred_key) if valid_versions: spec.versions = ver([valid_versions[-1]]) |