Recently Written · git

desktop-subtitle-replay

git clone https://github.com/equwal/desktop-subtitle-replay

Log | Files | Refs


setup.ps1 (1089 bytes)

1 # One-time setup: creates .venv and installs dependencies.
2 $ErrorActionPreference = "Stop"
3 Set-Location $PSScriptRoot
4 
5 $py = $null
6 foreach ($cand in @("py -3.11", "py -3.12", "py -3", "python")) {
7     $parts = $cand.Split(" ")
8     $exe = $parts[0]
9     $rest = $parts[1..($parts.Length - 1)]
10     try {
11         $v = & $exe @rest -c "import sys;print('%d.%d'%sys.version_info[:2])" 2>$null
12         if ($LASTEXITCODE -eq 0 -and $v) {
13             $minor = [int]($v.Split(".")[1])
14             if ($minor -ge 9 -and $minor -le 12) { $py = $cand; Write-Host "Using Python $v ($cand)"; break }
15         }
16     } catch { }
17 }
18 if (-not $py) { throw "Need Python 3.9-3.12. Install 3.11 from python.org and re-run." }
19 
20 $parts = $py.Split(" ")
21 & $parts[0] @($parts[1..($parts.Length - 1)]) -m venv .venv
22 
23 & ".\.venv\Scripts\python.exe" -m pip install --upgrade pip --quiet
24 & ".\.venv\Scripts\python.exe" -m pip install -r requirements.txt
25 
26 Write-Host ""
27 Write-Host "Done. Next:" -ForegroundColor Green
28 Write-Host "  .\run.ps1 --list-devices"
29 Write-Host "  .\run.ps1 --selftest 12"
30 Write-Host "  .\run.ps1"