-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstart.sh
More file actions
executable file
·49 lines (41 loc) · 1.64 KB
/
Copy pathstart.sh
File metadata and controls
executable file
·49 lines (41 loc) · 1.64 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
#!/usr/bin/env bash
# Operra public-source launcher. Creates an isolated Python environment on first run.
set -euo pipefail
ROOT="$(cd "$(dirname "$0")" && pwd)"
cd "$ROOT"
PYTHON_BIN=""
for candidate in python3.13 python3.12 python3.11 python3; do
if command -v "$candidate" >/dev/null 2>&1; then
if "$candidate" -c 'import sys; raise SystemExit(sys.version_info < (3, 11))'; then
PYTHON_BIN="$candidate"
break
fi
fi
done
if [[ -z "$PYTHON_BIN" ]]; then
echo "Operra requires Python 3.11 or newer." >&2
echo "Install Python from https://www.python.org/downloads/ and run ./start.sh again." >&2
exit 1
fi
if [[ ! -x .venv/bin/python ]]; then
echo "Creating Operra's local Python environment..."
"$PYTHON_BIN" -m venv .venv
fi
REQUIREMENTS_HASH="$(".venv/bin/python" -c 'import hashlib, pathlib; print(hashlib.sha256(pathlib.Path("requirements.txt").read_bytes()).hexdigest())')"
INSTALLED_HASH="$(test -f .venv/.operra-requirements && tr -d '\r\n' < .venv/.operra-requirements || true)"
if [[ "$REQUIREMENTS_HASH" != "$INSTALLED_HASH" ]]; then
echo "Installing Operra dependencies..."
.venv/bin/python -m pip install --disable-pip-version-check -r requirements.txt
printf '%s\n' "$REQUIREMENTS_HASH" > .venv/.operra-requirements
fi
export OPERRA_HOME="${OPERRA_HOME:-$HOME/Operra}"
PORT="${PORT:-8848}"
if [[ "${1:-}" == "--fast" || "${1:-}" == "fast" ]]; then
export OPERRA_LUI_AGENT=0
fi
mkdir -p "$OPERRA_HOME"
echo "Operra is ready: http://127.0.0.1:$PORT"
echo "Workspace: $OPERRA_HOME"
echo "Press Ctrl+C to stop."
exec .venv/bin/python -m uvicorn app.api.server:app \
--host 127.0.0.1 --port "$PORT" --log-level warning