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

ROOT_DIR="$(cd "$(dirname "$0")" && pwd)"
VENV_DIR="${ROOT_DIR}/.venv-macos"
PYTHON_BIN="${PYTHON_BIN:-python3.11}"
cd "${ROOT_DIR}"

echo "[aurora-native] root: ${ROOT_DIR}"
echo "[aurora-native] python: ${PYTHON_BIN}"

if ! command -v "${PYTHON_BIN}" >/dev/null 2>&1; then
  echo "[aurora-native] error: ${PYTHON_BIN} not found"
  exit 1
fi

if ! command -v ffmpeg >/dev/null 2>&1; then
  echo "[aurora-native] error: ffmpeg is required (brew install ffmpeg)"
  exit 1
fi

if [ ! -d "${VENV_DIR}" ]; then
  "${PYTHON_BIN}" -m venv "${VENV_DIR}"
fi

source "${VENV_DIR}/bin/activate"
python -m pip install --upgrade pip setuptools wheel
python -m pip install -r "${ROOT_DIR}/requirements.txt"

echo "[aurora-native] setup complete: ${VENV_DIR}"
