From 4cfe401eb3d4b5ee0a4c99c957e9f96ae086aeb4 Mon Sep 17 00:00:00 2001 From: nose Date: Wed, 24 Dec 2025 03:03:36 -0800 Subject: [PATCH] bootstrap/setup: make global 'mm' wrapper prefer venv/python3 and fall back to python; include informative error when no Python found --- scripts/bootstrap.sh | 13 +++++++++---- scripts/setup.py | 11 ++++++++--- 2 files changed, 17 insertions(+), 7 deletions(-) diff --git a/scripts/bootstrap.sh b/scripts/bootstrap.sh index 56eeeb7..9f64c60 100644 --- a/scripts/bootstrap.sh +++ b/scripts/bootstrap.sh @@ -412,16 +412,21 @@ if [[ -f "$USER_BIN/mm" ]]; then echo "Backing up existing $USER_BIN/mm to $USER_BIN/mm.bak.$(date +%s)" mv "$USER_BIN/mm" "$USER_BIN/mm.bak.$(date +%s)" fi -cat > "$USER_BIN/mm" <<'EOF' +cat > "$USER_BIN/mm" </dev/null 2>&1; then + exec python3 -m medeia_macina.cli_entry "\$@" +elif command -v python >/dev/null 2>&1; then + exec python -m medeia_macina.cli_entry "\$@" else - exec python -m medeia_macina.cli_entry "$@" + echo "Error: no Python interpreter found (python3 or python). Activate the venv with 'source $VENV/bin/activate' or install system Python 3." >&2 + exit 127 fi EOF chmod +x "$USER_BIN/mm" diff --git a/scripts/setup.py b/scripts/setup.py index f0893fc..ca3ac43 100644 --- a/scripts/setup.py +++ b/scripts/setup.py @@ -363,13 +363,18 @@ python $cli @args sh_text = ( "#!/usr/bin/env bash\n" f"REPO=\"{repo}\"\n" - "VENV=\"$REPO/.venv\"\n" + f"VENV=\"{repo}/.venv\"\n" "if [ -x \"$VENV/bin/mm\" ]; then\n" " exec \"$VENV/bin/mm\" \"$@\"\n" "elif [ -x \"$VENV/bin/python\" ]; then\n" - " exec \"$VENV/bin/python\" -m medeia_entry \"$@\"\n" + " exec \"$VENV/bin/python\" -m medeia_macina.cli_entry \"$@\"\n" + "elif command -v python3 >/dev/null 2>&1; then\n" + " exec python3 -m medeia_macina.cli_entry \"$@\"\n" + "elif command -v python >/dev/null 2>&1; then\n" + " exec python -m medeia_macina.cli_entry \"$@\"\n" "else\n" - " exec python -m medeia_entry \"$@\"\n" + " echo 'Error: no Python interpreter (python3 or python) found in PATH. Please install Python 3 or use the venv.' >&2\n" + " exit 127\n" "fi\n" ) if mm_sh.exists():