forked from jsturtevant/copilot-codeact-plugin
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpreflight.ps1
More file actions
61 lines (52 loc) · 1.92 KB
/
Copy pathpreflight.ps1
File metadata and controls
61 lines (52 loc) · 1.92 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
# preflight.ps1 — Windows preflight check for codeact backends
param(
[Parameter(Mandatory=$true)]
[string]$Backend
)
$ErrorActionPreference = "Stop"
function Fail($msg) {
Write-Error "PREFLIGHT FAIL ($Backend): $msg"
exit 1
}
function Warn($msg) {
Write-Warning "PREFLIGHT WARN ($Backend): $msg"
}
# Shared checks
try { $null = Get-Command python3 -ErrorAction Stop } catch { Fail "python3 not found" }
$pyVer = python3 -c "import sys; print(f'{sys.version_info.major}.{sys.version_info.minor}')"
$pyParts = $pyVer -split '\.'
$pyMajor = [int]$pyParts[0]
$pyMinor = [int]$pyParts[1]
if ($pyMajor -lt 3 -or ($pyMajor -eq 3 -and $pyMinor -lt 10)) {
Fail "Python $pyVer too old. Need >=3.10."
}
$hasUv = $null -ne (Get-Command uv -ErrorAction SilentlyContinue)
switch ($Backend) {
"monty" {
if (-not $hasUv) { Warn "uv not found. Will try pip fallback." }
try {
python3 -c "import pydantic_monty" 2>$null
} catch {
if ($hasUv) {
Write-Host "pydantic-monty not installed. Will auto-install via uv." -ForegroundColor Yellow
} else {
Warn "pydantic-monty not installed. Install: pip install pydantic-monty"
}
}
}
"hyperlight" {
if ($pyMajor -gt 3 -or ($pyMajor -eq 3 -and $pyMinor -gt 13)) {
Fail "Python $pyVer too new for hyperlight Wasm. Need <=3.13."
}
$hvEnabled = (Get-WindowsOptionalFeature -Online -FeatureName Microsoft-Hyper-V -ErrorAction SilentlyContinue).State -eq 'Enabled'
if (-not $hvEnabled) {
Fail "Hyper-V not enabled. Hyperlight needs hardware virtualization."
}
if (-not $hasUv) { Warn "uv not found. Will try pip fallback." }
}
default {
Fail "Unknown backend: $Backend. Expected 'monty' or 'hyperlight'."
}
}
Write-Host "Preflight OK: $Backend (Python $pyVer, uv=$hasUv)" -ForegroundColor Green
exit 0