#!/bin/sh
# Bootstrap the Needle 3 structured data lab on Linux/macOS.
# Usage:  ./bootstrap.sh [--no-serve] [--port 8001]
set -eu
here="$(cd "$(dirname "$0")" && pwd)"
curl -LsSf https://astral.sh/uv/install.sh | sh
export PATH="$HOME/.local/bin:$PATH"
uv python install 311
if [ ! -d .venv ] ; then uv venv .venv --python 311; fi
. .venv/bin/activate
uv pip install cactus-compute fastapi uvicorn
# Pre-fetch the cactus engine and the needle3 weights into the package
# cache (~/.cache/cactus) so the server's first request doesn't wait.
"$here/.venv/bin/cactus" fetch
"$here/.venv/bin/cactus" download needle3
python "$here/bootstrap.py" "$@"
