-
-
Notifications
You must be signed in to change notification settings - Fork 13
Expand file tree
/
Copy pathbuild.ps1
More file actions
81 lines (61 loc) · 2.32 KB
/
Copy pathbuild.ps1
File metadata and controls
81 lines (61 loc) · 2.32 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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
$ErrorActionPreference = "Stop"
<#
UpdateRootCertificates build script
Dependencies (required on build machine)
Python
- Python 2.7 (32-bit)
Path expected:
C:\Python27\python.exe
or
C:\Program Files (x86)\Python27\python.exe
Python packages
- pip 20.3.4 (last version supporting Python 2.7)
- pyinstaller 3.4 (last reliable version for Windows XP compatibility)
Install via:
python -m pip install pip==20.3.4 pyinstaller==3.4
Microsoft VC++ Runtime (VC90)
- Bundled automatically by PyInstaller via win_private_assemblies=True in the spec
- No manual step required
Output
- Final distributable:
dist\UpdateRootCertificates.exe
- Single self-contained executable (PyInstaller onefile)
- No external dependencies required on target system (including XP)
Notes
- Built EXE targets Windows XP through Windows 11
#>
# -- Paths ---------------------------------------------------------------------
$scriptDir = $PSScriptRoot
# Python
$py = "C:\Python27\python.exe"
if (-not (Test-Path $py)) {
$py = "C:\Program Files (x86)\Python27\python.exe"
}
if (-not (Test-Path $py)) {
throw "Python 2.7 not found"
}
$env:PYTHONHOME = Split-Path $py
$env:PYTHONPATH = ""
$pyBits = & $py -c "import struct; print(struct.calcsize('P') * 8)"
if ($pyBits -ne "32") {
throw "Python at $py is $pyBits-bit. A 32-bit Python 2.7 is required to produce an XP-compatible binary."
}
# Output
$distDir = Join-Path $scriptDir "dist"
$outputExe = Join-Path $distDir "UpdateRootCertificates.exe"
# -- Clean ---------------------------------------------------------------------
Remove-Item $distDir -Recurse -Force -ErrorAction SilentlyContinue
New-Item -ItemType Directory -Path $distDir -Force | Out-Null
# -- Install deps --------------------------------------------------------------
& $py "-m" "pip" "install" "pip==20.3.4"
if ($LASTEXITCODE -ne 0) { throw "pip upgrade failed" }
& $py "-m" "pip" "install" "pyinstaller==3.4"
if ($LASTEXITCODE -ne 0) { throw "pyinstaller install failed" }
# -- Build EXE -----------------------------------------------------------------
$spec = Join-Path $scriptDir "UpdateRootCertificatesApp.spec"
& $py "-m" "PyInstaller" "--clean" $spec
if ($LASTEXITCODE -ne 0) { throw "PyInstaller failed" }
if (-not (Test-Path $outputExe)) {
throw "EXE not found after build: $outputExe"
}
Write-Output "Done: $outputExe"