mirror of
https://github.com/fish-shell/fish-shell.git
synced 2024-11-22 12:04:39 +08:00
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:
parent
aa0bfa0eb8
commit
eb517e0bdd
|
@ -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)
|
||||
|
|
Loading…
Reference in New Issue
Block a user