#!/bin/sh -e

# Use the Python executable provided from the `-p` option, or a default.
[ "$1" = "-p" ] && PYTHON=$2 || PYTHON="python3"

REQUIREMENTS="requirements/test.txt"
VENV="venv"

set -x

if [ -z "$GITHUB_ACTIONS" ]; then
    "$PYTHON" -m venv "$VENV"
    PIP="$VENV/bin/pip"
else
    PIP="pip"
fi

if [ -n "$GITHUB_ACTIONS" ] && [ "x$USE_CYTHON" = "xtrue" ] ; then
    $PIP install Cython
    FAST="[fast]"
fi

"$PIP" install -r "$REQUIREMENTS"
"$PIP" install -e .${FAST}
