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
+27 -11

No files matched your search

+14 -8
View File
@@ -2,10 +2,16 @@
# Build: python -m PyInstaller --noconfirm --clean NetBoxSynchronizer.spec
# Produces a one-folder build in dist/NetBoxSynchronizer that the Inno Setup
# 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 sys
from pathlib import Path
PORTABLE = "--portable" in sys.argv
from PyInstaller.utils.win32.versioninfo import (
FixedFileInfo,
StringFileInfo,
@@ -66,12 +72,7 @@ a.datas = [
pyz = PYZ(a.pure)
exe = EXE(
pyz,
a.scripts,
[],
exclude_binaries=True,
name="NetBoxSynchronizer",
EXE_OPTIONS = dict(
debug=False,
bootloader_ignore_signals=False,
strip=False,
@@ -86,7 +87,12 @@ exe = EXE(
version=version_info,
)
coll = COLLECT(
if PORTABLE:
exe = EXE(pyz, a.scripts, a.binaries, a.datas, [], name="NetBox VM Import", upx_exclude=[],
runtime_tmpdir=None, **EXE_OPTIONS)
else:
exe = EXE(pyz, a.scripts, [], exclude_binaries=True, name="NetBoxSynchronizer", **EXE_OPTIONS)
coll = COLLECT(
exe,
a.binaries,
a.datas,
@@ -94,4 +100,4 @@ coll = COLLECT(
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\
```
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
Baut NetBox Synchronizer: Tests, PyInstaller-Build und Inno-Setup-Installer.
Baut NetBox Synchronizer: Tests, PyInstaller-Build, Inno-Setup-Installer und portable EXE.
.EXAMPLE
.\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
#>
param(
[switch]$SkipTests,
[switch]$SkipInstaller,
[switch]$SkipPortable,
[string]$InnoSetupCompiler
)
@@ -38,6 +40,13 @@ Write-Host "Baue NetBox Synchronizer $version …" -ForegroundColor Cyan
& $python -m PyInstaller --noconfirm --clean --log-level WARN NetBoxSynchronizer.spec
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) {
Write-Host "Fertig: dist\NetBoxSynchronizer\NetBoxSynchronizer.exe" -ForegroundColor Green
return