-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathSetup-EXDA-MAC.command
More file actions
141 lines (120 loc) · 3.96 KB
/
Setup-EXDA-MAC.command
File metadata and controls
141 lines (120 loc) · 3.96 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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
#!/usr/bin/env bash
set -u
REPO_ROOT="$(cd "$(dirname "$0")" && pwd)"
cd "$REPO_ROOT" || exit 1
PYTHON_CMD=""
activate_local_venv() {
if [ ! -f "$REPO_ROOT/.venv/bin/activate" ]; then
return 1
fi
# shellcheck disable=SC1091
. "$REPO_ROOT/.venv/bin/activate" || return 1
PYTHON_CMD="$REPO_ROOT/.venv/bin/python"
return 0
}
prepend_path_if_dir() {
local candidate="$1"
[ -d "$candidate" ] || return 0
case ":$PATH:" in
*":$candidate:"*) return 0 ;;
esac
PATH="$candidate:$PATH"
}
seed_gui_path() {
prepend_path_if_dir "/opt/homebrew/bin"
prepend_path_if_dir "/usr/local/bin"
prepend_path_if_dir "/usr/bin"
prepend_path_if_dir "/bin"
prepend_path_if_dir "$HOME/.local/bin"
prepend_path_if_dir "$HOME/bin"
prepend_path_if_dir "$HOME/.nvm/current/bin"
}
print_header() {
echo "========================================"
echo "EXDA Setup (macOS)"
echo "========================================"
}
pause_on_exit() {
if [ -t 0 ]; then
read -r -p "Press Enter to exit..." _
fi
}
fail() {
echo ""
echo "Setup failed: $1"
echo ""
pause_on_exit
exit 1
}
sanitize_local_venv() {
if [ -d "$REPO_ROOT/.venv" ]; then
find "$REPO_ROOT/.venv" -name '._*' -type f -delete >/dev/null 2>&1 || true
if command -v dot_clean >/dev/null 2>&1; then
dot_clean -m "$REPO_ROOT/.venv" >/dev/null 2>&1 || true
fi
fi
}
archive_broken_venv() {
if [ ! -d "$REPO_ROOT/.venv" ]; then
return 0
fi
local archived_path="$REPO_ROOT/.venv.broken-$(date +%Y%m%d-%H%M%S)"
mv "$REPO_ROOT/.venv" "$archived_path" || return 1
echo "Archived incompatible local virtualenv to $archived_path"
}
resolve_python() {
sanitize_local_venv
if [ -x "$REPO_ROOT/.venv/bin/python" ]; then
local detected_prefix=""
detected_prefix="$("$REPO_ROOT/.venv/bin/python" -c "import sys; print(sys.prefix)" 2>/dev/null || true)"
if [ "$detected_prefix" = "$REPO_ROOT/.venv" ]; then
PYTHON_CMD="$REPO_ROOT/.venv/bin/python"
return 0
fi
archive_broken_venv || return 1
fi
command -v python3 >/dev/null 2>&1 || return 1
echo "Creating local .venv ..."
python3 -m venv "$REPO_ROOT/.venv" || return 1
sanitize_local_venv
PYTHON_CMD="$REPO_ROOT/.venv/bin/python"
return 0
}
verify_node_packages() {
node -e "require.resolve('vite/package.json'); require.resolve('react/package.json'); require.resolve('react-dom/package.json')" >/dev/null 2>&1
}
verify_python_requirements() {
"$PYTHON_CMD" scripts/check_runtime_requirements.py --requirements "$1" >/dev/null 2>&1
}
print_header
seed_gui_path
command -v node >/dev/null 2>&1 || fail "Missing tool: node"
command -v npm >/dev/null 2>&1 || fail "Missing tool: npm"
resolve_python || fail "Missing tool: python3"
activate_local_venv || fail "Could not activate the local .venv"
echo ""
echo "Installing frontend dependencies with npm ..."
npm install || fail "npm install failed"
verify_node_packages || fail "Frontend packages are still incomplete after npm install"
echo ""
echo "Upgrading pip in local .venv ..."
"$PYTHON_CMD" -m pip install --upgrade pip >/dev/null 2>&1 || fail "Could not upgrade pip in .venv"
echo "Installing backend requirements ..."
"$PYTHON_CMD" -m pip install -r backend/requirements.txt || fail "Failed to install backend/requirements.txt"
sanitize_local_venv
verify_python_requirements backend/requirements.txt || fail "Backend Python requirements are still incomplete"
echo "Installing optional feature requirements ..."
"$PYTHON_CMD" -m pip install -r backend/requirements-optional.txt || fail "Failed to install backend/requirements-optional.txt"
sanitize_local_venv
verify_python_requirements backend/requirements-optional.txt || fail "Optional Python requirements are still incomplete"
echo ""
echo "EXDA setup is complete."
echo ""
echo "The EXDA launcher uses .venv automatically."
echo "If you want this terminal itself to stay activated afterward, run:"
echo " source .venv/bin/activate"
echo ""
echo "Next step:"
echo " Run-EXDA-MAC.command"
echo ""
pause_on_exit