Robust config search and ZIP packaging

This commit is contained in:
joel
2026-07-20 18:14:19 +02:00
parent eb222dd2ca
commit cb13fd8d2b
2 changed files with 27 additions and 5 deletions
+21
View File
@@ -84,8 +84,29 @@ def build():
if config_src.exists(): if config_src.exists():
shutil.copy(config_src, dist_dir / "config.json") shutil.copy(config_src, dist_dir / "config.json")
# ZIP-Archiv für das Release erstellen
import tempfile
zip_name = f"fcco-Converter-{system.lower()}"
zip_path = dist_dir / zip_name
with tempfile.TemporaryDirectory() as tmpdir:
tmp = Path(tmpdir)
# App/Exe ins Temp-Verzeichnis kopieren
if system == "Darwin":
shutil.copytree(dist_dir / f"{app_name}.app", tmp / f"{app_name}.app")
else:
shutil.copy(dist_dir / f"{app_name}.exe", tmp / f"{app_name}.exe")
# config.json mit in die ZIP packen
if config_src.exists():
shutil.copy(config_src, tmp / "config.json")
shutil.make_archive(str(zip_path), 'zip', str(tmp))
print() print()
print(f"Build erfolgreich! Ausgabe in: {dist_dir}") print(f"Build erfolgreich! Ausgabe in: {dist_dir}")
print(f"ZIP für Release: {zip_path}.zip")
else: else:
print() print()
print(f"Build fehlgeschlagen (Code {result.returncode}).") print(f"Build fehlgeschlagen (Code {result.returncode}).")
+6 -5
View File
@@ -23,11 +23,12 @@ def _load_app_info():
try: try:
# Finde config.json relativ zum Skript oder im PyInstaller Bundle # Finde config.json relativ zum Skript oder im PyInstaller Bundle
if getattr(sys, "frozen", False): if getattr(sys, "frozen", False):
if platform.system() == "Darwin": # Suche ausgehend von der Executable aufwärts nach config.json
# Path(sys.executable) ist fcco-Converter.app/Contents/MacOS/executable base_dir = Path(sys.executable).parent
base_dir = Path(sys.executable).parent.parent.parent.parent while base_dir.name and str(base_dir) != base_dir.root:
else: if (base_dir / "config.json").exists():
base_dir = Path(sys.executable).parent break
base_dir = base_dir.parent
else: else:
base_dir = Path(__file__).parent.parent base_dir = Path(__file__).parent.parent