Skip to content

Commit ee34137

Browse files
committed
[clang] Replace find_executable with shutil.which in creduce script
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 which was added in 3.3 (https://docs.python.org/3/library/shutil.html#shutil.which) and LLVM requires at least 3.6 (https://llvm.org/docs/GettingStarted.html#software). There is one small differnce here that shutil.which ignores the PATH when given a path argument. However in this case I think that's actually the behaviour we want. Reviewed By: zequanwu Differential Revision: https://reviews.llvm.org/D148529
1 parent 2be3189 commit ee34137

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

clang/utils/creduce-clang-crash.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,14 @@
1111
from argparse import ArgumentParser, RawTextHelpFormatter
1212
import os
1313
import re
14+
import shutil
1415
import stat
1516
import sys
1617
import subprocess
1718
import pipes
1819
import shlex
1920
import tempfile
2021
import shutil
21-
from distutils.spawn import find_executable
2222
import multiprocessing
2323

2424
verbose = False
@@ -43,12 +43,12 @@ def check_cmd(cmd_name, cmd_dir, cmd_path=None):
4343
if cmd_path:
4444
# Make the path absolute so the creduce test can be run from any directory.
4545
cmd_path = os.path.abspath(cmd_path)
46-
cmd = find_executable(cmd_path)
46+
cmd = shutil.which(cmd_path)
4747
if cmd:
4848
return cmd
4949
sys.exit("ERROR: executable `%s` not found" % (cmd_path))
5050

51-
cmd = find_executable(cmd_name, path=cmd_dir)
51+
cmd = shutil.which(cmd_name, path=cmd_dir)
5252
if cmd:
5353
return cmd
5454

0 commit comments

Comments
 (0)