-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup.sourceme
More file actions
100 lines (85 loc) · 3.7 KB
/
Copy pathsetup.sourceme
File metadata and controls
100 lines (85 loc) · 3.7 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
# SPDX-FileCopyrightText: 2026 Real-Time Innovations, Inc.
# SPDX-License-Identifier: Apache-2.0
##########
# Set up the Python environment for the tractor fleet comparison demo.
#
# Usage:
# source setup.sourceme # install all dependencies
# source setup.sourceme grpc # install only gRPC approach deps
# source setup.sourceme dds # install only DDS approach deps
# source setup.sourceme grpc-dds # install hybrid approach deps
#
# Environment variables you can override:
# PYTHON – Python interpreter (default: python3)
# VENV_DIR – venv directory name (default: venv)
# NDDSHOME – RTI Connext DDS installation directory
# (auto-detected in /Applications, /opt, or $HOME)
# This file is sourced, not executed. Never use set -e/-u/-o pipefail at the
# top level — those options propagate to the interactive shell and cause it to
# exit on any error. We use explicit error checking instead.
# Find repo root as the directory containing this file (works in bash and zsh)
if [ -n "${BASH_SOURCE[0]+x}" ]; then
REPO_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
else
REPO_ROOT="$(cd "$(dirname "$0")" && pwd)"
fi
cd "$REPO_ROOT"
APPROACH="${1:-all}"
REQS_FILE="$REPO_ROOT/requirements/${APPROACH}.txt"
if [ ! -f "$REQS_FILE" ]; then
echo "Unknown approach: $APPROACH"
echo "Available:"
for f in "$REPO_ROOT"/requirements/*.txt; do
echo " $(basename "$f" .txt)"
done
return 1 2>/dev/null || exit 1
fi
PYTHON="${PYTHON:-python3}"
VENV_DIR="${VENV_DIR:-venv}"
# ── Connext installation path ───────────────────────────────────────────────
# Auto-detect NDDSHOME if not set.
if [ -z "${NDDSHOME:-}" ]; then
for _d in /Applications /opt "$HOME"; do
[ -d "$_d/rti_connext_dds-7.7.0" ] && NDDSHOME="$_d/rti_connext_dds-7.7.0" && break
done
unset _d
fi
if [ -z "${NDDSHOME:-}" ] || [[ ! -d "$NDDSHOME" ]]; then
echo "ERROR: RTI Connext DDS 7.7.0 not found."
echo " Set NDDSHOME to your installation directory, e.g.:"
echo " export NDDSHOME=/opt/rti_connext_dds-7.7.0"
return 1 2>/dev/null || exit 1
fi
export NDDSHOME
export RTI_MONITORING2_ENABLE=TRUE
# ─────────────────────────────────────────────────────────────────────────
# Require Python >= 3.14.3
PY_VERSION=$($PYTHON -c 'import sys; print(f"{sys.version_info.major}.{sys.version_info.minor}.{sys.version_info.micro}")')
PY_OK=$($PYTHON -c 'import sys; print(1 if sys.version_info >= (3,14,3) else 0)')
if [ "$PY_OK" -ne 1 ]; then
echo "ERROR: Python >= 3.14.3 is required (found $PY_VERSION from '$PYTHON')"
echo " Set PYTHON to a supported interpreter, e.g.:"
echo " PYTHON=python3.14 source setup.sourceme $APPROACH"
return 1 2>/dev/null || exit 1
fi
if [ ! -d "$VENV_DIR" ]; then
"$PYTHON" -m venv "$VENV_DIR" --prompt venv
fi
# shellcheck disable=SC1091
source "$VENV_DIR/bin/activate"
python -m pip install --upgrade pip setuptools wheel
# macOS: pybullet's bundled zlib redefines fdopen which clashes with
# the Apple SDK _stdio.h header. This flag suppresses the TARGET_OS_*
# macros that trigger the conflict.
if [[ "$(uname)" == "Darwin" ]]; then
export CFLAGS="${CFLAGS:-} -fno-define-target-os-macros"
fi
# Install dependencies (rti.connext is available on PyPI)
python -m pip install -r "$REQS_FILE"
echo ""
echo "Environment ready for: $APPROACH"
echo " Python: $(which python)"
echo " venv: $REPO_ROOT/$VENV_DIR"
if [ -n "${NDDSHOME:-}" ]; then
echo " NDDSHOME: $NDDSHOME"
fi