#!/usr/bin/env bash
set -euo pipefail

cd "$(dirname "$0")/.."

PYTHON=""
for candidate in \
  /Library/Frameworks/Python.framework/Versions/3.12/bin/python3 \
  /usr/local/bin/python3 \
  /usr/bin/python3 \
  python3
do
  if command -v "$candidate" >/dev/null 2>&1 && "$candidate" - <<'PY' >/dev/null 2>&1
import tkinter
PY
  then
    PYTHON="$candidate"
    break
  fi
done

if [[ -z "$PYTHON" ]]; then
  echo "No Python with Tkinter found. Install python.org Python 3, then retry." >&2
  exit 1
fi

exec "$PYTHON" scripts/deploy_gui.py
