From eb517e0bddf3c499c4ea1bf2be1f4086fc5ca8a2 Mon Sep 17 00:00:00 2001 From: Fabian Homborg Date: Sat, 28 Nov 2020 13:12:55 +0100 Subject: [PATCH] webconfig: Determine if we're termux without distutils Just copy that "find an executable" code we already have, the one that was commented with "oh, btw, distutils.spawn.find_executable is bad", and use it here as well. Work towards #7514. --- share/tools/web_config/webconfig.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/share/tools/web_config/webconfig.py b/share/tools/web_config/webconfig.py index 8252009c0..e724ced48 100755 --- a/share/tools/web_config/webconfig.py +++ b/share/tools/web_config/webconfig.py @@ -8,7 +8,6 @@ try: except ImportError: from cgi import escape as escape_html from distutils.version import LooseVersion -from distutils.spawn import find_executable import glob import multiprocessing.pool import operator @@ -36,6 +35,13 @@ else: from urllib.parse import parse_qs +def find_executable(exe): + for p in os.environ["PATH"].split(os.pathsep): + proposed_path = os.path.join(p, exe) + if os.access(proposed_path, os.X_OK): + return proposed_path + + def isMacOS10_12_5_OrLater(): """ Return whether this system is macOS 10.12.5 or a later version. """ version = platform.mac_ver()[0] @@ -1404,13 +1410,7 @@ fish_bin_dir = os.environ.get("__fish_bin_dir") fish_bin_path = None if not fish_bin_dir: print("The $__fish_bin_dir environment variable is not set. " "Looking in $PATH...") - # distutils.spawn is terribly broken, because it looks in wd before PATH, - # and doesn't actually validate that the file is even executable - for p in os.environ["PATH"].split(os.pathsep): - proposed_path = os.path.join(p, "fish") - if os.access(proposed_path, os.X_OK): - fish_bin_path = proposed_path - break + fish_bin_path = find_executable("fish") if not fish_bin_path: print("fish could not be found. Is fish installed correctly?") sys.exit(-1)