build: add portable single-file EXE to the build
Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
1 parent
735585c579
commit
c42cedd655
3 files changed
+25
-9
No files matched your search
+12
-6
@@ -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,6 +87,11 @@ exe = EXE(
|
||||
version=version_info,
|
||||
)
|
||||
|
||||
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,
|
||||
|
||||
@@ -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`.
|
||||
@@ -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
|
||||
|
||||
Reference in new issue
Block a user