This commit is contained in:
onysd 2026-07-28 05:43:14 +03:00
parent 155a2435ce
commit c8eae6323f
2 changed files with 19 additions and 4 deletions

View file

@ -22,6 +22,10 @@ if errorlevel 1 (
) )
rem --- Python ------------------------------------------------------------- rem --- Python -------------------------------------------------------------
rem Just checking "where" isn't enough: on Windows, python.exe / python3.exe
rem can resolve to the Microsoft Store app-execution-alias stub, which sits
rem on PATH but fails as soon as it's actually run instead of launching real
rem Python. Confirm each candidate's --version actually succeeds too.
set "PYTHON=" set "PYTHON="
where py >nul 2>&1 where py >nul 2>&1
if not errorlevel 1 ( if not errorlevel 1 (
@ -30,7 +34,10 @@ if not errorlevel 1 (
) )
if not defined PYTHON ( if not defined PYTHON (
where python >nul 2>&1 where python >nul 2>&1
if not errorlevel 1 (
python --version >nul 2>&1
if not errorlevel 1 set "PYTHON=python" if not errorlevel 1 set "PYTHON=python"
)
) )
if not defined PYTHON ( if not defined PYTHON (

View file

@ -24,12 +24,20 @@ else
fi fi
# --- Python --------------------------------------------------------------- # --- Python ---------------------------------------------------------------
# Just checking `command -v` isn't enough: on Windows, `python3` (and
# sometimes `python`) can resolve to the Microsoft Store app-execution-alias
# stub, which exists on PATH but fails as soon as it's actually run instead
# of launching real Python. Validate the version output too.
PYTHON="" PYTHON=""
PYTHON_VERSION=""
for cand in python3 python; do for cand in python3 python; do
if command -v "$cand" >/dev/null 2>&1; then if command -v "$cand" >/dev/null 2>&1; then
if VER_OUT="$("$cand" --version 2>&1)" && [[ "$VER_OUT" == Python\ 3* ]]; then
PYTHON="$cand" PYTHON="$cand"
PYTHON_VERSION="$VER_OUT"
break break
fi fi
fi
done done
if [[ -z "$PYTHON" ]]; then if [[ -z "$PYTHON" ]]; then
@ -37,7 +45,7 @@ if [[ -z "$PYTHON" ]]; then
echo " Install it from: https://www.python.org/downloads/" echo " Install it from: https://www.python.org/downloads/"
PROBLEMS=1 PROBLEMS=1
else else
ok "Python found: $("$PYTHON" --version 2>&1) (${PYTHON})" ok "Python found: ${PYTHON_VERSION} (${PYTHON})"
fi fi
# --- Python dependencies ---------------------------------------------------- # --- Python dependencies ----------------------------------------------------