Better algorithm for find_all_versions

Signed-off-by: Dan Ryan <dan@danryan.co>
This commit is contained in:
Dan Ryan
2018-07-17 02:45:57 -04:00
parent 6518325a3c
commit febfc6e907
+5
View File
@@ -76,6 +76,11 @@ class Finder(object):
def find_all_python_versions(self, major=None, minor=None, patch=None, pre=None, dev=None, arch=None):
version_sort = operator.attrgetter("as_python.version_sort")
python_version_dict = getattr(self.system_path, 'python_version_dict')
if python_version_dict:
paths = [path for version in python_version_dict.values() for path in version]
paths = sorted(paths, key=version_sort, reverse=True)
return paths
versions = self.system_path.find_all_python_versions(major=major, minor=minor, patch=patch, pre=pre, dev=dev, arch=arch)
if not isinstance(versions, list):
versions = [versions,]