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

import sys
from PyInstaller.utils.hooks import collect_data_files, collect_submodules

# 收集所有需要的数据文件
datas = []
datas += collect_data_files('matplotlib')
datas += collect_data_files('nicegui')
datas += collect_data_files('networkx')
datas += collect_data_files('scipy')
datas += collect_data_files('sklearn')
datas += collect_data_files('pandas')

# 收集所有隐藏导入
hiddenimports = []
hiddenimports += collect_submodules('matplotlib')
hiddenimports += collect_submodules('nicegui')
hiddenimports += collect_submodules('networkx')
hiddenimports += collect_submodules('scipy')
hiddenimports += collect_submodules('sklearn')
hiddenimports += collect_submodules('pandas')
hiddenimports += collect_submodules('numpy')

# 添加特定的隐藏导入
hiddenimports += [
    'matplotlib.backends.backend_qt5agg',
    'matplotlib.backends.backend_tkagg',
    'matplotlib.backends.backend_agg',
    'matplotlib.backends.backend_svg',
    'PIL._tkinter_finder',
    'openpyxl',
    'ezdxf',
    'scipy.spatial._qhull',
    'scipy.special._cdflib',
    'scipy.linalg.cython_lapack',
    'scipy.linalg.cython_blas',
    'sklearn.utils._cython_blas',
    'sklearn.neighbors._partition_nodes',
    'sklearn.tree._utils',
    'pandas._libs.tslibs.nattype',
    'pandas._libs.tslibs.np_datetime',
    'pandas._libs.skiplist',
]

block_cipher = None

a = Analysis(
    ['gui.py'],
    pathex=[],
    binaries=[],
    datas=datas,
    hiddenimports=hiddenimports,
    hookspath=[],
    hooksconfig={},
    runtime_hooks=[],
    excludes=[],
    win_no_prefer_redirects=False,
    win_private_assemblies=False,
    cipher=block_cipher,
    noarchive=False,
)

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

exe = EXE(
    pyz,
    a.scripts,
    a.binaries,
    a.zipfiles,
    a.datas,
    [],
    name='海上风电场集电线路设计优化系统',
    debug=False,
    bootloader_ignore_signals=False,
    strip=False,
    upx=True,
    upx_exclude=[],
    runtime_tmpdir=None,
    console=False,
    disable_windowed_traceback=False,
    argv_emulation=False,
    target_arch=None,
    codesign_identity=None,
    entitlements_file=None,
    icon=None,
)