This commit is contained in:
root
2025-07-11 14:31:11 +08:00
parent c2e219c125
commit cd75bf70ea
5 changed files with 219 additions and 133 deletions

View File

@@ -1,130 +1,81 @@
# -*- mode: python ; coding: utf-8 -*-
"""
PyInstaller配置文件 - MixVideo V2 Python Core
用于将Python代码打包成独立可执行文件
"""
import os
import sys
from pathlib import Path
block_cipher = None
# 获取当前目录
current_dir = Path(__file__).parent
project_root = current_dir.parent
# 添加隐藏导入(确保所有模块都被包含)
hiddenimports = [
# 核心模块
'python_core',
'python_core.config',
'python_core.utils',
'python_core.utils.logger',
'python_core.utils.jsonrpc',
'python_core.utils.helpers',
'python_core.utils.validators',
# 服务模块
'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视频模块
'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',
# 第三方依赖
'requests',
'PIL',
'Pillow',
'numpy',
'opencv-python',
'cv2',
'json',
'sqlite3',
'pathlib',
'uuid',
'hashlib',
'base64',
'urllib',
'urllib.parse',
'urllib.request',
'http',
'http.client',
'ssl',
'certifi',
]
# 数据文件(包含配置文件、模板等)
datas = [
# 配置文件
(str(current_dir / '*.json'), '.'),
(str(current_dir / '*.yaml'), '.'),
(str(current_dir / '*.yml'), '.'),
# 模板文件
(str(project_root / 'assets' / 'templates'), 'assets/templates'),
# 其他资源文件
(str(project_root / 'assets' / 'icons'), 'assets/icons'),
]
# 二进制文件(如果有的话)
binaries = []
# 排除的模块(减少打包大小)
excludes = [
'tkinter',
'matplotlib',
'scipy',
'pandas',
'jupyter',
'notebook',
'IPython',
'pytest',
'unittest',
'test',
'tests',
'_pytest',
'setuptools',
'pip',
'wheel',
'distutils',
]
# 分析配置
a = Analysis(
[str(current_dir / 'main.py')],
pathex=[str(current_dir), str(project_root)],
binaries=binaries,
datas=datas,
hiddenimports=hiddenimports,
['main.py'],
pathex=[],
binaries=[],
datas=[],
hiddenimports=[
'python_core',
'python_core.config',
'python_core.utils',
'python_core.utils.logger',
'python_core.utils.jsonrpc',
'python_core.utils.helpers',
'python_core.utils.validators',
'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',
'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',
'requests',
'PIL',
'json',
'sqlite3',
'pathlib',
'uuid',
'hashlib',
'base64',
'urllib',
'urllib.parse',
'urllib.request',
'http',
'http.client',
'ssl',
'certifi',
],
hookspath=[],
hooksconfig={},
runtime_hooks=[],
excludes=excludes,
excludes=[
'tkinter',
'matplotlib',
'scipy',
'pandas',
'jupyter',
'notebook',
'IPython',
'pytest',
'unittest',
'test',
'tests',
'_pytest',
'setuptools',
'pip',
'wheel',
'distutils',
],
win_no_prefer_redirects=False,
win_private_assemblies=False,
cipher=None,
cipher=block_cipher,
noarchive=False,
)
# 处理PYZ
pyz = PYZ(a.pure, a.zipped_data, cipher=None)
pyz = PYZ(a.pure, a.zipped_data, cipher=block_cipher)
# 可执行文件配置
exe = EXE(
pyz,
a.scripts,
@@ -139,23 +90,10 @@ exe = EXE(
upx=True,
upx_exclude=[],
runtime_tmpdir=None,
console=True, # 保持控制台模式,便于调试
console=True,
disable_windowed_traceback=False,
argv_emulation=False,
target_arch=None,
codesign_identity=None,
entitlements_file=None,
icon=str(project_root / 'src-tauri' / 'icons' / 'icon.ico') if (project_root / 'src-tauri' / 'icons' / 'icon.ico').exists() else None,
)
# 如果需要创建目录分发版本(可选)
# coll = COLLECT(
# exe,
# a.binaries,
# a.zipfiles,
# a.datas,
# strip=False,
# upx=True,
# upx_exclude=[],
# name='mixvideo-python-core'
# )