#!/bin/bash
set -e
cd "$(dirname "$(realpath "$0")")"


py_ver="3.12.4"


mkdir -p ".toolchain"
export PYENV_ROOT="$PWD/.toolchain/pyenv"


if ! [ -f "$PYENV_ROOT/versions/$py_ver/bin/python" ]
then
    echo ""
    echo "[setup.sh] Installing pyenv."
    curl https://pyenv.run | bash > /dev/null
    alias pyenv="$PYENV_ROOT/bin/pyenv"


    echo ""
    echo "[setup.sh] Installing python $py_ver."
    echo "           This takes a few minutes. ☕"
    echo ""
    pyenv install "$py_ver"
fi


alias python="$PYENV_ROOT/versions/$py_ver/bin/python"


python -m venv venv
. venv/bin/activate


pip install -r requirements.txt
