diff --git a/deploy/install.sh b/deploy/install.sh index db48f38..76bfede 100755 --- a/deploy/install.sh +++ b/deploy/install.sh @@ -33,16 +33,24 @@ # ── 1. prerequisites ──────────────────────────────────────────────── say "Checking prerequisites" -if ! command -v python3 >/dev/null; then - err "python3 not found — install Python 3.11+ first"; exit 1 -fi -PYOK=$(python3 - <<'EOF' -import sys -print(0 if sys.version_info >= (3, 11) else 1) -EOF -) -if [ "$PYOK" != "0" ]; then - err "python3 is older than 3.11 — upgrade and re-run"; exit 1 +# Pick the first interpreter >= 3.11. Ubuntu 22.04's system python3 is 3.10 +# (and must NOT be replaced — apt depends on it); a newer Python installed +# alongside (deadsnakes PPA) lives under its own name, e.g. python3.12. +PYBIN="" +for cand in python3.13 python3.12 python3.11 python3; do + command -v "$cand" >/dev/null 2>&1 || continue + if "$cand" -c 'import sys; sys.exit(0 if sys.version_info >= (3, 11) else 1)'; then + PYBIN="$cand" + break + fi +done +if [ -z "$PYBIN" ]; then + err "no python >= 3.11 found (system python3 is too old)." + err "Ubuntu 22.04: sudo add-apt-repository ppa:deadsnakes/ppa && sudo apt update" + err " sudo apt install python3.12 python3.12-venv" + err "Ubuntu 24.04 already ships 3.12 as python3." + err "Do NOT replace the system python3 — install alongside and re-run." + exit 1 fi if ! command -v docker >/dev/null; then @@ -51,7 +59,7 @@ if ! $SUDO docker compose version >/dev/null 2>&1; then err "docker compose (v2 plugin) not available"; exit 1 fi -echo "OK: python3 $(python3 --version | cut -d' ' -f2), docker + compose" +echo "OK: $PYBIN ($($PYBIN --version 2>&1)), docker + compose" # ── 2. .env ──────────────────────────────────────────────────────── say "Provisioning .env" @@ -91,7 +99,7 @@ # ── 4. venv + install ─────────────────────────────────────────────── say "Building venv and installing navi" if [ ! -d .venv ]; then - python3 -m venv .venv + "$PYBIN" -m venv .venv fi ./.venv/bin/pip install --upgrade pip -q ./.venv/bin/pip install -e .