# -*- mode: python ; coding: utf-8 -*-

a = Analysis(
    ['src\\mainwindow.py'],
    pathex=[],
    binaries=[],
    datas=[
      ('.\\styles\\styles.qss', 'styles'),
      ('.\\ui\\mainwindow.ui', 'ui')
    ],
    hiddenimports=[],
    hookspath=[],
    hooksconfig={
        "qt_plugins": ["platforms", "styles"]
    },
    runtime_hooks=[],
    excludes=[
        # PySide6 - modules non utilisés
      'PySide6.Qt3DAnimation',
      'PySide6.Qt3DCore',
      'PySide6.Qt3DExtras',
      'PySide6.Qt3DInput',
      'PySide6.Qt3DLogic',
      'PySide6.Qt3DRender',
      'PySide6.QtAxContainer',
      'PySide6.QtBluetooth',
      'PySide6.QtCharts',
      'PySide6.QtConcurrent',
      'PySide6.QtDataVisualization',
      'PySide6.QtDesigner',
      'PySide6.QtHelp',
      'PySide6.QtLocation',
      # 'PySide6.QtMultimedia',
      'PySide6.QtMultimediaWidgets',
      # 'PySide6.QtNetwork',   # Dépendance à QtMultimedia
      'PySide6.QtNetworkAuth',
      'PySide6.QtNfc',
      'PySide6.QtOpenGL',
      'PySide6.QtOpenGLWidgets',
      'PySide6.QtPdf',
      'PySide6.QtPdfWidgets',
      'PySide6.QtPositioning',
      'PySide6.QtPrintSupport',
      'PySide6.QtQml',
      'PySide6.QtQuick',
      'PySide6.QtQuick3D',
      'PySide6.QtQuickControls2',
      'PySide6.QtQuickWidgets',
      'PySide6.QtRemoteObjects',
      'PySide6.QtScxml',
      'PySide6.QtSensors',
      'PySide6.QtSerialBus',
      'PySide6.QtSerialPort',
      'PySide6.QtSpatialAudio',
      'PySide6.QtSql',
      'PySide6.QtStateMachine',
      'PySide6.QtSvg',
      'PySide6.QtSvgWidgets',
      'PySide6.QtTest',
      'PySide6.QtTextToSpeech',
      'PySide6.QtWebChannel',
      'PySide6.QtWebEngineCore',
      'PySide6.QtWebEngineQuick',
      'PySide6.QtWebEngineWidgets',
      'PySide6.QtWebSockets',
      'PySide6.QtXml',

      # Stdlib inutile en prod
      'unittest',
      'email',
      'html',
      'http',
      'xmlrpc',
      'pydoc',
      'doctest',
      'difflib',
      'tkinter',
      'curses',
      'readline',
      'xml',
      'xmlrpc',
      'csv',
      'multiprocessing',
      'concurrent',
      'asyncio',
      'sqlite3',
      'ssl',
      'socket',
      'ctypes',
      'lib2to3',
      'test',
      'distutils',
      'setuptools',
      'pkg_resources',
      'pip',
    ],
    noarchive=False,
    optimize=2,
)

# --- Filtre des DLLs Qt inutiles ---
# Ces DLLs sont incluses par analyse binaire malgré les excludes Python
unwanted_dlls = [
    'Qt6Pdf',
    'Qt6Quick',
    'Qt6Qml',
    'Qt6QmlModels',
    'Qt6QmlWorkerScript',
    'Qt6WebEngine',
    'Qt6WebEngineCore',
    'Qt63DCore',
    'Qt63DRender',
    'Qt63DAnimation',
    'Qt63DExtras',
    'Qt63DInput',
    'Qt63DLogic',
    'Qt6Charts',
    'Qt6DataVisualization',
    'Qt6Bluetooth',
    'Qt6Nfc',
    'Qt6Positioning',
    'Qt6Location',
    'Qt6RemoteObjects',
    'Qt6Scxml',
    'Qt6Sensors',
    'Qt6SerialBus',
    'Qt6SerialPort',
    'Qt6SpatialAudio',
    'Qt6StateMachine',
    # 'Qt6Svg',    # Dependance lecteur svg
    'Qt6TextToSpeech',
    'Qt6WebChannel',
    'Qt6WebSockets',
    'Qt6Sql',
    'Qt6Test',
    # 'Qt6OpenGL',    # Dependance a Qt6UiTools
    'Qt6PrintSupport',
    # 'Qt6Xml',   # Dependance fichier .ui
    'Qt6Help',
    'Qt6Designer',
    'Qt6Concurrent',
]

a.binaries = [
    (name, path, typecode)
    for name, path, typecode in a.binaries
    if not any(u.lower() in name.lower() for u in unwanted_dlls)
]

pyz = PYZ(a.pure, a.zipped_data)

exe = EXE(
    pyz,
    a.scripts,
    a.binaries,
    a.datas,
    [],
    name='La Tanière Launcher',
    debug=False,
    bootloader_ignore_signals=False,
    strip=False,
    upx=True,
    upx_exclude=[
      "_uuid.pyd",
      "Qt6Core.dll",
      "Qt6Gui.dll",
      "Qt6Widgets.dll",
      "Qt6UiTools.dll",
      "qwindows.dll",
      "python3*.dll",
      "vcruntime*.dll",
      "msvcp*.dll",
    ],
    runtime_tmpdir=None,
    console=True,
    disable_windowed_traceback=True,
    argv_emulation=False,
    target_arch=None,
    codesign_identity=None,
    entitlements_file=None,
    icon=['assets\\Icon.ico'],
)
