#!/bin/sh
set -eu
root=$(CDPATH= cd -- "$(dirname -- "$0")/.." && pwd)
cd "$root"
if [ "${1:-}" = --system ]; then
    timeout 180 apt-get update
    timeout 240 apt-get install -y gcc g++ gfortran make python3-venv libopenmpi-dev openmpi-bin
fi
python3 -m venv .venv
if [ -d wheelhouse ]; then
    timeout 180 .venv/bin/pip install --no-index --find-links wheelhouse -r requirements-local.lock
else
    timeout 180 .venv/bin/pip install --only-binary=:all: -r requirements-local.lock
fi
timeout 120 .venv/bin/pip install --no-deps --no-build-isolation -e .
mkdir -p tmp
./scripts/sbdart-build
