#!/usr/bin/env bash
# Build the native extension wheel inside a Rust container.
# Output is written to <project-root>/dist/ (gitignored).
# Can be run from any directory.
set -euo pipefail

PROJECT_ROOT="$(cd "$(dirname "$0")/.." && pwd)"

mkdir -p "$PROJECT_ROOT/dist"

docker run --rm \
  -v "$PROJECT_ROOT":/project \
  -w /project \
  rust:1.93.1-trixie \
  bash -c "
    set -euo pipefail
    apt-get update -qq
    apt-get install -y -qq python3 python3-pip python3-venv
    python3 -m venv /opt/maturin-venv
    /opt/maturin-venv/bin/pip install --quiet -r docker/requirements-build.txt
    /opt/maturin-venv/bin/maturin build --release --out dist
  "
