diff --git a/src/python/pants/backend/project_info/tasks/export.py b/src/python/pants/backend/project_info/tasks/export.py index 00270bdee4d..a9c8425b0d7 100644 --- a/src/python/pants/backend/project_info/tasks/export.py +++ b/src/python/pants/backend/project_info/tasks/export.py @@ -336,8 +336,8 @@ def iter_transitive_jars(jar_lib): # across all the python targets in-play. # # For now, make our arbitrary historical choice of a default interpreter explicit and use the - # lowest version. - default_interpreter = min(python_interpreter_targets_mapping.keys()) + # highest version. + default_interpreter = max(python_interpreter_targets_mapping.keys()) interpreters_info = {} for interpreter, targets in six.iteritems(python_interpreter_targets_mapping): diff --git a/src/python/pants/backend/python/interpreter_cache.py b/src/python/pants/backend/python/interpreter_cache.py index e0126f74e13..8350d9d0169 100644 --- a/src/python/pants/backend/python/interpreter_cache.py +++ b/src/python/pants/backend/python/interpreter_cache.py @@ -112,8 +112,8 @@ def select_interpreter_for_targets(self, targets): 'Unable to detect a suitable interpreter for compatibilities: {} ' '(Conflicting targets: {})'.format(' && '.join(sorted(unique_compatibilities_strs)), ', '.join(tgts_by_compatibilities_strs))) - # Return the lowest compatible interpreter. - return min(allowed_interpreters) + # Return the highest compatible interpreter. + return max(allowed_interpreters) def _interpreter_from_path(self, path, filters=()): try: diff --git a/tests/python/pants_test/backend/python/interpreter_selection_utils.py b/tests/python/pants_test/backend/python/interpreter_selection_utils.py index 90d3ccc69f3..101a8ef5e6d 100644 --- a/tests/python/pants_test/backend/python/interpreter_selection_utils.py +++ b/tests/python/pants_test/backend/python/interpreter_selection_utils.py @@ -36,7 +36,7 @@ def python_interpreter_path(version): command = ['python{}'.format(version), '-c', 'import sys; print(sys.executable)'] py_path = subprocess.check_output(command).decode('utf-8').strip() return os.path.realpath(py_path) - except subprocess.CalledProcessError: + except (subprocess.CalledProcessError, OSError): return None diff --git a/tests/python/pants_test/backend/python/tasks/test_select_interpreter.py b/tests/python/pants_test/backend/python/tasks/test_select_interpreter.py index 07fcfb626fa..7f3efaa68db 100644 --- a/tests/python/pants_test/backend/python/tasks/test_select_interpreter.py +++ b/tests/python/pants_test/backend/python/tasks/test_select_interpreter.py @@ -105,14 +105,14 @@ def _select_interpreter_and_get_version(self, target_roots, should_invalidate=No def test_interpreter_selection(self): self.assertIsNone(self._select_interpreter([])) - self.assertEqual('IronPython-2.77.777', self._select_interpreter_and_get_version([self.reqtgt])) - self.assertEqual('IronPython-2.77.777', self._select_interpreter_and_get_version([self.tgt1])) - self.assertEqual('IronPython-2.88.888', self._select_interpreter_and_get_version([self.tgt2])) + self.assertEqual('IronPython-2.99.999', self._select_interpreter_and_get_version([self.reqtgt])) + self.assertEqual('IronPython-2.99.999', self._select_interpreter_and_get_version([self.tgt1])) + self.assertEqual('IronPython-2.99.999', self._select_interpreter_and_get_version([self.tgt2])) self.assertEqual('IronPython-2.99.999', self._select_interpreter_and_get_version([self.tgt3])) - self.assertEqual('IronPython-2.77.777', self._select_interpreter_and_get_version([self.tgt4])) - self.assertEqual('IronPython-2.88.888', self._select_interpreter_and_get_version([self.tgt20])) + self.assertEqual('IronPython-2.88.888', self._select_interpreter_and_get_version([self.tgt4])) + self.assertEqual('IronPython-2.99.999', self._select_interpreter_and_get_version([self.tgt20])) self.assertEqual('IronPython-2.99.999', self._select_interpreter_and_get_version([self.tgt30])) - self.assertEqual('IronPython-2.77.777', self._select_interpreter_and_get_version([self.tgt40])) + self.assertEqual('IronPython-2.88.888', self._select_interpreter_and_get_version([self.tgt40])) self.assertEqual('IronPython-2.99.999', self._select_interpreter_and_get_version([self.tgt2, self.tgt3])) self.assertEqual('IronPython-2.88.888', self._select_interpreter_and_get_version([self.tgt2, self.tgt4]))