-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstart.ps1
More file actions
48 lines (43 loc) · 1.77 KB
/
Copy pathstart.ps1
File metadata and controls
48 lines (43 loc) · 1.77 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
$ErrorActionPreference = "Stop"
Set-Location $PSScriptRoot
$python = $null
foreach ($candidate in @("py", "python3", "python")) {
try {
if ($candidate -eq "py") {
& py -3 -c "import sys; raise SystemExit(sys.version_info < (3, 11))" 2>$null
if ($LASTEXITCODE -eq 0) { $python = @("py", "-3"); break }
} else {
& $candidate -c "import sys; raise SystemExit(sys.version_info < (3, 11))" 2>$null
if ($LASTEXITCODE -eq 0) { $python = @($candidate); break }
}
} catch {}
}
if (-not $python) {
throw "Operra requires Python 3.11 or newer. Install it from https://www.python.org/downloads/"
}
if (-not (Test-Path ".venv\Scripts\python.exe")) {
Write-Host "Creating Operra's local Python environment..."
if ($python.Length -gt 1) {
& $python[0] $python[1] -m venv .venv
} else {
& $python[0] -m venv .venv
}
}
$venvPython = ".venv\Scripts\python.exe"
$hash = (Get-FileHash requirements.txt -Algorithm SHA256).Hash.ToLowerInvariant()
$stamp = ".venv\.operra-requirements"
$installed = if (Test-Path $stamp) { (Get-Content $stamp -Raw).Trim() } else { "" }
if ($hash -ne $installed) {
Write-Host "Installing Operra dependencies..."
& $venvPython -m pip install --disable-pip-version-check -r requirements.txt
Set-Content -Path $stamp -Value $hash
}
if (-not $env:OPERRA_HOME) {
$env:OPERRA_HOME = Join-Path $env:USERPROFILE "Operra"
}
$port = if ($env:PORT) { $env:PORT } else { "8848" }
New-Item -ItemType Directory -Force -Path $env:OPERRA_HOME | Out-Null
Write-Host "Operra is ready: http://127.0.0.1:$port"
Write-Host "Workspace: $env:OPERRA_HOME"
Write-Host "Press Ctrl+C to stop."
& $venvPython -m uvicorn app.api.server:app --host 127.0.0.1 --port $port --log-level warning