-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.ps1
More file actions
64 lines (56 loc) · 2.81 KB
/
Copy pathbuild.ps1
File metadata and controls
64 lines (56 loc) · 2.81 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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
# Build the standalone artifacts into dist\.
#
# dist\compare-tool.exe ONE file, needs NOTHING installed on the target --
# CLI + side-by-side viewer together, carrying the
# app icon and the viewer's image resources:
# compare-tool.exe <old> <new> CLI + HTML report (exit 0/1/2)
# compare-tool.exe --qt <old> <new> viewer, folders loaded
# double-click viewer (drop the folders in)
# Built as a CONSOLE app so terminal runs keep stdout
# and the exit code; the viewer hides the console
# window at runtime (see packaging\entry.py).
#
# dist\compare_tool.pyz optional tiny zipapp for machines that
# already have Python 3.8+. Stdlib only, so the CLI
# works anywhere; the viewer additionally needs
# PySide6 installed on that machine.
#
# Usage:
# .\build.ps1 # exe only (needs pyinstaller + PySide6 locally)
# .\build.ps1 -Pyz # exe + zipapp
# .\build.ps1 -PyzOnly # zipapp only (no PyInstaller / PySide6 needed)
param([switch]$Pyz, [switch]$PyzOnly)
$ErrorActionPreference = 'Stop'
Set-Location $PSScriptRoot
New-Item -ItemType Directory -Force dist | Out-Null
# --- zipapp (.pyz) ---
if ($Pyz -or $PyzOnly) {
$entry = @'
import sys
from compare_tool.main import main
sys.exit(main())
'@
$stage = 'build\zipapp'
if (Test-Path $stage) { Remove-Item -Recurse -Force $stage }
New-Item -ItemType Directory -Force $stage | Out-Null
Copy-Item compare_tool $stage -Recurse
Get-ChildItem $stage -Recurse -Directory -Filter __pycache__ |
Remove-Item -Recurse -Force
Set-Content "$stage\__main__.py" $entry -Encoding ascii
python -m zipapp $stage -o dist\compare_tool.pyz -c
if ($LASTEXITCODE -ne 0) { throw 'zipapp build failed' }
Write-Host 'OK dist\compare_tool.pyz (run: python compare_tool.pyz <old> <new>)'
}
# --- PyInstaller onefile (.exe): CLI + viewer in one binary ---
if (-not $PyzOnly) {
python -m pip install --upgrade pyinstaller "PySide6>=6.5"
if ($LASTEXITCODE -ne 0) { throw 'installing build dependencies failed' }
python -m PyInstaller --noconfirm --clean packaging\compare-tool.spec
if ($LASTEXITCODE -ne 0) { throw 'pyinstaller build failed' }
$exe = Join-Path $PSScriptRoot 'dist\compare-tool.exe'
if (-not (Test-Path $exe)) { throw "build finished but $exe is missing" }
$mb = [math]::Round((Get-Item $exe).Length / 1MB, 1)
Write-Host "OK dist\compare-tool.exe ($mb MB)"
Write-Host ' CLI: compare-tool.exe <old> <new>'
Write-Host ' viewer: compare-tool.exe --qt <old> <new> (or double-click)'
}