Blob Blame History Raw
# HG changeset patch
# User Daniel <daniel@thunderbird.net>
# Date 1658184582 0
#      Mon Jul 18 22:49:42 2022 +0000
# Node ID 9998ed5c2bcee289b03828eba670053614fa26da
# Parent  e572bc3cfa07492189aec439e98378b0811ae3bb
Bug 1753683 - Replace distutils (deprecated) with packaging. r=rjl

Differential Revision: https://phabricator.services.mozilla.com/D152123

diff --git a/comm/python/thirdroc/thirdroc/__init__.py b/comm/python/thirdroc/thirdroc/__init__.py
--- a/comm/python/thirdroc/thirdroc/__init__.py
+++ b/comm/python/thirdroc/thirdroc/__init__.py
@@ -3,11 +3,11 @@
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
 from __future__ import print_function, absolute_import
 
 import re
-from distutils.version import StrictVersion
+from packaging.version import parse
 
 VTAG_RE = re.compile(r"^v\d+\.\d+\.\d+$")
 
 
 def tag2version(tag):
@@ -22,16 +22,16 @@ def tag2version(tag):
         raise Exception("Invalid tag {}".format(tag))
 
 
 def get_latest_version(*versions):
     """
-    Given a list of versions (that must parse with distutils.version.StrictVersion,
+    Given a list of versions (that must parse with packaging.version.parse),
     return the latest/newest version.
     :param list versions:
-    :return StrictVersion:
+    :return Version:
     """
-    version_list = [StrictVersion(tag2version(v)) for v in versions]
+    version_list = [parse(tag2version(v)) for v in versions]
     version_list.sort()
     return version_list[-1]
 
 
 def latest_version(*versions):
diff --git a/comm/python/thirdroc/thirdroc/rnp.py b/comm/python/thirdroc/thirdroc/rnp.py
--- a/comm/python/thirdroc/thirdroc/rnp.py
+++ b/comm/python/thirdroc/thirdroc/rnp.py
@@ -6,11 +6,11 @@ from __future__ import absolute_import
 
 import os
 from io import StringIO
 from datetime import date
 import re
-from distutils.version import StrictVersion
+from packaging.version import parse
 
 from mozbuild.preprocessor import Preprocessor
 
 
 def rnp_source_update(rnp_root, version_str, revision, timestamp, bug_report):
@@ -21,14 +21,14 @@ def rnp_source_update(rnp_root, version_
     :param string version_str: latest version
     :param string revision: revision hash (short form)
     :param float timestamp: UNIX timestamp from revision
     :param string bug_report: where to report bugs for this RNP build
     """
-    version = StrictVersion(version_str)
-    version_major = version.version[0]
-    version_minor = version.version[1]
-    version_patch = version.version[2]
+    version = parse(version_str)
+    version_major = version.major
+    version_minor = version.minor
+    version_patch = version.micro
     date_str = date.fromtimestamp(float(timestamp)).strftime("%Y%m%d")
     revision_short = revision[:8]
     version_full = "{}+git{}.{}.MZLA".format(version_str, date_str, revision_short)
 
     defines = dict(