"""Passenger entry point for shared hosting (cPanel "Setup Python App").

This file lies in the application root (the folder with manage.py). In the panel:
"Application startup file" = passenger_wsgi.py, "Application Entry point" = application.
"""

import os
import sys

ROOT = os.path.dirname(os.path.abspath(__file__))
if ROOT not in sys.path:
    sys.path.insert(0, ROOT)

os.environ.setdefault("DJANGO_SETTINGS_MODULE", "snapfile.settings")
os.environ.setdefault("SNAPFILE_ENV_FILE", os.path.join(ROOT, ".env"))

from django.core.wsgi import get_wsgi_application  # noqa: E402

application = get_wsgi_application()

# load the render engine when the process starts, so the first document is not slower
try:  # pragma: no cover - best effort
    import pypdfium2  # noqa: F401,E402
    import reportlab.pdfgen.canvas  # noqa: F401,E402

    import snapfile_render.renderer  # noqa: F401,E402
except Exception:
    pass
