From: Zack Cerza Date: Thu, 23 May 2024 21:46:22 +0000 (-0600) Subject: bootstrap: Improve Python version detection X-Git-Tag: 1.2.0~40^2~1 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=f91cd22d400436ce1455f386e8564cb3b8421b23;p=teuthology.git bootstrap: Improve Python version detection Signed-off-by: Zack Cerza --- diff --git a/bootstrap b/bootstrap index 53c56f876..cc5e1e7a9 100755 --- a/bootstrap +++ b/bootstrap @@ -21,16 +21,11 @@ if [ -z "$PYTHON" ]; then for i in 12 11 10; do command -v "python3.$i" && PYTHON="python3.$i" && break done +fi +if [ -z "$PYTHON" ]; then # This would be bizarre, but I suppose possible PYTHON=${PYTHON:-"python3"} fi -PYTHON_VER_OUT=$($PYTHON --version) -PYTHON_BIN=$(command -v $PYTHON) -if [ -z $PYTHON_BIN -o ! -e $PYTHON_BIN -o ! -x $PYTHON_BIN ]; then - echo "Cannot find $PYTHON!" - exit 1 -fi -VENV=${VENV:-"virtualenv"} case "$(uname -s)" in Linux) @@ -176,6 +171,14 @@ Darwin) ;; esac +PYTHON_BIN=$(command -v $PYTHON) +if [ -z $PYTHON_BIN -o ! -e $PYTHON_BIN -o ! -x $PYTHON_BIN ]; then + echo "Cannot find $PYTHON!" + exit 1 +fi +PYTHON_VER_OUT=$($PYTHON_BIN --version) + +VENV=${VENV:-"virtualenv"} # If the venv was set to use system site-packages, fix that if [ -f "$VENV/pyvenv.cfg" ]; then sed -i'' -e 's/\(include-system-site-packages\s*=\s*\)true/\1false/g' $VENV/pyvenv.cfg