|
64 | 64 |
|
65 | 65 | log() { echo "[run-kakeya-mac] $*" >&2; } |
66 | 66 |
|
67 | | -# Pinned interpreter (Layer B): prefer KAKEYA_MAC_PYTHON (the venv python with |
68 | | -# mlx_lm/torch/transformers) over a bare python3 that a host reboot may have |
69 | | -# repointed. See docs/skills/pin-selfhosted-runner-python-env-skill.md. |
70 | | -PYBIN="${KAKEYA_MAC_PYTHON:-python3}" |
| 67 | +# Pinned interpreter (Layer B): AUTO-DISCOVER the venv python that actually has |
| 68 | +# mlx_lm (a bare `python3` is often the system/pyenv one without it, especially |
| 69 | +# after a reboot or in a fresh shell). Try KAKEYA_MAC_PYTHON first, then common |
| 70 | +# venv locations, then PATH pythons; pick the first that can `import mlx_lm`. |
| 71 | +# Set KAKEYA_MAC_PYTHON to override. See |
| 72 | +# docs/skills/pin-selfhosted-runner-python-env-skill.md. |
| 73 | +_can_import_mlx_lm() { [ -n "${1:-}" ] && "$1" -c 'import mlx_lm' >/dev/null 2>&1; } |
| 74 | +_resolve_pybin() { |
| 75 | + local c |
| 76 | + for c in \ |
| 77 | + "${KAKEYA_MAC_PYTHON:-}" \ |
| 78 | + "$repo_root/.venv-mac/bin/python3.13" \ |
| 79 | + "$repo_root/.venv-mac/bin/python" \ |
| 80 | + "$repo_root/.venv/bin/python" \ |
| 81 | + "$HOME/kakeya-venv/bin/python" \ |
| 82 | + "$HOME/.venv/bin/python" \ |
| 83 | + "$(command -v python3.13 2>/dev/null || true)" \ |
| 84 | + "$(command -v python3 2>/dev/null || true)"; do |
| 85 | + if _can_import_mlx_lm "$c"; then printf '%s' "$c"; return 0; fi |
| 86 | + done |
| 87 | + # Nothing with mlx_lm — fall back to a sensible value so dry-run/preflight can |
| 88 | + # still report a clear error. |
| 89 | + printf '%s' "${KAKEYA_MAC_PYTHON:-python3}" |
| 90 | + return 1 |
| 91 | +} |
| 92 | +PYBIN="$(_resolve_pybin)" || true |
| 93 | +log "python : $PYBIN$([ -n "${KAKEYA_MAC_PYTHON:-}" ] && echo ' (KAKEYA_MAC_PYTHON)')" |
71 | 94 |
|
72 | 95 | # ---- argv for the full-engine harness chat ---- |
73 | 96 | args=( |
@@ -107,9 +130,11 @@ if [[ "$DRY_RUN" == "1" ]]; then |
107 | 130 | fi |
108 | 131 |
|
109 | 132 | # ---- preflight (Apple Silicon + MLX + model) ---- |
110 | | -command -v "$PYBIN" >/dev/null 2>&1 || { log "interpreter not found: $PYBIN (set KAKEYA_MAC_PYTHON)"; exit 1; } |
111 | 133 | "$PYBIN" -c "import mlx.core, mlx_lm" 2>/dev/null \ |
112 | | - || { log "mlx/mlx_lm not importable by $PYBIN — Apple Silicon + a venv with 'mlx mlx-lm'; set KAKEYA_MAC_PYTHON. See docs/skills/pin-selfhosted-runner-python-env-skill.md"; exit 2; } |
| 134 | + || { log "no Python with mlx_lm found (auto-searched KAKEYA_MAC_PYTHON, "\ |
| 135 | +"$repo_root/.venv-mac, ~/kakeya-venv, ~/.venv, python3.13, python3; tried '$PYBIN'). "\ |
| 136 | +"Activate your MLX venv or set KAKEYA_MAC_PYTHON=/path/to/venv/bin/python "\ |
| 137 | +"(needs 'mlx mlx-lm torch transformers'). See docs/skills/pin-selfhosted-runner-python-env-skill.md"; exit 2; } |
113 | 138 | [[ -d "$VERIFIER" ]] \ |
114 | 139 | || { log "verifier model dir not found: $VERIFIER (set KAKEYA_MAC_VERIFIER_PATH)"; exit 3; } |
115 | 140 | if [[ "$FAST" != "1" && ! -e "$FTHETA" ]]; then |
|
0 commit comments