Unverified Commit 7998cdfa authored by Bruno Korbar's avatar Bruno Korbar Committed by GitHub
Browse files

replace distutils.spawn with shutil.which per PEP632 in setup script (#5849)


Co-authored-by: default avatarBruno Korbar <bkorbar@quansight.com>
Co-authored-by: default avatarNicolas Hug <contact@nicolas-hug.com>
parent 385a44f8
...@@ -102,7 +102,7 @@ def find_library(name, vision_include): ...@@ -102,7 +102,7 @@ def find_library(name, vision_include):
conda_installed = library_found conda_installed = library_found
else: else:
# Check if using Anaconda to produce wheels # Check if using Anaconda to produce wheels
conda = distutils.spawn.find_executable("conda") conda = shutil.which("conda")
is_conda = conda is not None is_conda = conda is not None
print(f"Running build on conda: {is_conda}") print(f"Running build on conda: {is_conda}")
if is_conda: if is_conda:
...@@ -259,8 +259,8 @@ def get_extensions(): ...@@ -259,8 +259,8 @@ def get_extensions():
image_macros += [("USE_PYTHON", None)] image_macros += [("USE_PYTHON", None)]
# Locating libPNG # Locating libPNG
libpng = distutils.spawn.find_executable("libpng-config") libpng = shutil.which("libpng-config")
pngfix = distutils.spawn.find_executable("pngfix") pngfix = shutil.which("pngfix")
png_found = libpng is not None or pngfix is not None png_found = libpng is not None or pngfix is not None
print(f"PNG found: {png_found}") print(f"PNG found: {png_found}")
if png_found: if png_found:
...@@ -340,7 +340,7 @@ def get_extensions(): ...@@ -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 has_ffmpeg = ffmpeg_exe is not None
# FIXME: Building torchvision with ffmpeg on MacOS or with Python 3.9 # FIXME: Building torchvision with ffmpeg on MacOS or with Python 3.9
# FIXME: causes crash. See the following GitHub issues for more details. # FIXME: causes crash. See the following GitHub issues for more details.
...@@ -366,7 +366,7 @@ def get_extensions(): ...@@ -366,7 +366,7 @@ def get_extensions():
ffmpeg_include_dir = os.path.join(ffmpeg_root, "include") ffmpeg_include_dir = os.path.join(ffmpeg_root, "include")
ffmpeg_library_dir = os.path.join(ffmpeg_root, "lib") 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 = subprocess.run([gcc, "-print-multiarch"], stdout=subprocess.PIPE)
platform_tag = platform_tag.stdout.strip().decode("utf-8") platform_tag = platform_tag.stdout.strip().decode("utf-8")
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment