DavidSpickett created this revision.
Herald added a project: All.
DavidSpickett requested review of this revision.
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.
TODO: This would require packaging (https://github.com/pypa/packaging)
to be added as a third party module, it is not part of the base python.
[lldb] Use packaging.version instead of distutils Strict/LooseVersion
distutils is deprecated (https://peps.python.org/pep-0632/) and
packaging is the recommended replacement.
Although LegacyVersion is itself deprecated within packaging,
we have our own copy of the package so that's not a risk until it
needs updating.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D124670
Files:
lldb/packages/Python/lldbsuite/test/decorators.py
lldb/packages/Python/lldbsuite/test/lldbtest.py
lldb/test/API/tools/lldb-server/TestAppleSimulatorOSType.py
lldb/test/Shell/helper/build.py
Index: lldb/test/Shell/helper/build.py
===================================================================
--- lldb/test/Shell/helper/build.py
+++ lldb/test/Shell/helper/build.py
@@ -351,8 +351,8 @@
if not subdirs:
return None
- from distutils.version import StrictVersion
- subdirs.sort(key=lambda x : StrictVersion(x))
+ from packaging.version import Version
+ subdirs.sort(key=lambda x : Version(x))
if self.verbose:
full_path = os.path.join(vcinstalldir, subdirs[-1])
@@ -417,9 +417,9 @@
return (None, None)
# Windows SDK version numbers consist of 4 dotted components, so we
- # have to use LooseVersion, as StrictVersion supports 3 or fewer.
- from distutils.version import LooseVersion
- sdk_versions.sort(key=lambda x : LooseVersion(x), reverse=True)
+ # have to use LegacyVersion, as Version expects 3 or fewer.
+ from packaging.version import LegacyVersion
+ sdk_versions.sort(key=lambda x : LegacyVersion(x), reverse=True)
option_value_name = 'OptionId.DesktopCPP' + self.msvc_arch_str
for v in sdk_versions:
try:
Index: lldb/test/API/tools/lldb-server/TestAppleSimulatorOSType.py
===================================================================
--- lldb/test/API/tools/lldb-server/TestAppleSimulatorOSType.py
+++ lldb/test/API/tools/lldb-server/TestAppleSimulatorOSType.py
@@ -54,8 +54,8 @@
# Older versions of watchOS (<7.0) only support i386
if platform_name == 'watchos':
- from distutils.version import LooseVersion
- if LooseVersion(vers) < LooseVersion("7.0"):
+ from packaging.version import LegacyVersion
+ if LegacyVersion(vers) < LegacyVersion("7.0"):
arch = 'i386'
triple = '-'.join([arch, 'apple', platform_name + vers, 'simulator'])
Index: lldb/packages/Python/lldbsuite/test/lldbtest.py
===================================================================
--- lldb/packages/Python/lldbsuite/test/lldbtest.py
+++ lldb/packages/Python/lldbsuite/test/lldbtest.py
@@ -36,7 +36,6 @@
# System modules
import abc
-from distutils.version import LooseVersion
from functools import wraps
import gc
import glob
@@ -51,6 +50,7 @@
import traceback
# Third-party modules
+from packaging.version import LegacyVersion
import unittest2
from six import add_metaclass
from six import StringIO as SixStringIO
@@ -1354,13 +1354,13 @@
return operator in ['>', '>=', '!', '!=', 'not']
if operator == '>':
- return LooseVersion(test_compiler_version) > LooseVersion(version)
+ return LegacyVersion(test_compiler_version) > LegacyVersion(version)
if operator == '>=' or operator == '=>':
- return LooseVersion(test_compiler_version) >= LooseVersion(version)
+ return LegacyVersion(test_compiler_version) >= LegacyVersion(version)
if operator == '<':
- return LooseVersion(test_compiler_version) < LooseVersion(version)
+ return LegacyVersion(test_compiler_version) < LegacyVersion(version)
if operator == '<=' or operator == '=<':
- return LooseVersion(test_compiler_version) <= LooseVersion(version)
+ return LegacyVersion(test_compiler_version) <= LegacyVersion(version)
if operator == '!=' or operator == '!' or operator == 'not':
return str(version) not in str(test_compiler_version)
return str(version) in str(test_compiler_version)
Index: lldb/packages/Python/lldbsuite/test/decorators.py
===================================================================
--- lldb/packages/Python/lldbsuite/test/decorators.py
+++ lldb/packages/Python/lldbsuite/test/decorators.py
@@ -1,7 +1,6 @@
from __future__ import absolute_import
# System modules
-from distutils.version import LooseVersion
from functools import wraps
import ctypes
import locale
@@ -13,6 +12,7 @@
import subprocess
# Third-party modules
+from packaging.version import LegacyVersion
import six
import unittest2
@@ -67,8 +67,8 @@
actual_str = '.'.join([str(x) for x in actual])
return op_lookup[comparison](
- LooseVersion(actual_str),
- LooseVersion(expected_str))
+ LegacyVersion(actual_str),
+ LegacyVersion(expected_str))
_re_pattern_type = type(re.compile(''))
_______________________________________________
lldb-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits