# -*- mode: python ; coding: utf-8 -*-
"""
增强版PyInstaller配置 - 逐步添加功能
"""

block_cipher = None

# 基础隐藏导入
basic_imports = [
    'json',
    'sqlite3',
    'pathlib',
    'uuid',
    'hashlib',
    'base64',
    'urllib',
    'urllib.parse',
    'urllib.request',
    'http',
    'http.client',
    'ssl',
    'certifi',
]

# Python Core 核心模块
core_imports = [
    'python_core',
    'python_core.config',
    'python_core.utils',
    'python_core.utils.logger',
    'python_core.utils.jsonrpc',
    'python_core.utils.helpers',
    'python_core.utils.validators',
]

# 服务模块
service_imports = [
    'python_core.services',
    'python_core.services.template_manager',
    'python_core.services.project_manager',
    'python_core.services.media_manager',
    'python_core.services.audio_manager',
    'python_core.services.model_manager',
    'python_core.services.resource_category_manager',
    'python_core.services.file_manager',
]

# AI和处理模块
ai_processing_imports = [
    'python_core.ai_video',
    'python_core.ai_video.video_generator',
    'python_core.ai_video.api_client',
    'python_core.ai_video.cloud_storage',
    'python_core.audio_processing',
    'python_core.audio_processing.core',
    'python_core.video_processing',
    'python_core.video_processing.core',
]

# 第三方库（基础）
basic_third_party = [
    'requests',
    'requests.adapters',
    'requests.auth',
    'requests.cookies',
    'requests.exceptions',
    'requests.models',
    'requests.sessions',
    'requests.utils',
]

# 图像处理库
image_imports = [
    'PIL',
    'PIL.Image',
    'PIL.ImageDraw',
    'PIL.ImageFont',
    'PIL.ImageFilter',
    'PIL.ImageEnhance',
    'PIL.ImageOps',
]

# 组合所有导入
all_imports = (
    basic_imports + 
    core_imports + 
    service_imports + 
    ai_processing_imports + 
    basic_third_party + 
    image_imports
)

# 排除的模块
excludes = [
    'tkinter',
    'matplotlib',
    'scipy',
    'pandas',
    'jupyter',
    'notebook',
    'IPython',
    'pytest',
    'unittest',
    'test',
    'tests',
    '_pytest',
    'setuptools',
    'pip',
    'wheel',
    'distutils',
    # 暂时排除可能有问题的模块
    'numpy',
    'cv2',
    'opencv-python',
    'torch',
    'tensorflow',
]

a = Analysis(
    ['main_simple.py', 'mock_services.py'],
    pathex=['.'],
    binaries=[],
    datas=[],
    hiddenimports=all_imports,
    hookspath=[],
    hooksconfig={},
    runtime_hooks=[],
    excludes=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='mixvideo-python-core',
    debug=False,
    bootloader_ignore_signals=False,
    strip=False,
    upx=True,
    upx_exclude=[],
    runtime_tmpdir=None,
    console=True,
    disable_windowed_traceback=False,
    argv_emulation=False,
    target_arch=None,
    codesign_identity=None,
    entitlements_file=None,
)
