-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup_python.sh
More file actions
executable file
·34 lines (30 loc) · 1.17 KB
/
setup_python.sh
File metadata and controls
executable file
·34 lines (30 loc) · 1.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#!/usr/bin/env bash
#
# setup_python.sh
# ----------------
# Creates a Python virtual environment in ./tools/venv/ and installs
# pipeline dependencies from requirements.txt.
#
# Outputs:
# tools/venv/ — Python virtual environment with dependencies installed
#
set -euo pipefail
PROJECT_DIR="$(cd "$(dirname "$0")" && pwd)"
VENV_DIR="${PROJECT_DIR}/tools/venv"
REQUIREMENTS="${PROJECT_DIR}/requirements.txt"
# ---------------------------------------------------------------------------
# Create venv (skip if it already exists)
# ---------------------------------------------------------------------------
if [[ -d "${VENV_DIR}" ]]; then
echo " [skip] Python venv already exists at ${VENV_DIR}"
else
echo " [create] Python venv at ${VENV_DIR} ..."
python3 -m venv "${VENV_DIR}"
fi
# ---------------------------------------------------------------------------
# Install / update dependencies
# ---------------------------------------------------------------------------
echo " [install] Python dependencies from requirements.txt ..."
"${VENV_DIR}/bin/pip" install --quiet --upgrade pip
"${VENV_DIR}/bin/pip" install --quiet -r "${REQUIREMENTS}"
echo "==> Python setup complete."