diff --git a/NetBoxSynchronizer.spec b/NetBoxSynchronizer.spec index c17fc9d..c34b9bc 100644 --- a/NetBoxSynchronizer.spec +++ b/NetBoxSynchronizer.spec @@ -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,12 +87,17 @@ exe = EXE( version=version_info, ) -coll = COLLECT( - exe, - a.binaries, - a.datas, - strip=False, - upx=False, - upx_exclude=[], - name="NetBoxSynchronizer", -) +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, + strip=False, + upx=False, + upx_exclude=[], + name="NetBoxSynchronizer", + ) diff --git a/README.md b/README.md index d2c0e90..c0191f5 100644 --- a/README.md +++ b/README.md @@ -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-.exe`. Die Version steht in `netbox_sync/__init__.py`. +Ergebnis: `dist\installer\NetBoxSynchronizer-Setup-.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`. diff --git a/build.ps1 b/build.ps1 index 029ff5d..e92c8e7 100644 --- a/build.ps1 +++ b/build.ps1 @@ -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