#!/usr/bin/env bash # LM-Gambit launcher (macOS / Linux). # # First run creates a virtual environment beside this script and installs the # dependencies into it; later runs skip straight to starting the app. # # The environment is built on YOUR machine rather than shipped prebuilt, and # that is the whole point: llama-cpp-python is a compiled package whose GPU # support is baked in at install time. A prebuilt bundle would freeze one # choice — almost certainly CPU-only — for everybody. Installing here means pip # picks the build that matches this machine. # # For NVIDIA, AMD or Apple GPU acceleration, see GPU-ACCELERATION.md. set -euo pipefail HERE="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" cd "$HERE" VENV="$HERE/.venv" PYTHON_MIN="3.10" find_python() { for candidate in python3.13 python3.12 python3.11 python3.10 python3 python; do if command -v "$candidate" >/dev/null 2>&1; then if "$candidate" -c "import sys; raise SystemExit(0 if sys.version_info >= (3, 10) else 1)" 2>/dev/null; then echo "$candidate" return 0 fi fi done return 1 } if [ ! -x "$VENV/bin/python" ]; then echo "First run — setting up. This takes a few minutes and happens once." echo if ! PYTHON="$(find_python)"; then cat >&2 </dev/null; then cat >&2 <&2 <