Skip to content

Commit

Permalink
Fix windows specific sort order quirks
Browse files Browse the repository at this point in the history
Signed-off-by: Dan Ryan <dan@danryan.co>
  • Loading branch information
techalchemy committed Jul 6, 2019
1 parent f1bfee0 commit 30b6763
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
4 changes: 2 additions & 2 deletions pipenv/vendor/pythonfinder/models/python.py
Expand Up @@ -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):
Expand Down Expand Up @@ -392,7 +392,7 @@ def version_sort(self):
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
Expand Down
8 changes: 6 additions & 2 deletions pipenv/vendor/pythonfinder/pythonfinder.py
Expand Up @@ -308,7 +308,11 @@ def find_all_python_versions(
)
if not isinstance(versions, Iterable):
versions = [versions]
path_list = sorted(versions, key=version_sort, reverse=True)
# This list has already been mostly sorted on windows, we don't need to reverse it again
if os.name == "nt":
path_list = sorted(versions, key=version_sort)
else:
path_list = sorted(versions, key=version_sort, reverse=True)
path_map = {} # type: Dict[str, PathEntry]
for path in path_list:
try:
Expand All @@ -317,4 +321,4 @@ def find_all_python_versions(
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

0 comments on commit 30b6763

Please sign in to comment.