36 lines
1.0 KiB
Bash
Executable File
36 lines
1.0 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# Prepare the virtual environment and install dependencies.
|
|
# Usage: bash scripts/bootstrap.sh
|
|
|
|
set -euo pipefail
|
|
|
|
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]:-${0}}")" && pwd)"
|
|
PROJECT_ROOT="$(cd "${SCRIPT_DIR}/.." && pwd)"
|
|
VENV_DIR="${PROJECT_ROOT}/.venv"
|
|
PYTHON_BIN="${PYTHON_BIN:-python3}"
|
|
|
|
if ! command -v "${PYTHON_BIN}" >/dev/null 2>&1; then
|
|
echo "Python interpreter '${PYTHON_BIN}' not found. Set PYTHON_BIN to override." >&2
|
|
exit 1
|
|
fi
|
|
|
|
if [ ! -d "${VENV_DIR}" ]; then
|
|
echo "Creating virtual environment at ${VENV_DIR}"
|
|
"${PYTHON_BIN}" -m venv "${VENV_DIR}"
|
|
else
|
|
echo "Reusing existing virtual environment at ${VENV_DIR}"
|
|
fi
|
|
|
|
"${VENV_DIR}/bin/python" -m pip install --upgrade pip
|
|
REQ_FILE="${PROJECT_ROOT}/requirements.txt"
|
|
if [ -f "${REQ_FILE}" ]; then
|
|
"${VENV_DIR}/bin/pip" install -r "${REQ_FILE}"
|
|
else
|
|
echo "requirements.txt not found at ${REQ_FILE}" >&2
|
|
fi
|
|
|
|
cat <<'EOF'
|
|
Virtual environment ready.
|
|
Use the helper scripts in scripts/ to run the app, tests, or build artefacts.
|
|
EOF
|