添加PyInstaller打包支持和运行时路径修复

- 创建PyInstaller规范文件和打包脚本
- 修复开发/打包环境路径兼容性问题
- 添加PaddleOCR运行时依赖(opencv-contrib-python, pypdfium2, pyclipper)
- 支持打包后的多进程启动
- 修复图标路径和翻译文件路径
- 清理重复的模型和FFmpeg文件
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
yaofanguk
2026-04-10 19:23:05 +08:00
parent 293cd9bbee
commit c80e7fabc9
18 changed files with 423 additions and 33 deletions

View File

@@ -1,5 +1,6 @@
import os
import sys
from pathlib import Path
from qfluentwidgets import (qconfig, ConfigItem, QConfig, OptionsValidator, BoolValidator, OptionsConfigItem,
EnumSerializer, RangeValidator, RangeConfigItem, ConfigValidator)
@@ -115,10 +116,16 @@ elif isinstance(_detect_mode_value, str) and _detect_mode_value in ("精准", "P
# 读取界面语言配置
tr = configparser.ConfigParser()
TRANSLATION_FILE = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'interface', f"{config.interface.value}.ini")
# 确定运行环境(开发环境或打包环境)
if getattr(sys, 'frozen', False):
# 打包后的环境
BASE_DIR = sys._MEIPASS
TRANSLATION_FILE = os.path.join(BASE_DIR, 'backend', 'interface', f"{config.interface.value}.ini")
else:
# 开发环境
BASE_DIR = str(Path(os.path.abspath(__file__)).parent.parent)
TRANSLATION_FILE = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'interface', f"{config.interface.value}.ini")
tr.read(TRANSLATION_FILE, encoding='utf-8')
# 项目的base目录
BASE_DIR = str(Path(os.path.abspath(__file__)).parent)
os.environ['KMP_DUPLICATE_LIB_OK'] = 'True'