run-tests: deal with distutil deprecation
authorPierre-Yves David <pierre-yves.david@octobus.net>
Thu, 22 Sep 2022 01:48:02 +0200
changeset 49507 35bf7f23b84c
parent 49506 59a72267f5ce
child 49508 1baf0fffd82f
run-tests: deal with distutil deprecation PEP 632 recommend the use of `packaging.version` to replace the deprecated `distutil.version`. So lets do it.
tests/run-tests.py
--- a/tests/run-tests.py	Fri Sep 09 12:45:26 2022 -0700
+++ b/tests/run-tests.py	Thu Sep 22 01:48:02 2022 +0200
@@ -48,7 +48,7 @@
 import collections
 import contextlib
 import difflib
-import distutils.version as version
+
 import errno
 import functools
 import json
@@ -72,6 +72,13 @@
 import uuid
 import xml.dom.minidom as minidom
 
+try:
+    # PEP 632 recommend the use of `packaging.version` to replace the
+    # deprecated `distutil.version`. So lets do it.
+    import packaging.version as version
+except ImportError:
+    import distutils.version as version
+
 if sys.version_info < (3, 5, 0):
     print(
         '%s is only supported on Python 3.5+, not %s'