forked from gradient-industrial-robotics/GradientOS
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstart.sh
More file actions
executable file
·50 lines (41 loc) · 1.97 KB
/
Copy pathstart.sh
File metadata and controls
executable file
·50 lines (41 loc) · 1.97 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
#!/bin/bash
# Activation script that includes system Python packages for camera libraries
# Ensure this script is sourced, not executed
if [[ "${BASH_SOURCE[0]}" == "${0}" ]]; then
echo "This script must be sourced so the environment persists in your current shell."
echo "Run: source ./start.sh"
exit 1
fi
echo 'NOTE: start.sh is intended for manual/legacy setups.'
echo 'If you ran ./setup.sh, activation + install are already handled.'
REPO_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
VENV_ACTIVATE="${REPO_ROOT}/.venv/bin/activate"
if [[ ! -f "${VENV_ACTIVATE}" ]]; then
echo "Missing ${VENV_ACTIVATE}"
echo "Create the single repo virtualenv with ./setup.sh (or uv venv .venv --python python3.12)."
return 1
fi
# Activate the single repo virtual environment
source "${VENV_ACTIVATE}"
cat <<'BANNER'
>>> GradientOS environment bootstrap
>>> - for manual setups that create .venv without running ./setup.sh
>>> - activates the venv and injects camera/project paths
>>> - registers CLI aliases when console scripts are missing
BANNER
# Compute venv site-packages path and place it FIRST in PYTHONPATH to avoid system packages shadowing venv wheels
VENV_SITE=$(python -c "import site; print([p for p in site.getsitepackages() if p.endswith('site-packages')][0])" 2>/dev/null)
export PYTHONPATH="$VENV_SITE:$(pwd)/src:/usr/lib/python3/dist-packages"
echo "Virtual environment activated with system camera libraries"
echo "PYTHONPATH includes: $PYTHONPATH"
# Register CLI aliases only if console scripts are missing
if ! command -v gradient-controller >/dev/null 2>&1; then
alias gradient-vision='python -m gradient_os.vision'
alias gradient-ui='python -m gradient_os.ui_start'
alias gradient-controller='python -m gradient_os.run_controller'
alias gradient-cli='python -m gradient_os.cli_controller'
printf 'CLI aliases registered: %s
' 'gradient-vision gradient-ui gradient-controller gradient-cli'
else
echo 'CLI console scripts already available; aliases not required.'
fi