# Windows Distribution Guide für DocuMentor ## Überblick Dieses Dokument beschreibt, wie DocuMentor für Windows-Benutzer ohne Python-Installation verpackt wird. ## Voraussetzungen ### Auf dem Entwicklungssystem ```bash # Dependencies installieren (inkl. PyInstaller) uv sync --all-groups ``` ### Für Setup.exe (optional) - **Inno Setup**: Download von https://jrsoftware.org/isdl.php - Oder **WiX Toolset** für MSI: https://wixtoolset.org/ ## Build-Prozess ### Option 1: Einfacher Build (ZIP-Distribution) ```bash # 1. PyInstaller installieren uv sync --all-groups # 2. Build ausführen uv run python build_windows.py ``` Dies erstellt: - `dist/DocuMentor/DocuMentor.exe` - Eigenständige Executable - `dist/DocuMentor-YYYYMMDD-Windows.zip` - Portable ZIP-Archiv ### Option 2: Professionelle Setup.exe mit Inno Setup ```bash # 1. PyInstaller Build uv run python build_windows.py # 2. Inno Setup Compiler ausführen iscc installer.iss ``` Dies erstellt: - `dist/installer/DocuMentor-Setup-0.1.0.exe` - Professioneller Installer ### Option 3: MSI-Installer mit WiX ```bash # TODO: WiX-Konfiguration noch zu erstellen ``` ## Manuelle Schritte ### 1. PyInstaller direkt verwenden ```bash # Cleanup rm -rf build/ dist/ # Build uv run pyinstaller --clean DocuMentor.spec # Testen dist/DocuMentor/DocuMentor.exe ``` ### 2. Anpassungen vornehmen **Icon hinzufügen:** 1. Icon-Datei (`.ico`) im Projekt speichern, z.B. `resources/icon.ico` 2. In `DocuMentor.spec` anpassen: ```python icon='resources/icon.ico' ``` **Versionsinformationen:** In `DocuMentor.spec` erweitern: ```python exe = EXE( # ... version='version_info.txt', # Windows-Versionsinformationen ) ``` ## PyInstaller .spec Konfiguration Die Datei `DocuMentor.spec` enthält: - **datas**: UI-Dateien (.ui) werden mitgepackt - **hiddenimports**: Alle notwendigen PySide6/Polars-Module - **console=False**: GUI-Anwendung ohne Konsole - **upx=True**: Kompression der Binaries ### Wichtige Einstellungen ```python # Ein-Datei-Build (alles in einer .exe) exe = EXE( pyz, a.scripts, a.binaries, # Diese Zeilen a.zipfiles, # auskommentieren a.datas, # für One-File # ... onefile=True, # Hinzufügen ) ``` **Achtung**: One-File-Build ist langsamer beim Start, da alles temporär entpackt werden muss. ## Distribution ### ZIP-Archive ```bash # Automatisch durch build_windows.py erstellt dist/DocuMentor-YYYYMMDD-Windows.zip ``` **Vorteile:** - Einfach, portable - Keine Installation nötig - Kann auf USB-Stick verwendet werden **Nachteile:** - Keine Deinstallationsroutine - Keine Verknüpfungen - Keine Registry-Einträge ### Setup.exe mit Inno Setup **Vorteile:** - Professionell - Deinstallation integriert - Start-Menü und Desktop-Icons - Update-Mechanismus möglich **Nachteile:** - Benötigt Administrator-Rechte (optional) - Komplexere Konfiguration ### MSI-Installer **Vorteile:** - Windows-Standard - Gruppen-Richtlinien-fähig - Silent Installation möglich **Nachteile:** - Komplexe Erstellung - Benötigt WiX Toolset ## Externe Abhängigkeiten DocuMentor benötigt diese Tools (NICHT im Installer enthalten): 1. **Java Runtime Environment (JRE) 11+** - Für Saxon und Apache FOP - Download: https://adoptium.net/ 2. **Apache FOP** - XSL-FO zu PDF Konvertierung - Download: https://xmlgraphics.apache.org/fop/ 3. **Saxon XSLT Prozessor** - XSLT 2.0/3.0 Transformationen - Download: https://www.saxonica.com/ 4. **diff-pdf** - PDF-Vergleich - Download: https://vslavik.github.io/diff-pdf/ ### Benutzer-Anleitung Nach der Installation: 1. DocuMentor starten 2. Beim ersten Start öffnet sich automatisch die Einstellungen 3. Pfade zu Java, Saxon, FOP und diff-pdf konfigurieren 4. Projekt-Verzeichnis wählen oder neues Projekt erstellen ## Testing ### Lokales Testing (Linux/WSL) ```bash # Build für Windows erstellen uv run python build_windows.py # Executable mit Wine testen (falls verfügbar) wine dist/DocuMentor/DocuMentor.exe ``` ### Testing auf Windows 1. ZIP auf Windows-System kopieren 2. Entpacken 3. `DocuMentor.exe` ausführen 4. Alle Features testen: - Projekt öffnen/erstellen - Tree-Navigation - PDF-Generierung - Einstellungen ## Troubleshooting ### Problem: "Module not found" Fehler **Lösung**: Hidden imports in `DocuMentor.spec` ergänzen: ```python hiddenimports=[ # ... existing 'missing_module', ] ``` ### Problem: UI-Dateien nicht gefunden **Lösung**: Prüfen ob datas korrekt konfiguriert: ```python datas=[ ('src/ui/*.ui', 'ui'), ] ``` ### Problem: Executable zu groß **Lösungen**: 1. UPX-Kompression aktivieren (bereits aktiv) 2. Excludes hinzufügen für ungenutzte Module: ```python excludes=['tkinter', 'matplotlib', 'test', 'unittest'] ``` 3. One-File-Build verwenden (langsamer Start) ### Problem: Antivirus blockiert **Lösung**: - Code-Signing-Zertifikat verwenden - Bei Microsoft einreichen für SmartScreen - README mit Hinweis erweitern ## Automatisierung mit CI/CD ### GitHub Actions Beispiel ```yaml name: Build Windows Release on: push: tags: - 'v*' jobs: build: runs-on: windows-latest steps: - uses: actions/checkout@v3 - name: Install uv uses: astral-sh/setup-uv@v1 - name: Build run: uv run python build_windows.py - name: Create Release uses: softprops/action-gh-release@v1 with: files: dist/*.zip ``` ## Versionierung Version in folgenden Dateien aktualisieren: 1. `pyproject.toml` - `version = "X.Y.Z"` 2. `installer.iss` - `#define MyAppVersion "X.Y.Z"` 3. Optional: `src/version.py` erstellen ## Lizenz und Rechtliches - Alle Python-Dependencies sind in der Distribution enthalten - PySide6 (LGPL): Dynamische Verlinkung ist OK - Polars (MIT): Unproblematisch - Pydantic (MIT): Unproblematisch Externe Tools (Saxon, FOP) haben eigene Lizenzen und müssen separat installiert werden.