#!/usr/bin/env bash
# SwiftCanvas CPU-only launcher for Linux / macOS (no NVIDIA GPU required).
set -e
cd "$(dirname "$0")"

PY="${PYTHON:-}"
if [ -z "$PY" ]; then
    if [ -x ".venv/bin/python" ]; then PY=".venv/bin/python"
    elif [ -x "venv/bin/python" ]; then PY="venv/bin/python"
    elif command -v python3 >/dev/null 2>&1; then PY="python3"
    elif command -v python >/dev/null 2>&1; then PY="python"
    else
        echo "[ERROR] Python not found. Install Python 3.10+ first." >&2
        exit 1
    fi
fi

echo "Using Python: $PY (CPU-only mode, 512x512 may take 10-30 minutes)"
echo "Starting SwiftCanvas... Open browser: http://127.0.0.1:7871"
exec "$PY" app.py --cpu "$@"