64 lines
2.4 KiB
PowerShell
64 lines
2.4 KiB
PowerShell
param(
|
|
[string]$EnvName = "sensor-bench-build-py310"
|
|
)
|
|
|
|
$ErrorActionPreference = "Stop"
|
|
|
|
$RepoRoot = Resolve-Path (Join-Path $PSScriptRoot "..")
|
|
$DistDir = Join-Path $RepoRoot "dist"
|
|
$WorkDir = Join-Path $RepoRoot "build\pyinstaller_work"
|
|
$SpecPath = Join-Path $PSScriptRoot "sensor_bench.spec"
|
|
$RepoConfig = Join-Path $RepoRoot "config"
|
|
$RepoSensors = Join-Path $RepoRoot "sensors"
|
|
|
|
if (-not (Get-Command conda -ErrorAction SilentlyContinue)) {
|
|
throw "conda was not found on PATH. Open an Anaconda Prompt or initialize conda for PowerShell."
|
|
}
|
|
|
|
Push-Location $RepoRoot
|
|
try {
|
|
conda run -n $EnvName python -m pip install --upgrade pip
|
|
if ($LASTEXITCODE -ne 0) { throw "pip upgrade failed in env '$EnvName'." }
|
|
|
|
conda run -n $EnvName python -m pip install -e ".[pack]"
|
|
if ($LASTEXITCODE -ne 0) { throw "Editable install failed in env '$EnvName'." }
|
|
|
|
conda run -n $EnvName python -m pip install --upgrade orisys
|
|
if ($LASTEXITCODE -ne 0) { throw "orisys install failed in env '$EnvName'." }
|
|
|
|
# Sync Orisys wheel sensor configs into repo config/ before packaging.
|
|
conda run -n $EnvName python build/sync_wheel_configs.py
|
|
if ($LASTEXITCODE -ne 0) { throw "Config sync failed." }
|
|
|
|
conda run -n $EnvName python tests/test_smoke.py
|
|
if ($LASTEXITCODE -ne 0) { throw "Smoke tests failed." }
|
|
|
|
if (Test-Path $WorkDir) {
|
|
Remove-Item -Recurse -Force $WorkDir
|
|
}
|
|
if (Test-Path (Join-Path $DistDir "SensorBench")) {
|
|
Remove-Item -Recurse -Force (Join-Path $DistDir "SensorBench")
|
|
}
|
|
|
|
conda run -n $EnvName python -m PyInstaller --noconfirm --clean --distpath "$DistDir" --workpath "$WorkDir" "$SpecPath"
|
|
if ($LASTEXITCODE -ne 0) { throw "PyInstaller failed." }
|
|
|
|
# Public package only: copy exhibition config/ and sensors/. Never ship internal/ operator assets.
|
|
Copy-Item -Recurse -Force $RepoConfig (Join-Path $DistDir "SensorBench")
|
|
if (Test-Path $RepoSensors) {
|
|
Copy-Item -Recurse -Force $RepoSensors (Join-Path $DistDir "SensorBench")
|
|
}
|
|
$InternalLeak = Join-Path $DistDir "SensorBench\internal"
|
|
if (Test-Path $InternalLeak) {
|
|
throw "Public dist must not contain internal/: $InternalLeak"
|
|
}
|
|
|
|
conda run -n $EnvName python build/verify_dist.py
|
|
if ($LASTEXITCODE -ne 0) { throw "Distribution verification failed." }
|
|
|
|
Write-Host "Build complete: dist\SensorBench\SensorBench.exe"
|
|
}
|
|
finally {
|
|
Pop-Location
|
|
}
|