45 lines
1.4 KiB
Python
Executable File
45 lines
1.4 KiB
Python
Executable File
#!/usr/bin/env python
|
|
"""Django's command-line utility for administrative tasks."""
|
|
import os
|
|
import sys
|
|
from pathlib import Path
|
|
|
|
def main():
|
|
"""Run administrative tasks."""
|
|
try:
|
|
from dotenv import load_dotenv
|
|
env_path = Path(__file__).resolve().parent.parent / '.env'
|
|
if env_path.exists():
|
|
load_dotenv(env_path)
|
|
except ImportError:
|
|
pass
|
|
|
|
# --- WeasyPrint Library Preloading ---
|
|
import ctypes
|
|
import ctypes.util
|
|
|
|
# Try to find and load libraries dynamically to help WeasyPrint on different platforms
|
|
libs_to_load = ['glib-2.0', 'gobject-2.0', 'fontconfig', 'cairo', 'pango-1.0', 'pangoft2-1.0']
|
|
for lib_name in libs_to_load:
|
|
try:
|
|
path = ctypes.util.find_library(lib_name)
|
|
if path:
|
|
ctypes.CDLL(path)
|
|
except Exception:
|
|
pass
|
|
# -------------------------------------
|
|
|
|
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'config.settings')
|
|
try:
|
|
from django.core.management import execute_from_command_line
|
|
except ImportError as exc:
|
|
raise ImportError(
|
|
"Couldn't import Django. Are you sure it's installed and "
|
|
"available on your PYTHONPATH environment variable? Did you "
|
|
"forget to activate a virtual environment?"
|
|
) from exc
|
|
execute_from_command_line(sys.argv)
|
|
|
|
if __name__ == '__main__':
|
|
main()
|