Skip to content

Commit

Permalink
[lldb] Use shutil.which instead of distutils find_executable
Browse files Browse the repository at this point in the history
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
  • Loading branch information
DavidSpickett committed Apr 29, 2022
1 parent 7047c47 commit 14869bd
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 4 deletions.
3 changes: 1 addition & 2 deletions lldb/packages/Python/lldbsuite/test/lldbtest.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@
import sys
import time
import traceback
import distutils.spawn

# Third-party modules
import unittest2
Expand Down Expand Up @@ -1568,7 +1567,7 @@ def findBuiltClang(self):

# 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

Expand Down
3 changes: 1 addition & 2 deletions lldb/test/Shell/lit.cfg.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

site.addsitedir(os.path.dirname(__file__))
from helper import toolchain
Expand Down Expand Up @@ -121,7 +120,7 @@ def calculate_arch_features(arch_string):
if config.lldb_enable_lzma:
config.available_features.add('lzma')

if find_executable('xz') != None:
if shutil.which('xz') != None:
config.available_features.add('xz')

if config.lldb_system_debugserver:
Expand Down

0 comments on commit 14869bd

Please sign in to comment.