gabriel / musehub public
_python_env.sh bash
61 lines 2.1 KB
Raw
sha256:f65847c6a4ae29872f3ccbc2420f91a8948949b84a06320bdaf2ac281c89ff8a docs(F7b): governance sync — BUILT awaiting Gabriel; carry … Human patch 26 days ago
1 #!/usr/bin/env bash
2 # Resolve a Python interpreter that can import the MuseHub app.
3 #
4 # Sourced by every scripts/verify/verify_*.sh wrapper. Sets PY to an interpreter
5 # whose environment satisfies `import musehub.main`, or exits non-zero.
6 #
7 # Fails closed on purpose: an L1 checkpoint that silently passes because no
8 # interpreter was available is worse than one that refuses to run. The three
9 # MuseHub verify checks exist precisely because "the suite was green" was
10 # accepted as proof that the app worked, so "the check did not run" must never
11 # be reported as success.
12 #
13 # Resolution order:
14 # 1. $MUSEHUB_VERIFY_PYTHON — explicit override (CI, containers)
15 # 2. .venv/bin/python — local developer environment
16 # 3. python3 on PATH — only if it can already import musehub
17 #
18 # Docker is deliberately not attempted: docker-compose.override.yml bind-mounts
19 # ../contracts, which is empty on at least one developer machine, so a container
20 # fallback would fail with a misleading error instead of a clear setup message.
21
22 set -euo pipefail
23
24 _verify_can_import() {
25 "$1" -c 'import musehub.main' >/dev/null 2>&1
26 }
27
28 PY=""
29
30 if [[ -n "${MUSEHUB_VERIFY_PYTHON:-}" ]]; then
31 if [[ ! -x "${MUSEHUB_VERIFY_PYTHON}" ]]; then
32 echo "FAIL: MUSEHUB_VERIFY_PYTHON=${MUSEHUB_VERIFY_PYTHON} is not executable" >&2
33 exit 3
34 fi
35 PY="${MUSEHUB_VERIFY_PYTHON}"
36 elif [[ -x ".venv/bin/python" ]]; then
37 PY=".venv/bin/python"
38 elif command -v python3 >/dev/null 2>&1 && _verify_can_import "python3"; then
39 PY="python3"
40 else
41 cat >&2 <<'SETUP'
42 FAIL: no Python interpreter can import the MuseHub app.
43
44 The L1 verify checks refuse to report success when they cannot run.
45
46 Set up a local environment (pyproject requires Python >= 3.14, and the [dev]
47 extra cannot install because muse_contracts is published on no index):
48
49 python3.14 -m venv .venv
50 .venv/bin/python -m pip install -e .
51 .venv/bin/python -m pip install -e ../muse
52 .venv/bin/python -m pip install pytest httpx
53
54 Or point the checks at an existing interpreter:
55
56 MUSEHUB_VERIFY_PYTHON=/path/to/python ok verify-step <step>
57 SETUP
58 exit 3
59 fi
60
61 export PY
File History 1 commit
sha256:f65847c6a4ae29872f3ccbc2420f91a8948949b84a06320bdaf2ac281c89ff8a docs(F7b): governance sync — BUILT awaiting Gabriel; carry … Human patch 26 days ago