-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathInstall-PythonGuardianRuntime.ps1
More file actions
43 lines (40 loc) · 2.14 KB
/
Copy pathInstall-PythonGuardianRuntime.ps1
File metadata and controls
43 lines (40 loc) · 2.14 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
<# Build the dedicated, non-global Python Guardian Codex runtime. #>
[CmdletBinding()]
param([string]$Python)
Set-StrictMode -Version Latest
$ErrorActionPreference = 'Stop'
$runtime = Join-Path $PSScriptRoot 'guardian_venv'
if (-not $Python) {
$candidates = @()
$direct = Get-Command python.exe -ErrorAction SilentlyContinue
if ($direct) { $candidates += $direct.Source }
$launcher = Get-Command py.exe -ErrorAction SilentlyContinue
if ($launcher) {
foreach ($requestedVersion in '-3.13', '-3.12', '-3.11', '-3.10', '-3') {
try {
$found = & $launcher.Source $requestedVersion -c 'import sys; print(sys.executable)' 2>$null
if ($LASTEXITCODE -eq 0 -and $found) { $candidates += $found; break }
} catch { }
}
}
$Python = $candidates | Where-Object { Test-Path -LiteralPath $_ -PathType Leaf } |
Select-Object -First 1
}
if (-not $Python -or -not (Test-Path -LiteralPath $Python -PathType Leaf)) {
throw 'Python 3.10 or newer was not found. Install Python from python.org, then run this installer again.'
}
$version = & $Python -c 'import sys; print(f"{sys.version_info.major}.{sys.version_info.minor}")'
if ([version]$version -lt [version]'3.10') { throw "Python 3.10+ is required; found $version" }
if (-not (Test-Path -LiteralPath (Join-Path $runtime 'Scripts\python.exe'))) {
& $Python -m venv $runtime
if ($LASTEXITCODE) { throw 'Python could not create the Guardian virtual environment.' }
}
$runtimePython = Join-Path $runtime 'Scripts\python.exe'
# SDK b3 pins an older CLI, but gpt-5.6-sol rejects it. CLI 0.144.4 has been
# exercised against the b3 app-server protocol by the Guardian integration test.
& $runtimePython -m pip install 'openai-codex==0.1.0b3'
if ($LASTEXITCODE) { throw 'Could not install the OpenAI Codex Python SDK.' }
& $runtimePython -m pip install --upgrade --no-deps 'openai-codex-cli-bin==0.144.4'
if ($LASTEXITCODE) { throw 'Could not install the compatible Codex CLI runtime.' }
& $runtimePython -c "from openai_codex import Codex, CodexConfig; print('Guardian Codex SDK import: OK')"
Write-Output "Python Guardian runtime ready: $runtime"