feat: 添加桌面程序打包支持

- 添加 PyInstaller 打包脚本 build_exe.py
- 更新 requirements.txt 添加 PyQt6 和 opencv-python
- .gitignore 添加 PyInstaller 打包产物忽略规则

使用方法:
  pip install pyinstaller
  python build_exe.py

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
let5sne.win10
2026-02-12 23:00:57 +08:00
parent 109946a461
commit 7e4f2c92b1
3 changed files with 67 additions and 0 deletions

9
.gitignore vendored
View File

@@ -51,3 +51,12 @@ android-app/*.keystore
android-app/**/kotlin/
android-app/**/tmp/
android-app/**/.kotlin/
# ==================================================
# PyInstaller 打包产物
# ==================================================
*.spec
build/
dist/
*.exe
*.db

46
build_exe.py Normal file
View File

@@ -0,0 +1,46 @@
#!/usr/bin/env python3
"""
打包脚本 - 将桌面程序打包成独立可执行文件
使用方法: pip install pyinstaller && python build_exe.py
"""
import subprocess
from pathlib import Path
PROJECT_ROOT = Path(__file__).parent
def build():
"""使用 PyInstaller 打包"""
# PyInstaller 命令
cmd = [
"pyinstaller",
"--name=信封信息提取系统",
"--onefile", # 打包成单个 exe
"--windowed", # 无控制台窗口
"--clean", # 清理缓存
"--noconfirm", # 覆盖输出目录不询问
"--add-data=src;src", # 包含源码目录
"--hidden-import=PaddleOCR",
"--hidden-import=paddleocr",
"--hidden-import=cv2",
"--hidden-import=PyQt6",
"--collect-all=PaddleOCR",
"--collect-all=paddleocr",
"src/desktop.py",
]
print("正在打包,请稍候...")
print(f"工作目录: {PROJECT_ROOT}")
print(f"输出目录: {PROJECT_ROOT / 'dist'}")
print("-" * 50)
subprocess.run(cmd, check=True, cwd=PROJECT_ROOT)
print("-" * 50)
print("打包完成!")
print(f"可执行文件: {PROJECT_ROOT / 'dist' / '信封信息提取系统.exe'}")
if __name__ == "__main__":
build()

View File

@@ -1,7 +1,19 @@
# OCR 核心依赖
paddleocr>=2.6,<3
paddlepaddle>=2.5,<3
# 数据处理
pandas
openpyxl
pydantic
tqdm
# Web 界面
streamlit
# 桌面版依赖
PyQt6>=6.6.0
opencv-python>=4.8.0
# 打包工具(仅开发时需要)
pyinstaller>=6.0.0