From cb13fd8d2b89ed612eefd9daaf699480132e4a29 Mon Sep 17 00:00:00 2001 From: joel Date: Mon, 20 Jul 2026 18:14:19 +0200 Subject: [PATCH] Robust config search and ZIP packaging --- build.py | 21 +++++++++++++++++++++ fcco_converter/config.py | 11 ++++++----- 2 files changed, 27 insertions(+), 5 deletions(-) diff --git a/build.py b/build.py index 87877c9..4e9dbc2 100644 --- a/build.py +++ b/build.py @@ -84,8 +84,29 @@ def build(): if config_src.exists(): 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(f"Build erfolgreich! Ausgabe in: {dist_dir}") + print(f"ZIP für Release: {zip_path}.zip") else: print() print(f"Build fehlgeschlagen (Code {result.returncode}).") diff --git a/fcco_converter/config.py b/fcco_converter/config.py index f8d309c..e3c220b 100644 --- a/fcco_converter/config.py +++ b/fcco_converter/config.py @@ -23,11 +23,12 @@ def _load_app_info(): try: # Finde config.json relativ zum Skript oder im PyInstaller Bundle if getattr(sys, "frozen", False): - if platform.system() == "Darwin": - # Path(sys.executable) ist fcco-Converter.app/Contents/MacOS/executable - base_dir = Path(sys.executable).parent.parent.parent.parent - else: - base_dir = Path(sys.executable).parent + # Suche ausgehend von der Executable aufwärts nach config.json + base_dir = Path(sys.executable).parent + while base_dir.name and str(base_dir) != base_dir.root: + if (base_dir / "config.json").exists(): + break + base_dir = base_dir.parent else: base_dir = Path(__file__).parent.parent