set -eou pipefail

export VENV="${VENV:-.venv}"
export CARGO_TARGET_DIR="${CARGO_TARGET_DIR:-target}"

rm /etc/yum.repos.d/fedora-cisco-openh264.repo || true

dnf install --setopt=install_weak_deps=false -y rustup clang lld "${PYTHON_PACKAGE}" python3-uv nettle clang clang-devel nettle-devel pcsc-lite-devel

rustup-init --default-toolchain "${RUST_TOOLCHAIN}-${TARGET}" --profile minimal --component rust-src -y
source "${HOME}/.cargo/env"

mkdir -p .cargo
cp ci/config.toml .cargo/config.toml

cargo fetch --target="${TARGET}" &

rm -rf "${VENV}"
uv venv --python "${PYTHON}" "${VENV}"
source "${VENV}/bin/activate"

uv pip install --upgrade "maturin>=1,<2" -r requirements-dev.txt
