Fix: PyInstaller-Bundle für installierte Version repariert (connectorx, SQL-Ressourcen)
- connectorx via collect_all() eingebunden statt hiddenimports (Rust-PYD + __init__.py + Metadaten als Einheit) - SQL/CSV-Ressourcen (src/res/) ins PyInstaller-Bundle aufgenommen - Pfadauflösung in database.py auf sys._MEIPASS umgestellt für installierten Modus - connectorx als explizite Abhängigkeit in pyproject.toml ergänzt - Dokumentation (windows_distribution.md) um collect_all-Pattern und _MEIPASS-Hinweise erweitert - Version auf 1.0.0 aktualisiert, Hersteller-Informationen ergänzt
This commit is contained in:
@@ -166,14 +166,16 @@ exe = EXE(
|
||||
)
|
||||
```
|
||||
|
||||
## 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
|
||||
## PyInstaller .spec Konfiguration
|
||||
|
||||
Die Datei `DocuMentor.spec` enthält:
|
||||
|
||||
- **datas**: UI-Dateien (.ui), Ressource-Dateien (SQL, CSV) und connectorx-Package
|
||||
- **binaries**: Native Extensions (connectorx `.pyd`)
|
||||
- **hiddenimports**: Alle notwendigen PySide6/Polars-Module
|
||||
- **collect_all('connectorx')**: Sammelt Python-Code, native `.pyd`-Extension und Metadaten als Einheit (nötig, da `polars` connectorx erst zur Laufzeit per `importlib.import_module()` lädt)
|
||||
- **console=False**: GUI-Anwendung ohne Konsole
|
||||
- **upx=True**: Kompression der Binaries
|
||||
|
||||
### Wichtige Einstellungen
|
||||
|
||||
@@ -294,24 +296,49 @@ wine dist/DocuMentor/DocuMentor.exe
|
||||
|
||||
## Troubleshooting
|
||||
|
||||
### Problem: "Module not found" Fehler
|
||||
### Problem: "Module not found" Fehler
|
||||
|
||||
**Lösung A** – Einfache Python-Module: Hidden imports in `DocuMentor.spec` ergänzen:
|
||||
```python
|
||||
hiddenimports=[
|
||||
# ... existing
|
||||
'missing_module',
|
||||
]
|
||||
```
|
||||
|
||||
**Lösung B** – Packages mit nativen Extensions (Rust/C, z.B. `connectorx`):
|
||||
`hiddenimports` allein reicht nicht, da PyInstaller die `__init__.py` ins PYZ-Archiv packt, aber die `.pyd`-Extension separat im Dateisystem erwartet. Stattdessen `collect_all` verwenden:
|
||||
```python
|
||||
from PyInstaller.utils.hooks import collect_all
|
||||
cx_datas, cx_binaries, cx_hiddenimports = collect_all('problematic_package')
|
||||
|
||||
a = Analysis(
|
||||
# ...
|
||||
binaries=cx_binaries,
|
||||
datas=cx_datas,
|
||||
hiddenimports=cx_hiddenimports,
|
||||
)
|
||||
```
|
||||
|
||||
**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: UI-Dateien oder Ressourcen nicht gefunden
|
||||
|
||||
**Lösung**: Prüfen ob datas korrekt konfiguriert. Ressource-Pfade müssen im Code PyInstaller-kompatibel aufgelöst werden (`sys._MEIPASS`):
|
||||
```python
|
||||
# In DocuMentor.spec:
|
||||
datas=[
|
||||
('src/ui/*.ui', 'ui'),
|
||||
('src/res/*', 'res'),
|
||||
]
|
||||
|
||||
# Im Code:
|
||||
import sys
|
||||
from pathlib import Path
|
||||
|
||||
if hasattr(sys, "_MEIPASS"):
|
||||
res_path = Path(sys._MEIPASS) / "res" / "data.sql"
|
||||
else:
|
||||
res_path = Path(__file__).parents[3] / "src" / "res" / "data.sql"
|
||||
```
|
||||
|
||||
### Problem: Executable zu groß
|
||||
|
||||
|
||||
Reference in New Issue
Block a user