#!/usr/bin/env python3 """ Build-Skript für Windows-Distribution von DocuMentor Erstellt: 1. Eigenständige Executable mit PyInstaller 2. Optional: ZIP-Archiv für portable Distribution """ import shutil import subprocess import sys from pathlib import Path from datetime import datetime def main(): project_root = Path(__file__).parent dist_dir = project_root / "dist" build_dir = project_root / "build" resources_dir = project_root / "resources" icon_path = resources_dir / "icon.ico" version_info_path = project_root / "version_info.txt" print("=" * 60) print("DocuMentor Windows Build") print("=" * 60) # 1. Icon und Versionsinformationen generieren print("\n[1/6] Icon und Versionsinformationen generieren...") # Icon erstellen falls nicht vorhanden if not icon_path.exists(): print(" Erstelle Standard-Icon...") try: subprocess.run([sys.executable, "create_icon.py"], check=True, cwd=project_root) print(" ✓ Icon erstellt") except subprocess.CalledProcessError as e: print(f" ✗ Icon-Erstellung fehlgeschlagen: {e}") print(" ⚠ Fahre ohne Icon fort...") else: print(f" ✓ Icon vorhanden: {icon_path.name}") # Versionsinformationen erstellen print(" Erstelle Versionsinformationen...") try: subprocess.run([sys.executable, "create_version_info.py"], check=True, cwd=project_root) print(" ✓ Versionsinformationen erstellt") except subprocess.CalledProcessError as e: print(f" ✗ Versionsinformationen-Erstellung fehlgeschlagen: {e}") print(" ⚠ Fahre ohne Versionsinformationen fort...") # 2. Cleanup alter Builds print("\n[2/6] Cleanup alter Builds...") if dist_dir.exists(): shutil.rmtree(dist_dir) print(" ✓ dist/ gelöscht") if build_dir.exists(): shutil.rmtree(build_dir) print(" ✓ build/ gelöscht") # 3. PyInstaller ausführen print("\n[3/6] PyInstaller Build starten...") try: subprocess.run( ["pyinstaller", "--clean", "DocuMentor.spec"], check=True, cwd=project_root ) print(" ✓ Build erfolgreich") except subprocess.CalledProcessError as e: print(f" ✗ Build fehlgeschlagen: {e}") return 1 # 4. README für Distribution erstellen print("\n[4/6] README erstellen...") readme_content = """DocuMentor - XSL-Transformations-Verwaltung ============================================ Installation: 1. Entpacken Sie dieses Archiv in ein Verzeichnis Ihrer Wahl 2. Führen Sie DocuMentor.exe aus Externe Abhängigkeiten (separat zu installieren): - Java Runtime Environment (JRE) oder JDK - Apache FOP (für PDF-Generierung) - Saxon XSLT-Prozessor (JAR-Datei) - diff-pdf (für PDF-Vergleiche) Beim ersten Start werden Sie aufgefordert, die Pfade zu diesen Tools in den Programmeinstellungen zu konfigurieren. Konfiguration und Logs: - Windows: %APPDATA%\\DocuMentor\\ - Konfiguration: config.json - Logs: logs\\ Support: Bei Fragen oder Problemen erstellen Sie bitte ein Issue auf GitHub. """ readme_path = dist_dir / "DocuMentor" / "README.txt" readme_path.write_text(readme_content, encoding='utf-8') print(" ✓ README.txt erstellt") # 5. Icon ins dist-Verzeichnis kopieren (für Installer) print("\n[5/6] Icon für Installer vorbereiten...") if icon_path.exists(): dist_icon = dist_dir / "DocuMentor" / "icon.ico" shutil.copy2(icon_path, dist_icon) print(" ✓ Icon kopiert") else: print(" ⚠ Kein Icon vorhanden") # 6. ZIP-Archiv erstellen print("\n[6/6] ZIP-Archiv erstellen...") timestamp = datetime.now().strftime("%Y%m%d") zip_name = f"DocuMentor-{timestamp}-Windows" zip_path = dist_dir / zip_name shutil.make_archive( str(zip_path), 'zip', dist_dir, 'DocuMentor' ) print(f" ✓ {zip_name}.zip erstellt") print("\n" + "=" * 60) print("Build abgeschlossen!") print("=" * 60) print(f"\nErgebnisse:") print(f" • Executable: dist/DocuMentor/DocuMentor.exe") print(f" • ZIP-Archiv: dist/{zip_name}.zip") print("\nNächste Schritte:") print(" 1. Testen Sie DocuMentor.exe auf einem Windows-System") print(" 2. Optional: Erstellen Sie einen Installer mit Inno Setup") return 0 if __name__ == "__main__": sys.exit(main())