$ErrorActionPreference = 'Stop' $project = $PSScriptRoot $venv = Join-Path $project '.venv_gui' $py = Join-Path $venv 'Scripts\python.exe' Push-Location $project try { if (-not (Test-Path -LiteralPath $py)) { & py -3 -m venv $venv if ($LASTEXITCODE -ne 0) { throw "venv failed: $LASTEXITCODE" } } & $py -m pip install -q --upgrade pip pyinstaller pyserial if ($LASTEXITCODE -ne 0) { throw "pip failed: $LASTEXITCODE" } & $py -m PyInstaller --noconfirm --clean --workpath gui_build --distpath dist nand_put_gui.spec if ($LASTEXITCODE -ne 0) { throw "PyInstaller failed: $LASTEXITCODE" } $exe = Join-Path $project 'dist\NAND_Xfer.exe' if (-not (Test-Path -LiteralPath $exe)) { throw "Missing $exe" } Write-Host "GUI exe: $exe" } finally { Pop-Location }