From 65ab15cd75e8c941b0c5022aa8ed66e1b41e1983 Mon Sep 17 00:00:00 2001 From: Bruno Korbar Date: Thu, 21 Apr 2022 10:23:48 +0000 Subject: [PATCH] replace distutils.spawn with shutil.which per PEP632 in setup script --- setup.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/setup.py b/setup.py index 8498354adb9..44dae571e9c 100644 --- a/setup.py +++ b/setup.py @@ -102,7 +102,7 @@ def find_library(name, vision_include): conda_installed = library_found else: # Check if using Anaconda to produce wheels - conda = distutils.spawn.find_executable("conda") + conda = shutil.which("conda") is_conda = conda is not None print(f"Running build on conda: {is_conda}") if is_conda: @@ -259,8 +259,8 @@ def get_extensions(): image_macros += [("USE_PYTHON", None)] # Locating libPNG - libpng = distutils.spawn.find_executable("libpng-config") - pngfix = distutils.spawn.find_executable("pngfix") + libpng = shutil.which("libpng-config") + pngfix = shutil.which("pngfix") png_found = libpng is not None or pngfix is not None print(f"PNG found: {png_found}") if png_found: @@ -340,7 +340,7 @@ def get_extensions(): ) ) - ffmpeg_exe = distutils.spawn.find_executable("ffmpeg") + ffmpeg_exe = shutil.which("ffmpeg") has_ffmpeg = ffmpeg_exe is not None # FIXME: Building torchvision with ffmpeg on MacOS or with Python 3.9 # FIXME: causes crash. See the following GitHub issues for more details. @@ -366,7 +366,7 @@ def get_extensions(): ffmpeg_include_dir = os.path.join(ffmpeg_root, "include") ffmpeg_library_dir = os.path.join(ffmpeg_root, "lib") - gcc = os.environ.get("CC", distutils.spawn.find_executable("gcc")) + gcc = os.environ.get("CC", shutil.which("gcc")) platform_tag = subprocess.run([gcc, "-print-multiarch"], stdout=subprocess.PIPE) platform_tag = platform_tag.stdout.strip().decode("utf-8")