From 7e4f2c92b1bcc927c0778f55e14d75d785e82118 Mon Sep 17 00:00:00 2001 From: "let5sne.win10" Date: Thu, 12 Feb 2026 23:00:57 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=B7=BB=E5=8A=A0=E6=A1=8C=E9=9D=A2?= =?UTF-8?q?=E7=A8=8B=E5=BA=8F=E6=89=93=E5=8C=85=E6=94=AF=E6=8C=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 添加 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 --- .gitignore | 9 +++++++++ build_exe.py | 46 ++++++++++++++++++++++++++++++++++++++++++++++ requirements.txt | 12 ++++++++++++ 3 files changed, 67 insertions(+) create mode 100644 build_exe.py diff --git a/.gitignore b/.gitignore index 16de759..6eb655c 100644 --- a/.gitignore +++ b/.gitignore @@ -51,3 +51,12 @@ android-app/*.keystore android-app/**/kotlin/ android-app/**/tmp/ android-app/**/.kotlin/ + +# ================================================== +# PyInstaller 打包产物 +# ================================================== +*.spec +build/ +dist/ +*.exe +*.db diff --git a/build_exe.py b/build_exe.py new file mode 100644 index 0000000..84d4d66 --- /dev/null +++ b/build_exe.py @@ -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() diff --git a/requirements.txt b/requirements.txt index feb491a..5ea6fc8 100644 --- a/requirements.txt +++ b/requirements.txt @@ -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