Skip to content

Commit 14869bd

Browse files
committed
[lldb] Use shutil.which instead of distutils find_executable
distutils is deprecated and shutil.which is the suggested replacement for this function. https://peps.python.org/pep-0632/#migration-advice https://docs.python.org/3/library/shutil.html#shutil.which It was added in Python3.3 but given that we're already using shutil.which elsewhere I think this is ok/no worse than before. We do have our own find_executable in lldb/test/Shell/helper/build.py but I'd rather leave that as is for now. Also we have our own versions of which() but again, a change for another time. This work is part of #54337. Reviewed By: JDevlieghere Differential Revision: https://reviews.llvm.org/D124601
1 parent 7047c47 commit 14869bd

File tree

2 files changed

+2
-4
lines changed

2 files changed

+2
-4
lines changed

lldb/packages/Python/lldbsuite/test/lldbtest.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@
4949
import sys
5050
import time
5151
import traceback
52-
import distutils.spawn
5352

5453
# Third-party modules
5554
import unittest2
@@ -1568,7 +1567,7 @@ def findBuiltClang(self):
15681567

15691568
# Tries to find clang at the same folder as the lldb
15701569
lldb_dir = os.path.dirname(lldbtest_config.lldbExec)
1571-
path = distutils.spawn.find_executable("clang", lldb_dir)
1570+
path = shutil.which("clang", path=lldb_dir)
15721571
if path is not None:
15731572
return path
15741573

lldb/test/Shell/lit.cfg.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
from lit.llvm import llvm_config
1313
from lit.llvm.subst import FindTool
1414
from lit.llvm.subst import ToolSubst
15-
from distutils.spawn import find_executable
1615

1716
site.addsitedir(os.path.dirname(__file__))
1817
from helper import toolchain
@@ -121,7 +120,7 @@ def calculate_arch_features(arch_string):
121120
if config.lldb_enable_lzma:
122121
config.available_features.add('lzma')
123122

124-
if find_executable('xz') != None:
123+
if shutil.which('xz') != None:
125124
config.available_features.add('xz')
126125

127126
if config.lldb_system_debugserver:

0 commit comments

Comments
 (0)