-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathinstall_sidepit
More file actions
executable file
·68 lines (60 loc) · 2.23 KB
/
Copy pathinstall_sidepit
File metadata and controls
executable file
·68 lines (60 loc) · 2.23 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
#!/usr/bin/env bash
# install_sidepit — set up the client, then hand back one command: `sidepit`.
#
# Safe to run more than once: it re-checks the environment and brings
# dependencies up to date. It never touches your keys (~/.sidepit is left
# exactly as it is).
set -euo pipefail
ROOT="$(cd -P "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
VENV="$ROOT/python-client/.venv"
BIN="${HOME}/.local/bin"
say() { printf ' %s\n' "$*"; }
echo
echo "sidepit — installing the client"
echo
# 1. Python
if ! command -v python3 >/dev/null 2>&1; then
echo "sidepit: python3 not found. Install Python 3.10+ and run this again." >&2
exit 1
fi
ver="$(python3 -c 'import sys; print("%d.%d" % sys.version_info[:2])')"
case "$ver" in
3.1[0-9]|3.[2-9][0-9]) ;; # 3.10+
*) echo "sidepit: Python $ver found, 3.10+ required." >&2; exit 1 ;;
esac
say "python $ver"
# 2. Virtual environment + dependencies
if [ ! -x "$VENV/bin/python" ]; then
say "creating the environment…"
python3 -m venv "$VENV"
fi
say "installing dependencies…"
"$VENV/bin/pip" install --quiet --upgrade pip
"$VENV/bin/pip" install --quiet -r "$ROOT/python-client/requirements.txt"
"$VENV/bin/pip" install --quiet -r "$ROOT/users-cli/requirements.txt"
# the SDK itself, editable: `sidepit_trader` must be importable from any
# directory, and -e keeps a git pull live without reinstalling
"$VENV/bin/pip" install --quiet -e "$ROOT"
# 3. Prove it works before promising anything — import exactly what the app
# needs, from a directory that is NOT the repo, so a stray sys.path entry
# cannot make a broken install look fine.
if ! (cd / && "$VENV/bin/python" -c "import textual, qrcode, pynng, sidepit_trader") 2>/dev/null; then
echo "sidepit: dependencies did not install cleanly — see the output above." >&2
exit 1
fi
say "toolchain OK"
# 4. Put `sidepit` on the PATH (a symlink, so git pulls stay live)
chmod +x "$ROOT/sidepit"
mkdir -p "$BIN"
ln -sf "$ROOT/sidepit" "$BIN/sidepit"
say "installed: $BIN/sidepit"
echo
if command -v sidepit >/dev/null 2>&1; then
echo "Ready. Run: sidepit"
else
echo "Ready. Run: $ROOT/sidepit"
echo
echo "(To type just 'sidepit' from anywhere, add this to your shell profile:)"
echo " export PATH=\"\$HOME/.local/bin:\$PATH\""
fi
echo