54 lines
1.5 KiB
Python
54 lines
1.5 KiB
Python
"""
|
|
WSGI config for config project.
|
|
|
|
It exposes the WSGI callable as a module-level variable named ``application``.
|
|
|
|
For more information on this file, see
|
|
https://docs.djangoproject.com/en/5.0/howto/deployment/wsgi/
|
|
"""
|
|
|
|
import os
|
|
from pathlib import Path
|
|
import ctypes
|
|
import ctypes.util
|
|
|
|
try:
|
|
from dotenv import load_dotenv
|
|
env_path = Path(__file__).resolve().parent.parent.parent / '.env'
|
|
if env_path.exists():
|
|
load_dotenv(env_path)
|
|
except ImportError:
|
|
pass
|
|
|
|
# --- FIX: Preload libraries for WeasyPrint/Pango ---
|
|
# Ensure LD_LIBRARY_PATH includes standard paths
|
|
if 'LD_LIBRARY_PATH' not in os.environ:
|
|
os.environ['LD_LIBRARY_PATH'] = '/usr/lib/x86_64-linux-gnu:/usr/lib'
|
|
else:
|
|
if '/usr/lib/x86_64-linux-gnu' not in os.environ['LD_LIBRARY_PATH']:
|
|
os.environ['LD_LIBRARY_PATH'] += ':/usr/lib/x86_64-linux-gnu'
|
|
|
|
# Manually load the library
|
|
try:
|
|
if not ctypes.util.find_library('libgobject-2.0-0'):
|
|
# Try to load known paths directly
|
|
candidates = [
|
|
'libgobject-2.0.so.0',
|
|
'/usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0',
|
|
'/usr/lib/libgobject-2.0.so.0'
|
|
]
|
|
for c in candidates:
|
|
try:
|
|
ctypes.CDLL(c)
|
|
break
|
|
except OSError:
|
|
continue
|
|
except Exception:
|
|
pass
|
|
# ---------------------------------------------------
|
|
|
|
from django.core.wsgi import get_wsgi_application
|
|
|
|
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'config.settings')
|
|
|
|
application = get_wsgi_application() |