forked from isaac-sim/IsaacLab
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·123 lines (106 loc) · 3.21 KB
/
Copy pathinstall.sh
File metadata and controls
executable file
·123 lines (106 loc) · 3.21 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
#!/usr/bin/env bash
set -euo pipefail
# IsaacLab installer
# - Optionally installs this repo as a Python package if pyproject.toml is installable
# - Installs a persistent 'lab' command under ~/.local/bin to run docker/runner.py
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd -P)"
REPO_DIR="${SCRIPT_DIR}"
echo "[IsaacLab] Running installer from ${REPO_DIR}"
# Args
FORCE_REINSTALL=false
print_usage() {
cat <<USAGE
Usage: $(basename "$0") [options]
Options:
-f, --force Force reinstall the 'lab' command wrapper
-h, --help Show this help and exit
USAGE
}
while [[ $# -gt 0 ]]; do
case "$1" in
-f|--force)
FORCE_REINSTALL=true
shift
;;
-h|--help)
print_usage
exit 0
;;
*)
echo "[ERROR] Unknown option: $1" >&2
print_usage
exit 2
;;
esac
done
# Choose Python
PY="${PYTHON:-python3}"
if ! command -v "$PY" >/dev/null 2>&1; then
if command -v /bin/python3 >/dev/null 2>&1; then
PY="/bin/python3"
else
echo "[ERROR] python3 not found. Please install Python 3 and re-run." >&2
exit 1
fi
fi
install_pyproject() {
local pfile="${REPO_DIR}/pyproject.toml"
if [[ ! -f "$pfile" ]]; then
echo "[INFO] No pyproject.toml found. Skipping Python package install."
return 0
fi
# Determine if the pyproject declares a build system (required to install via pip)
if grep -qE '^\[build-system\]' "$pfile" || grep -qE '^\[tool.poetry\]' "$pfile"; then
echo "[INFO] Detected installable pyproject.toml. Installing package (editable)…"
"$PY" -m pip install --user -e "$REPO_DIR"
else
echo "[INFO] pyproject.toml present but no build-system section found. Skipping package install."
fi
}
install_lab_command() {
local target_dir="${HOME}/.local/bin"
local wrapper_path="${target_dir}/lab"
mkdir -p "$target_dir"
# Skip reinstall unless forced and wrapper already exists
if [[ -f "$wrapper_path" && "${FORCE_REINSTALL}" != true ]]; then
echo "[INFO] 'lab' command already exists at ${wrapper_path}. Use --force to reinstall."
else
if [[ -f "$wrapper_path" ]]; then
cp -f "$wrapper_path" "${wrapper_path}.bak" || true
fi
cat > "$wrapper_path" <<EOF
#!/usr/bin/env bash
set -euo pipefail
# Auto-generated by IsaacLab install.sh
REPO_DIR="${REPO_DIR}"
PY="\${PYTHON:-python3}"
if ! command -v "\${PY}" >/dev/null 2>&1; then
PY="/bin/python3"
fi
cd "${REPO_DIR}"
exec "\${PY}" docker/runner.py "\$@"
EOF
chmod +x "$wrapper_path"
echo "[OK] Installed/updated 'lab' at ${wrapper_path}"
fi
# Ensure ~/.local/bin on PATH for future shells
local bashrc="${HOME}/.bashrc"
local add_path_line='export PATH="$HOME/.local/bin:$PATH"'
if ! grep -qs "^${add_path_line//\//\/}$" "$bashrc" 2>/dev/null; then
{
echo ""
echo "# Added by IsaacLab installer (lab command)"
echo "$add_path_line"
} >> "$bashrc"
echo "[INFO] Added ~/.local/bin to PATH in ${bashrc}"
fi
}
# Step 1: install Python package (optional)
install_pyproject
# Step 2: install the 'lab' command
install_lab_command
echo "[Done] Install complete."
if ! command -v lab >/dev/null 2>&1; then
echo "[INFO] To start using 'lab' now, run: source \"${HOME}/.bashrc\""
fi
echo "[INFO] Try: lab (interactive)"