Fix windows specific sort order quirks

Signed-off-by: Dan Ryan <dan@danryan.co>
This commit is contained in:
Dan Ryan
2019-07-06 03:50:23 -04:00
parent f1bfee0375
commit 85d0152361
2 changed files with 4 additions and 3 deletions
+2 -2
View File
@@ -354,7 +354,7 @@ class PythonVersion(object):
architecture = attr.ib(default=None) # type: Optional[str]
comes_from = attr.ib(default=None) # type: Optional[PathEntry]
executable = attr.ib(default=None) # type: Optional[str]
company = attr.ib(default="PythonCore") # type: Optional[str]
company = attr.ib(default=None) # type: Optional[str]
name = attr.ib(default=None, type=str)
def __getattribute__(self, key):
@@ -392,7 +392,7 @@ class PythonVersion(object):
postrelease. ``(0, 3, 7, 3, 2)`` represents a non-core python release, e.g. by
a repackager of python like Continuum.
"""
company_sort = 1 if self.company == "PythonCore" else 0
company_sort = 1 if (self.company and self.company == "PythonCore") else 0
release_sort = 2
if self.is_postrelease:
release_sort = 3
+2 -1
View File
@@ -308,6 +308,7 @@ class Finder(object):
)
if not isinstance(versions, Iterable):
versions = [versions]
# This list has already been mostly sorted on windows, we don't need to reverse it again
path_list = sorted(versions, key=version_sort, reverse=True)
path_map = {} # type: Dict[str, PathEntry]
for path in path_list:
@@ -317,4 +318,4 @@ class Finder(object):
resolved_path = path.path.absolute()
if not path_map.get(resolved_path.as_posix()):
path_map[resolved_path.as_posix()] = path
return list(path_map.values())
return path_list