build: add portable single-file EXE to the build

Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
MrBlakeandClaude Opus 5.5 committed 2026-10-21 13:31:02 +02:00
1 parent 735585c579
commit c42cedd655
3 files changed
+34 -18

No files matched your search

+21 -15
View File
@@ -2,10 +2,16 @@
# Build: python -m PyInstaller --noconfirm --clean NetBoxSynchronizer.spec # Build: python -m PyInstaller --noconfirm --clean NetBoxSynchronizer.spec
# Produces a one-folder build in dist/NetBoxSynchronizer that the Inno Setup # Produces a one-folder build in dist/NetBoxSynchronizer that the Inno Setup
# installer (installer/NetBoxSynchronizer.iss) packages. # installer (installer/NetBoxSynchronizer.iss) packages.
#
# Portable: python -m PyInstaller --noconfirm --clean NetBoxSynchronizer.spec -- --portable
# Produces a single self-extracting "NetBox VM Import.exe".
import re import re
import sys
from pathlib import Path from pathlib import Path
PORTABLE = "--portable" in sys.argv
from PyInstaller.utils.win32.versioninfo import ( from PyInstaller.utils.win32.versioninfo import (
FixedFileInfo, FixedFileInfo,
StringFileInfo, StringFileInfo,
@@ -66,12 +72,7 @@ a.datas = [
pyz = PYZ(a.pure) pyz = PYZ(a.pure)
exe = EXE( EXE_OPTIONS = dict(
pyz,
a.scripts,
[],
exclude_binaries=True,
name="NetBoxSynchronizer",
debug=False, debug=False,
bootloader_ignore_signals=False, bootloader_ignore_signals=False,
strip=False, strip=False,
@@ -86,12 +87,17 @@ exe = EXE(
version=version_info, version=version_info,
) )
coll = COLLECT( if PORTABLE:
exe, exe = EXE(pyz, a.scripts, a.binaries, a.datas, [], name="NetBox VM Import", upx_exclude=[],
a.binaries, runtime_tmpdir=None, **EXE_OPTIONS)
a.datas, else:
strip=False, exe = EXE(pyz, a.scripts, [], exclude_binaries=True, name="NetBoxSynchronizer", **EXE_OPTIONS)
upx=False, coll = COLLECT(
upx_exclude=[], exe,
name="NetBoxSynchronizer", a.binaries,
) a.datas,
strip=False,
upx=False,
upx_exclude=[],
name="NetBoxSynchronizer",
)
+2 -1
View File
@@ -105,4 +105,5 @@ Voraussetzung für den Installer ist [Inno Setup 6](https://jrsoftware.org/isinf
.\build.ps1 -SkipInstaller # nur dist\NetBoxSynchronizer\ .\build.ps1 -SkipInstaller # nur dist\NetBoxSynchronizer\
``` ```
Ergebnis: `dist\installer\NetBoxSynchronizer-Setup-<version>.exe`. Die Version steht in `netbox_sync/__init__.py`. Ergebnis: `dist\installer\NetBoxSynchronizer-Setup-<version>.exe` sowie die portable Variante
`dist\portable\NetBox VM Import.exe` (ohne Installation lauffähig; `-SkipPortable` lässt sie weg). Die Version steht in `netbox_sync/__init__.py`.
+11 -2
View File
@@ -1,15 +1,17 @@
<# <#
.SYNOPSIS .SYNOPSIS
Baut NetBox Synchronizer: Tests, PyInstaller-Build und Inno-Setup-Installer. Baut NetBox Synchronizer: Tests, PyInstaller-Build, Inno-Setup-Installer und portable EXE.
.EXAMPLE .EXAMPLE
.\build.ps1 # alles .\build.ps1 # alles
.\build.ps1 -SkipInstaller # nur dist\NetBoxSynchronizer\ .\build.ps1 -SkipInstaller # nur dist\NetBoxSynchronizer\ (und portable EXE)
.\build.ps1 -SkipPortable # ohne dist\portable\NetBox VM Import.exe
.\build.ps1 -SkipTests .\build.ps1 -SkipTests
#> #>
param( param(
[switch]$SkipTests, [switch]$SkipTests,
[switch]$SkipInstaller, [switch]$SkipInstaller,
[switch]$SkipPortable,
[string]$InnoSetupCompiler [string]$InnoSetupCompiler
) )
@@ -38,6 +40,13 @@ Write-Host "Baue NetBox Synchronizer $version …" -ForegroundColor Cyan
& $python -m PyInstaller --noconfirm --clean --log-level WARN NetBoxSynchronizer.spec & $python -m PyInstaller --noconfirm --clean --log-level WARN NetBoxSynchronizer.spec
if ($LASTEXITCODE) { throw "PyInstaller fehlgeschlagen." } if ($LASTEXITCODE) { throw "PyInstaller fehlgeschlagen." }
if (-not $SkipPortable) {
Write-Host "Baue portable EXE …" -ForegroundColor Cyan
& $python -m PyInstaller --noconfirm --clean --log-level WARN --distpath dist\portable --workpath build\portable NetBoxSynchronizer.spec -- --portable
if ($LASTEXITCODE) { throw "PyInstaller (portabel) fehlgeschlagen." }
Write-Host "Fertig: dist\portable\NetBox VM Import.exe" -ForegroundColor Green
}
if ($SkipInstaller) { if ($SkipInstaller) {
Write-Host "Fertig: dist\NetBoxSynchronizer\NetBoxSynchronizer.exe" -ForegroundColor Green Write-Host "Fertig: dist\NetBoxSynchronizer\NetBoxSynchronizer.exe" -ForegroundColor Green
return return