Merge branch 'master' of ssh://gitea.bowongai.com:221/bowong/mxivideo
This commit is contained in:
commit
41d7e22175
|
|
@ -1,20 +1,13 @@
|
|||
# -*- 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 = [
|
||||
# 核心模块
|
||||
a = Analysis(
|
||||
['main.py'],
|
||||
pathex=[],
|
||||
binaries=[],
|
||||
datas=[],
|
||||
hiddenimports=[
|
||||
'python_core',
|
||||
'python_core.config',
|
||||
'python_core.utils',
|
||||
|
|
@ -22,8 +15,6 @@ hiddenimports = [
|
|||
'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',
|
||||
|
|
@ -32,26 +23,16 @@ hiddenimports = [
|
|||
'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',
|
||||
|
|
@ -65,27 +46,11 @@ hiddenimports = [
|
|||
'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 = [
|
||||
],
|
||||
hookspath=[],
|
||||
hooksconfig={},
|
||||
runtime_hooks=[],
|
||||
excludes=[
|
||||
'tkinter',
|
||||
'matplotlib',
|
||||
'scipy',
|
||||
|
|
@ -102,29 +67,15 @@ excludes = [
|
|||
'pip',
|
||||
'wheel',
|
||||
'distutils',
|
||||
]
|
||||
|
||||
# 分析配置
|
||||
a = Analysis(
|
||||
[str(current_dir / 'main.py')],
|
||||
pathex=[str(current_dir), str(project_root)],
|
||||
binaries=binaries,
|
||||
datas=datas,
|
||||
hiddenimports=hiddenimports,
|
||||
hookspath=[],
|
||||
hooksconfig={},
|
||||
runtime_hooks=[],
|
||||
excludes=excludes,
|
||||
],
|
||||
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'
|
||||
# )
|
||||
|
|
|
|||
|
|
@ -0,0 +1,43 @@
|
|||
# -*- mode: python ; coding: utf-8 -*-
|
||||
|
||||
block_cipher = None
|
||||
|
||||
a = Analysis(
|
||||
['main_simple.py'],
|
||||
pathex=[],
|
||||
binaries=[],
|
||||
datas=[],
|
||||
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='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,
|
||||
)
|
||||
|
|
@ -0,0 +1,48 @@
|
|||
@echo off
|
||||
REM 测试PyInstaller构建
|
||||
|
||||
echo 🔨 Testing PyInstaller build...
|
||||
|
||||
REM 检查Python
|
||||
python --version
|
||||
if errorlevel 1 (
|
||||
echo ❌ Python not found
|
||||
pause
|
||||
exit /b 1
|
||||
)
|
||||
|
||||
REM 检查PyInstaller
|
||||
python -m PyInstaller --version
|
||||
if errorlevel 1 (
|
||||
echo Installing PyInstaller...
|
||||
python -m pip install pyinstaller
|
||||
)
|
||||
|
||||
REM 清理之前的构建
|
||||
if exist build rmdir /s /q build
|
||||
if exist dist rmdir /s /q dist
|
||||
|
||||
REM 构建简化版本
|
||||
echo Building simplified version...
|
||||
python -m PyInstaller --onefile --console --name mixvideo-python-core main_simple.py
|
||||
|
||||
if errorlevel 1 (
|
||||
echo ❌ Build failed
|
||||
pause
|
||||
exit /b 1
|
||||
)
|
||||
|
||||
REM 测试可执行文件
|
||||
echo Testing executable...
|
||||
dist\mixvideo-python-core.exe --version
|
||||
|
||||
if errorlevel 1 (
|
||||
echo ❌ Executable test failed
|
||||
pause
|
||||
exit /b 1
|
||||
)
|
||||
|
||||
echo ✅ Build successful!
|
||||
echo Executable location: dist\mixvideo-python-core.exe
|
||||
|
||||
pause
|
||||
|
|
@ -17,11 +17,21 @@ sys.path.insert(0, str(current_dir))
|
|||
|
||||
# 导入核心模块
|
||||
try:
|
||||
from python_core.utils.logger import get_logger
|
||||
from python_core.utils.jsonrpc import create_response_handler, create_progress_reporter
|
||||
from python_core.config import get_config
|
||||
except ImportError as e:
|
||||
print(f"ERROR: Failed to import core modules: {e}", file=sys.stderr)
|
||||
# 尝试备用导入方式
|
||||
try:
|
||||
import sys
|
||||
import os
|
||||
sys.path.insert(0, os.path.dirname(__file__))
|
||||
from utils.logger import get_logger
|
||||
from utils.jsonrpc import create_response_handler, create_progress_reporter
|
||||
from config import get_config
|
||||
except ImportError as e:
|
||||
print(f"ERROR: Failed to import core modules: {e}", file=sys.stderr)
|
||||
except ImportError as e2:
|
||||
print(f"ERROR: Failed to import with backup method: {e2}", file=sys.stderr)
|
||||
sys.exit(1)
|
||||
|
||||
# 模块映射表
|
||||
|
|
@ -84,7 +94,11 @@ def load_module_function(module_name, function_name):
|
|||
module_path = module_name
|
||||
|
||||
# 导入模块
|
||||
try:
|
||||
module = __import__(f"python_core.{module_path}", fromlist=[function_name])
|
||||
except ImportError:
|
||||
# 备用导入方式
|
||||
module = __import__(module_path, fromlist=[function_name])
|
||||
|
||||
# 获取函数
|
||||
if hasattr(module, function_name):
|
||||
|
|
|
|||
|
|
@ -0,0 +1,43 @@
|
|||
#!/usr/bin/env python3
|
||||
"""
|
||||
MixVideo V2 Python Core - 简化版入口文件
|
||||
用于测试PyInstaller打包
|
||||
"""
|
||||
|
||||
import sys
|
||||
import argparse
|
||||
import json
|
||||
|
||||
def main():
|
||||
"""简化的主函数"""
|
||||
parser = argparse.ArgumentParser(description='MixVideo V2 Python Core')
|
||||
|
||||
parser.add_argument('--module', '-m', required=False, default='test',
|
||||
help='Module name')
|
||||
|
||||
parser.add_argument('--action', '-a', required=False, default='hello',
|
||||
help='Action to execute')
|
||||
|
||||
parser.add_argument('--params', '-p', type=str,
|
||||
help='Parameters as JSON string')
|
||||
|
||||
parser.add_argument('--version', action='version', version='MixVideo V2 Python Core 2.0.0')
|
||||
|
||||
args = parser.parse_args()
|
||||
|
||||
# 简单的响应
|
||||
result = {
|
||||
"status": True,
|
||||
"message": f"Hello from {args.module}.{args.action}",
|
||||
"data": {
|
||||
"module": args.module,
|
||||
"action": args.action,
|
||||
"params": args.params
|
||||
}
|
||||
}
|
||||
|
||||
print(json.dumps(result))
|
||||
return 0
|
||||
|
||||
if __name__ == "__main__":
|
||||
sys.exit(main())
|
||||
Loading…
Reference in New Issue