Skip to content

Commit

Permalink
Use mozilla-version for version sorting instead of packaging.LegacyVe…
Browse files Browse the repository at this point in the history
…rsion. Fixes mozilla#635

As packaging.LegacyVersion is gone, and packaging.Version produces
too many errors, use the various version classes from mozilla_version.gecko
when looking for the latest version of a supported application.
  • Loading branch information
jfx2006 committed Feb 28, 2023
1 parent ad1754b commit b928767
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
10 changes: 8 additions & 2 deletions mozdownload/scraper.py
Expand Up @@ -33,6 +33,11 @@
APPLICATIONS_TO_FTP_DIRECTORY = {'fennec': 'mobile'}
# Used if the application is named differently then the binary on the server
APPLICATIONS_TO_BINARY_NAME = {'devedition': 'firefox'}
# Used when sorting versions
APPLICATIONS_TO_VERSION_CLASS = {'devedition': 'DeveditionVersion',
'firefox': 'FirefoxVersion',
'fennec': 'FennecVersion',
'thunderbird': 'ThunderbirdVersion'}

# Base URL for the path to all builds
BASE_URL = 'https://archive.mozilla.org/pub/'
Expand Down Expand Up @@ -668,8 +673,9 @@ def query_versions(self, version=None):
parser = self._create_directory_parser(url)
if version:
versions = parser.filter(RELEASE_AND_CANDIDATE_LATEST_VERSIONS[version])
from packaging.version import LegacyVersion
versions.sort(key=LegacyVersion)
from mozilla_version import gecko
MozVersion = getattr(gecko, APPLICATIONS_TO_VERSION_CLASS[self.application])
versions.sort(key=MozVersion.parse)
return [versions[-1]]
else:
return parser.entries
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
@@ -1,6 +1,6 @@
mozinfo >= 1.0.0
packaging >= 19.0
progressbar2 >= 3.34.3
redo==2.0.4
requests >= 2.21.0, <3.0.0
treeherder-client >= 5.0.0, <6.0.0
mozilla-version >= 1.2.0
1 change: 0 additions & 1 deletion requirements/tests.txt
@@ -1,5 +1,4 @@
coveralls[yaml]==3.3.1
packaging==21.3.0
pytest==7.2.1
pytest-cov==4.0.0
pytest-mock==3.10.0
Expand Down

0 comments on commit b928767

Please sign in to comment.