fc5871
# HG changeset patch
fc5871
# User Daniel <daniel@thunderbird.net>
fc5871
# Date 1658184582 0
fc5871
#      Mon Jul 18 22:49:42 2022 +0000
fc5871
# Node ID 9998ed5c2bcee289b03828eba670053614fa26da
fc5871
# Parent  e572bc3cfa07492189aec439e98378b0811ae3bb
fc5871
Bug 1753683 - Replace distutils (deprecated) with packaging. r=rjl
fc5871
fc5871
Differential Revision: https://phabricator.services.mozilla.com/D152123
fc5871
fc5871
diff --git a/comm/python/thirdroc/thirdroc/__init__.py b/comm/python/thirdroc/thirdroc/__init__.py
fc5871
--- a/comm/python/thirdroc/thirdroc/__init__.py
fc5871
+++ b/comm/python/thirdroc/thirdroc/__init__.py
fc5871
@@ -3,11 +3,11 @@
fc5871
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
fc5871
 
fc5871
 from __future__ import print_function, absolute_import
fc5871
 
fc5871
 import re
fc5871
-from distutils.version import StrictVersion
fc5871
+from packaging.version import parse
fc5871
 
fc5871
 VTAG_RE = re.compile(r"^v\d+\.\d+\.\d+$")
fc5871
 
fc5871
 
fc5871
 def tag2version(tag):
fc5871
@@ -22,16 +22,16 @@ def tag2version(tag):
fc5871
         raise Exception("Invalid tag {}".format(tag))
fc5871
 
fc5871
 
fc5871
 def get_latest_version(*versions):
fc5871
     """
fc5871
-    Given a list of versions (that must parse with distutils.version.StrictVersion,
fc5871
+    Given a list of versions (that must parse with packaging.version.parse),
fc5871
     return the latest/newest version.
fc5871
     :param list versions:
fc5871
-    :return StrictVersion:
fc5871
+    :return Version:
fc5871
     """
fc5871
-    version_list = [StrictVersion(tag2version(v)) for v in versions]
fc5871
+    version_list = [parse(tag2version(v)) for v in versions]
fc5871
     version_list.sort()
fc5871
     return version_list[-1]
fc5871
 
fc5871
 
fc5871
 def latest_version(*versions):
fc5871
diff --git a/comm/python/thirdroc/thirdroc/rnp.py b/comm/python/thirdroc/thirdroc/rnp.py
fc5871
--- a/comm/python/thirdroc/thirdroc/rnp.py
fc5871
+++ b/comm/python/thirdroc/thirdroc/rnp.py
fc5871
@@ -6,11 +6,11 @@ from __future__ import absolute_import
fc5871
 
fc5871
 import os
fc5871
 from io import StringIO
fc5871
 from datetime import date
fc5871
 import re
fc5871
-from distutils.version import StrictVersion
fc5871
+from packaging.version import parse
fc5871
 
fc5871
 from mozbuild.preprocessor import Preprocessor
fc5871
 
fc5871
 
fc5871
 def rnp_source_update(rnp_root, version_str, revision, timestamp, bug_report):
fc5871
@@ -21,14 +21,14 @@ def rnp_source_update(rnp_root, version_
fc5871
     :param string version_str: latest version
fc5871
     :param string revision: revision hash (short form)
fc5871
     :param float timestamp: UNIX timestamp from revision
fc5871
     :param string bug_report: where to report bugs for this RNP build
fc5871
     """
fc5871
-    version = StrictVersion(version_str)
fc5871
-    version_major = version.version[0]
fc5871
-    version_minor = version.version[1]
fc5871
-    version_patch = version.version[2]
fc5871
+    version = parse(version_str)
fc5871
+    version_major = version.major
fc5871
+    version_minor = version.minor
fc5871
+    version_patch = version.micro
fc5871
     date_str = date.fromtimestamp(float(timestamp)).strftime("%Y%m%d")
fc5871
     revision_short = revision[:8]
fc5871
     version_full = "{}+git{}.{}.MZLA".format(version_str, date_str, revision_short)
fc5871
 
fc5871
     defines = dict(