summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/spack/spack/package_prefs.py10
-rw-r--r--lib/spack/spack/test/concretize_preferences.py5
-rw-r--r--var/spack/repos/builtin.mock/packages/mixedversions/package.py36
3 files changed, 50 insertions, 1 deletions
diff --git a/lib/spack/spack/package_prefs.py b/lib/spack/spack/package_prefs.py
index 2e70a3b7dc..56efb604b1 100644
--- a/lib/spack/spack/package_prefs.py
+++ b/lib/spack/spack/package_prefs.py
@@ -112,9 +112,17 @@ class PackagePrefs(object):
# integer is the index of the first spec in order that satisfies
# spec, or it's a number larger than any position in the order.
- return next(
+ match_index = next(
(i for i, s in enumerate(spec_order) if spec.satisfies(s)),
len(spec_order))
+ if match_index < len(spec_order) and spec_order[match_index] == spec:
+ # If this is called with multiple specs that all satisfy the same
+ # minimum index in spec_order, the one which matches that element
+ # of spec_order exactly is considered slightly better. Note
+ # that because this decreases the value by less than 1, it is not
+ # better than a match which occurs at an earlier index.
+ match_index -= 0.5
+ return match_index
@classproperty
@classmethod
diff --git a/lib/spack/spack/test/concretize_preferences.py b/lib/spack/spack/test/concretize_preferences.py
index 5e880bc4d6..45c037eec7 100644
--- a/lib/spack/spack/test/concretize_preferences.py
+++ b/lib/spack/spack/test/concretize_preferences.py
@@ -102,6 +102,11 @@ class TestConcretizePreferences(object):
spec = concretize('mpileaks')
assert spec.version == spack.spec.Version('2.2')
+ def test_preferred_versions_mixed_version_types(self):
+ update_packages('mixedversions', 'version', ['2.0'])
+ spec = concretize('mixedversions')
+ assert spec.version == spack.spec.Version('2.0')
+
def test_preferred_providers(self):
"""Test preferred providers of virtual packages are
applied correctly
diff --git a/var/spack/repos/builtin.mock/packages/mixedversions/package.py b/var/spack/repos/builtin.mock/packages/mixedversions/package.py
new file mode 100644
index 0000000000..5b56eb004d
--- /dev/null
+++ b/var/spack/repos/builtin.mock/packages/mixedversions/package.py
@@ -0,0 +1,36 @@
+##############################################################################
+# Copyright (c) 2013-2016, Lawrence Livermore National Security, LLC.
+# Produced at the Lawrence Livermore National Laboratory.
+#
+# This file is part of Spack.
+# Created by Todd Gamblin, tgamblin@llnl.gov, All rights reserved.
+# LLNL-CODE-647188
+#
+# For details, see https://github.com/llnl/spack
+# Please also see the NOTICE and LICENSE files for our notice and the LGPL.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License (as
+# published by the Free Software Foundation) version 2.1, February 1999.
+#
+# This program is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the IMPLIED WARRANTY OF
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the terms and
+# conditions of the GNU Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+##############################################################################
+from spack import *
+
+
+class Mixedversions(Package):
+ url = "http://www.fake-mixedversions.org/downloads/mixedversions-1.0.tar.gz"
+
+ version('2.0.1', 'hashc')
+ version('2.0', 'hashb')
+ version('1.0.1', 'hasha')
+
+ def install(self, spec, prefix):
+ pass