# -*- coding: utf-8 -*-
"""
check_packages.py - prueft, ob alle benoetigten Pakete im virtualenv
installiert sind. Gibt pro Paket OK + Version oder FEHLT + Fehlertext aus.
Aufruf ueber cPanel "Python-Skript ausfuehren" mit Pfad:
    check_packages.py
"""

# (Import-Name, Anzeige-Name) -- manche Pakete importieren anders als ihr pip-Name
PAKETE = [
    ("flask", "flask"),
    ("anthropic", "anthropic"),
    ("reportlab", "reportlab"),
    ("swisseph", "pyswisseph"),
    ("matplotlib", "matplotlib"),
    ("scipy", "scipy"),
    ("pypdfium2", "pypdfium2"),
    ("PIL", "pillow"),
    ("geopy", "geopy"),
    ("timezonefinder", "timezonefinder"),
]

print("=" * 50)
print("PAKET-PRUEFUNG HD-Pipeline")
print("=" * 50)

fehlend = []
for import_name, anzeige in PAKETE:
    try:
        modul = __import__(import_name)
        version = getattr(modul, "__version__", "?")
        print(f"  OK    {anzeige:<16} {version}")
    except Exception as e:
        print(f"  FEHLT {anzeige:<16} -> {e}")
        fehlend.append(anzeige)

print("-" * 50)
if fehlend:
    print(f"ERGEBNIS: {len(fehlend)} Paket(e) fehlen: {', '.join(fehlend)}")
else:
    print("ERGEBNIS: ALLE 10 PAKETE INSTALLIERT")
print("=" * 50)
