File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 6262 INSTALL_DIR=" ${INSTALL_DIR:- $HOME / devops_os} "
6363fi
6464
65- # --- Check Python ---
66- PYTHON=" ${PYTHON:- $(which python3 2>/ dev/ null || which python 2>/ dev/ null)} "
65+ # --- Check Python (require 3.10+) ---
66+ if [ -n " ${PYTHON:- } " ]; then
67+ CANDIDATES=(" $PYTHON " )
68+ else
69+ CANDIDATES=()
70+ if command -v python3 > /dev/null 2>&1 ; then
71+ CANDIDATES+=(" $( command -v python3) " )
72+ fi
73+ if command -v python > /dev/null 2>&1 ; then
74+ CANDIDATES+=(" $( command -v python) " )
75+ fi
76+ fi
77+
78+ PYTHON=" "
79+ PYTHON_VERSION=" "
80+ for cmd in " ${CANDIDATES[@]} " ; do
81+ ver=" $( " $cmd " -c ' import sys; print(f"{sys.version_info.major}.{sys.version_info.minor}")' 2> /dev/null || true) "
82+ if [ -z " $ver " ]; then
83+ continue
84+ fi
85+ major=" ${ver%% .* } "
86+ minor=" ${ver#* .} "
87+ if [ " $major " -gt 3 ] || { [ " $major " -eq 3 ] && [ " $minor " -ge 10 ]; }; then
88+ PYTHON=" $cmd "
89+ PYTHON_VERSION=" $ver "
90+ break
91+ fi
92+ done
93+
6794if [ -z " $PYTHON " ]; then
6895 echo " Error: Python 3.10+ is required but was not found in PATH." >&2
6996 echo " Install it from https://www.python.org/downloads/ and re-run this script." >&2
7097 exit 1
7198fi
72-
73- PYTHON_VERSION=$( " $PYTHON " -c " import sys; print(f'{sys.version_info.major}.{sys.version_info.minor}')" )
7499echo " ==> Using Python $PYTHON_VERSION at $PYTHON "
75100
76101# --- Clone or update repo (skipped in local mode) ---
You can’t perform that action at this time.
0 commit comments