[Lldb-commits] [PATCH] D124601: [lldb] Use shutil.which instead of distutils find_executable

David Spickett via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Thu Apr 28 02:17:38 PDT 2022

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.

distutils is deprecated and shutil.which is the suggested
replacement for this function.


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.

  rG LLVM Github Monorepo



Index: lldb/test/Shell/lit.cfg.py
--- lldb/test/Shell/lit.cfg.py
+++ lldb/test/Shell/lit.cfg.py
@@ -12,7 +12,6 @@
 from lit.llvm import llvm_config
 from lit.llvm.subst import FindTool
 from lit.llvm.subst import ToolSubst
-from distutils.spawn import find_executable
 from helper import toolchain
@@ -121,7 +120,7 @@
 if config.lldb_enable_lzma:
-if find_executable('xz') != None:
+if shutil.which('xz') != None:
 if config.lldb_system_debugserver:
Index: lldb/packages/Python/lldbsuite/test/lldbtest.py
--- lldb/packages/Python/lldbsuite/test/lldbtest.py
+++ lldb/packages/Python/lldbsuite/test/lldbtest.py
@@ -49,7 +49,6 @@
 import sys
 import time
 import traceback
-import distutils.spawn
 # Third-party modules
 import unittest2
@@ -1568,7 +1567,7 @@
         # Tries to find clang at the same folder as the lldb
         lldb_dir = os.path.dirname(lldbtest_config.lldbExec)
-        path = distutils.spawn.find_executable("clang", lldb_dir)
+        path = shutil.which("clang", path=lldb_dir)
         if path is not None:
             return path

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D124601.425724.patch
Type: text/x-patch
Size: 1332 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20220428/336ae170/attachment.bin>

More information about the lldb-commits mailing list