#!/usr/bin/env bash # Resolve a Python interpreter that can import the MuseHub app. # # Sourced by every scripts/verify/verify_*.sh wrapper. Sets PY to an interpreter # whose environment satisfies `import musehub.main`, or exits non-zero. # # Fails closed on purpose: an L1 checkpoint that silently passes because no # interpreter was available is worse than one that refuses to run. The three # MuseHub verify checks exist precisely because "the suite was green" was # accepted as proof that the app worked, so "the check did not run" must never # be reported as success. # # Resolution order: # 1. $MUSEHUB_VERIFY_PYTHON — explicit override (CI, containers) # 2. .venv/bin/python — local developer environment # 3. python3 on PATH — only if it can already import musehub # # Docker is deliberately not attempted: docker-compose.override.yml bind-mounts # ../contracts, which is empty on at least one developer machine, so a container # fallback would fail with a misleading error instead of a clear setup message. set -euo pipefail _verify_can_import() { "$1" -c 'import musehub.main' >/dev/null 2>&1 } PY="" if [[ -n "${MUSEHUB_VERIFY_PYTHON:-}" ]]; then if [[ ! -x "${MUSEHUB_VERIFY_PYTHON}" ]]; then echo "FAIL: MUSEHUB_VERIFY_PYTHON=${MUSEHUB_VERIFY_PYTHON} is not executable" >&2 exit 3 fi PY="${MUSEHUB_VERIFY_PYTHON}" elif [[ -x ".venv/bin/python" ]]; then PY=".venv/bin/python" elif command -v python3 >/dev/null 2>&1 && _verify_can_import "python3"; then PY="python3" else cat >&2 <<'SETUP' FAIL: no Python interpreter can import the MuseHub app. The L1 verify checks refuse to report success when they cannot run. Set up a local environment (pyproject requires Python >= 3.14, and the [dev] extra cannot install because muse_contracts is published on no index): python3.14 -m venv .venv .venv/bin/python -m pip install -e . .venv/bin/python -m pip install -e ../muse .venv/bin/python -m pip install pytest httpx Or point the checks at an existing interpreter: MUSEHUB_VERIFY_PYTHON=/path/to/python ok verify-step SETUP exit 3 fi export PY