Skip to content

[lldb] Use packaging module instead of pkg_resources #93712

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jun 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions lldb/packages/Python/lldbsuite/test/decorators.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# System modules
from functools import wraps
from pkg_resources import packaging
from packaging import version
import ctypes
import locale
import os
Expand Down Expand Up @@ -66,9 +66,7 @@ def fn_neq(x, y):
"<=": fn_leq,
}

return op_lookup[comparison](
packaging.version.parse(actual), packaging.version.parse(expected)
)
return op_lookup[comparison](version.parse(actual), version.parse(expected))


def _match_decorator_property(expected, actual):
Expand Down
15 changes: 7 additions & 8 deletions lldb/packages/Python/lldbsuite/test/lldbplatformutil.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@
import subprocess
import sys
import os
from urllib.parse import urlparse
from pkg_resources import packaging
from packaging import version

# LLDB modules
import lldb
Expand Down Expand Up @@ -309,17 +308,17 @@ def expectedCompilerVersion(compiler_version):
# Assume the compiler version is at or near the top of trunk.
return operator in [">", ">=", "!", "!=", "not"]

version = packaging.version.parse(version_str)
test_compiler_version = packaging.version.parse(test_compiler_version_str)
actual_version = version.parse(version_str)
test_compiler_version = version.parse(test_compiler_version_str)

if operator == ">":
return test_compiler_version > version
return test_compiler_version > actual_version
if operator == ">=" or operator == "=>":
return test_compiler_version >= version
return test_compiler_version >= actual_version
if operator == "<":
return test_compiler_version < version
return test_compiler_version < actual_version
if operator == "<=" or operator == "=<":
return test_compiler_version <= version
return test_compiler_version <= actual_version
if operator == "!=" or operator == "!" or operator == "not":
return version_str not in test_compiler_version_str
return version_str in test_compiler_version_str
Expand Down
4 changes: 2 additions & 2 deletions lldb/test/API/tools/lldb-server/TestAppleSimulatorOSType.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,9 @@ def check_simulator_ostype(self, sdk, platform_name, arch=platform.machine()):

# Older versions of watchOS (<7.0) only support i386
if platform_name == "watchos":
from pkg_resources import packaging
from packaging import version

if packaging.version.parse(vers) < packaging.version.parse("7.0"):
if version.parse(vers) < version.parse("7.0"):
arch = "i386"

triple = "-".join([arch, "apple", platform_name + vers, "simulator"])
Expand Down
10 changes: 4 additions & 6 deletions lldb/test/Shell/helper/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -441,9 +441,9 @@ def _get_vctools_version(self):
if not subdirs:
return None

from distutils.version import StrictVersion
from packaging import version

subdirs.sort(key=lambda x: StrictVersion(x))
subdirs.sort(key=lambda x: version.parse(x))

if self.verbose:
full_path = os.path.join(vcinstalldir, subdirs[-1])
Expand Down Expand Up @@ -517,11 +517,9 @@ def _find_windows_sdk_in_registry_view(self, view):
if not sdk_versions:
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 pkg_resources import packaging
from packaging import version

sdk_versions.sort(key=lambda x: packaging.version.parse(x), reverse=True)
sdk_versions.sort(key=lambda x: version.parse(x), reverse=True)
option_value_name = "OptionId.DesktopCPP" + self.msvc_arch_str
for v in sdk_versions:
try:
Expand Down
Loading