Repository navigation
Expand file tree
/
Copy pathrun_developer_setup.sh
More file actions
executable file
·82 lines (66 loc) · 2.44 KB
/
Copy pathrun_developer_setup.sh
File metadata and controls
executable file
·82 lines (66 loc) · 2.44 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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
#!/usr/bin/env bash
set -euo pipefail
REPO_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
cd "$REPO_ROOT"
# Target env resolution: an explicit VENV_DIR wins; otherwise an ACTIVATED
# virtualenv is respected (install into the env the developer already uses,
# rather than forcing a repo-local .venv); only with neither do we fall back
# to creating ./.venv. PYTHON_BIN is consulted only if the env must be created.
VENV_DIR="${VENV_DIR:-${VIRTUAL_ENV:-.venv}}"
PYTHON_BIN="${PYTHON_BIN:-python3.12}"
VENV_PYTHON="$VENV_DIR/bin/python"
echo "[eval_audit] repo root: $REPO_ROOT"
echo "[eval_audit] target environment: $VENV_DIR"
need_cmd() {
if ! command -v "$1" >/dev/null 2>&1; then
echo "error: required command not found: $1" >&2
exit 1
fi
}
need_cmd git
need_cmd uv
echo "[eval_audit] syncing submodules"
git submodule sync --recursive
git submodule update --init --recursive
if [[ ! -x "$VENV_PYTHON" ]]; then
echo "[eval_audit] creating virtual environment at $VENV_DIR"
uv venv "$VENV_DIR" --python "$PYTHON_BIN"
else
echo "[eval_audit] reusing existing virtual environment at $VENV_DIR"
fi
echo "[eval_audit] upgrading packaging tools"
uv pip install --python "$VENV_PYTHON" --upgrade pip setuptools wheel
echo "[eval_audit] installing root package in editable mode"
uv pip install --python "$VENV_PYTHON" -e .
install_editable_pkg() {
local pkg_path="$1"
if [[ ! -d "$pkg_path" ]]; then
echo "[eval_audit] skipping missing path: $pkg_path"
return 0
fi
if [[ -f "$pkg_path/pyproject.toml" || -f "$pkg_path/setup.py" || -f "$pkg_path/setup.cfg" ]]; then
echo "[eval_audit] installing editable package: $pkg_path"
uv pip install --python "$VENV_PYTHON" -e "$pkg_path"
else
echo "[eval_audit] skipping non-python submodule: $pkg_path"
fi
}
if [[ -f .gitmodules ]]; then
echo "[eval_audit] discovering submodules from .gitmodules"
declare -A seen_paths=()
while IFS= read -r sm_path; do
[[ -n "${seen_paths[$sm_path]:-}" ]] && continue
seen_paths["$sm_path"]=1
install_editable_pkg "$sm_path"
done < <(git config --file .gitmodules --get-regexp path | awk '{print $2}')
else
echo "[eval_audit] no .gitmodules found"
fi
echo
echo "[eval_audit] setup complete"
echo "venv python: $VENV_PYTHON"
echo "activate with:"
echo " source $VENV_DIR/bin/activate"
echo
echo "sanity check:"
echo " $VENV_PYTHON -m eval_audit.cli.check_env"