#!/usr/bin/env bash
set -euo pipefail
ROOT=$(cd -- "$(dirname -- "$0")" && pwd)
PYTHON=${PYTHON:-python3.11}
cd "$ROOT"
sha256sum --check --quiet SHA256SUMS
"$PYTHON" - <<'PY'
import platform, sys
if sys.version_info[:2] != (3, 11) or platform.system() != 'Linux' or platform.machine() != 'x86_64':
    raise SystemExit('This wheel bundle requires Linux x86_64 with Python 3.11 and venv support.')
PY
"$PYTHON" -m venv "$ROOT/.venv"
"$ROOT/.venv/bin/python" -m pip install --no-index --find-links "$ROOT/wheels" --requirement "$ROOT/requirements.lock"
"$ROOT/.venv/bin/python" -m pip check
"$ROOT/bin/semgrep" --version
printf '\nInstalled. Add to PATH: export PATH="%s/bin:$PATH"\n' "$ROOT"
