forked from jsturtevant/copilot-codeact-plugin
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpreflight.sh
More file actions
executable file
·81 lines (67 loc) · 2.61 KB
/
Copy pathpreflight.sh
File metadata and controls
executable file
·81 lines (67 loc) · 2.61 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
#!/usr/bin/env bash
# preflight.sh — verify a codeact backend runtime is usable
# Usage: preflight.sh <backend>
# Exit 0 if usable, non-zero with diagnostic on failure.
set -euo pipefail
BACKEND="${1:?Usage: preflight.sh <backend>}"
fail() { echo "PREFLIGHT FAIL ($BACKEND): $*" >&2; exit 1; }
warn() { echo "PREFLIGHT WARN ($BACKEND): $*" >&2; }
# --- shared checks ---
command -v bash >/dev/null 2>&1 || fail "bash not found"
command -v python3 >/dev/null 2>&1 || fail "python3 not found"
PY_VERSION=$(python3 -c 'import sys; print(f"{sys.version_info.major}.{sys.version_info.minor}")')
PY_MAJOR=$(echo "$PY_VERSION" | cut -d. -f1)
PY_MINOR=$(echo "$PY_VERSION" | cut -d. -f2)
if (( PY_MAJOR < 3 || (PY_MAJOR == 3 && PY_MINOR < 10) )); then
fail "Python $PY_VERSION too old. Need >=3.10."
fi
HAS_UV=false
if command -v uv >/dev/null 2>&1; then
HAS_UV=true
fi
case "$BACKEND" in
monty)
if [[ "$HAS_UV" != "true" ]]; then
warn "uv not found. Will try pip fallback for pydantic-monty install."
fi
# Check if pydantic-monty is importable or installable
if ! python3 -c "import pydantic_monty" 2>/dev/null; then
if [[ "$HAS_UV" == "true" ]]; then
echo "pydantic-monty not installed. Will auto-install via uv run --with." >&2
else
warn "pydantic-monty not installed. Install with: pip install pydantic-monty"
fi
fi
;;
hyperlight)
# macOS check
if [[ "$(uname -s)" == "Darwin" ]]; then
fail "Hyperlight not supported on macOS. Use monty backend."
fi
# Python version ceiling
if (( PY_MAJOR > 3 || (PY_MAJOR == 3 && PY_MINOR > 13) )); then
fail "Python $PY_VERSION too new for hyperlight Wasm backend. Need <=3.13. Use: uv run --python 3.13 ..."
fi
# KVM/mshv check on Linux
if [[ "$(uname -s)" == "Linux" ]]; then
if [[ ! -r /dev/kvm ]] && [[ ! -r /dev/mshv ]]; then
fail "Neither /dev/kvm nor /dev/mshv readable. Hyperlight needs hardware virtualization."
fi
fi
if [[ "$HAS_UV" != "true" ]]; then
warn "uv not found. Will try pip fallback for hyperlight-sandbox install."
fi
if ! python3 -c "from hyperlight_sandbox import Sandbox" 2>/dev/null; then
if [[ "$HAS_UV" == "true" ]]; then
echo "hyperlight-sandbox not installed. Will auto-install via uv run --with." >&2
else
warn "hyperlight-sandbox not installed. Install with: pip install 'hyperlight-sandbox[wasm,python_guest]>=0.3.0'"
fi
fi
;;
*)
fail "Unknown backend: $BACKEND. Expected 'monty' or 'hyperlight'."
;;
esac
echo "Preflight OK: $BACKEND (Python $PY_VERSION, uv=$HAS_UV)" >&2
exit 0