[libcxx-commits] [libcxx] 268a4b0 - [libcxx] Replace find_executable with shutil.which

David Spickett via libcxx-commits libcxx-commits at lists.llvm.org
Mon Apr 17 08:01:53 PDT 2023


Author: David Spickett
Date: 2023-04-17T15:01:48Z
New Revision: 268a4b0a451432833d3b398c7182d133c865dff5

URL: https://github.com/llvm/llvm-project/commit/268a4b0a451432833d3b398c7182d133c865dff5
DIFF: https://github.com/llvm/llvm-project/commit/268a4b0a451432833d3b398c7182d133c865dff5.diff

LOG: [libcxx] Replace find_executable with shutil.which

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).

Reviewed By: #libc, philnik

Differential Revision: https://reviews.llvm.org/D148527

Added: 
    

Modified: 
    libcxx/utils/libcxx/sym_check/extract.py
    libcxx/utils/libcxx/sym_check/util.py

Removed: 
    


################################################################################
diff  --git a/libcxx/utils/libcxx/sym_check/extract.py b/libcxx/utils/libcxx/sym_check/extract.py
index c563720c74858..dbf7ab1a1dc13 100644
--- a/libcxx/utils/libcxx/sym_check/extract.py
+++ b/libcxx/utils/libcxx/sym_check/extract.py
@@ -9,10 +9,10 @@
 """
 extract - A set of function that extract symbol lists from shared libraries.
 """
-import distutils.spawn
 import os.path
 from os import environ
 import re
+import shutil
 import subprocess
 import sys
 
@@ -30,7 +30,7 @@ def find_tool():
         """
         Search for the nm executable and return the path.
         """
-        return distutils.spawn.find_executable('nm')
+        return shutil.which('nm')
 
     def __init__(self, static_lib):
         """
@@ -119,7 +119,7 @@ def find_tool():
         """
         Search for the readelf executable and return the path.
         """
-        return distutils.spawn.find_executable('readelf')
+        return shutil.which('readelf')
 
     def __init__(self, static_lib):
         """
@@ -200,7 +200,7 @@ def find_tool():
          """
          Search for the dump executable and return the path.
          """
-         return distutils.spawn.find_executable('dump')
+         return shutil.which('dump')
 
      def __init__(self, static_lib):
          """

diff  --git a/libcxx/utils/libcxx/sym_check/util.py b/libcxx/utils/libcxx/sym_check/util.py
index 7d9fd399912dc..897f992bc9e28 100644
--- a/libcxx/utils/libcxx/sym_check/util.py
+++ b/libcxx/utils/libcxx/sym_check/util.py
@@ -8,8 +8,8 @@
 
 from pprint import pformat
 import ast
-import distutils.spawn
 import re
+import shutil
 import subprocess
 import sys
 
@@ -60,7 +60,7 @@ def write_syms(sym_list, out=None, names_only=False, filter=None):
             f.write(out_str)
 
 
-_cppfilt_exe = distutils.spawn.find_executable('c++filt')
+_cppfilt_exe = shutil.which('c++filt')
 
 
 def demangle_symbol(symbol):


        


More information about the libcxx-commits mailing list