# Build a standalone PDFDupTool.exe for sharing (no Python required on target PCs). # Uses a dedicated venv so optional packages on your machine are not bundled into the exe. # # Usage (PowerShell, from this folder): # powershell -ExecutionPolicy Bypass -File .\build_windows.ps1 $ErrorActionPreference = "Stop" $Root = $PSScriptRoot Set-Location $Root $VenvDir = Join-Path $Root ".venv-build" $Python = Join-Path $VenvDir "Scripts\python.exe" $PyInstaller = Join-Path $VenvDir "Scripts\pyinstaller.exe" if (-not (Test-Path $Python)) { Write-Host "Creating clean build venv at $VenvDir ..." py -3 -m venv $VenvDir } Write-Host "Installing dependencies into build venv ..." & $Python -m pip install -r (Join-Path $Root "requirements.txt") & $Python -m pip install -r (Join-Path $Root "requirements-build.txt") Write-Host "Running PyInstaller (this may take a minute) ..." & $PyInstaller --noconfirm --clean (Join-Path $Root "PDFDupTool.spec") $VerLine = Get-Content (Join-Path $Root "version_info.py") -Raw if ($VerLine -match "APP_VERSION\s*=\s*['`"]([^'`"]+)['`"]") { $AppVer = $Matches[1] } else { $AppVer = "unknown" } $Out = Join-Path $Root "dist\PDFDupTool-$AppVer.exe" if (Test-Path $Out) { $mb = [math]::Round((Get-Item $Out).Length / 1MB, 2) Write-Host "" Write-Host "Done. Output: $Out ($mb MB)" Write-Host "Share that file, or zip the dist folder." } else { Write-Host "Build finished but PDFDupTool.exe was not found under dist\." exit 1 }