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.
This commit is contained in:
Fabian Homborg 2020-11-28 13:12:55 +01:00
parent aa0bfa0eb8
commit eb517e0bdd

View File

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