Files
douyi_guaji_main/packaging/README.md
T

4.3 KiB
Raw Blame History

Windows 打包说明

本目录提供两级交付方式:

  1. PyInstaller 便携目录:生成 dist/DouyinGuaji-<version>/,可直接复制给别人运行。
  2. Inno Setup 安装包:基于便携目录生成 DouyinGuaji-<version>-Setup.exe。

生成便携目录

在项目根目录运行:

powershell -NoProfile -ExecutionPolicy Bypass -File packaging\pyinstaller\build_windows.ps1

如果依赖已经装好,可以跳过安装依赖:

powershell -NoProfile -ExecutionPolicy Bypass -File packaging\pyinstaller\build_windows.ps1 -SkipInstall

正式打包默认会先通过 Cython 编译 douyin/ 和 operations/ 核心模块,再让 PyInstaller 从 build\cythonized-src\ 打包:

powershell -NoProfile -ExecutionPolicy Bypass -File packaging\pyinstaller\build_windows.ps1 -SkipInstall

该流程会生成 build\cythonized-src\,其中核心模块以 .pyd 形式存在。该目录是中间产物,不要直接分发;最终仍然只分发 dist\DouyinGuaji-<version>\ 或 Inno 生成的安装包。

如果需要继续使用旧的 PyArmor 路线,可额外加 -UsePyArmor。注意:PyArmor 试用版会在混淆文件头部留下 trial 标记,正式分发前建议购买/配置正式授权后重新打包。若 PyArmor 授权不可用,旧路线会失败并停止。

仅本机开发调试需要生成明文包时,才显式加 -NoCythonForDevOnly:

powershell -NoProfile -ExecutionPolicy Bypass -File packaging\pyinstaller\build_windows.ps1 -SkipInstall -NoCythonForDevOnly

如果要尝试对根目录 exe 做 UPX 加壳/压缩,可额外加 -PackExe -UpxDir <UPX目录>:

powershell -NoProfile -ExecutionPolicy Bypass -File packaging\pyinstaller\build_windows.ps1 -SkipInstall -PackExe -UpxDir C:\path\to\upx

当前 PyInstaller 生成的 exe 带 GUARD_CF,UPX 默认会拒绝压缩。脚本提供 -PackExeForce 仅用于实验;验证中它会导致 exe 启动失败并报 Failed to load Python DLL,脚本已加入加壳后 smoke 检查,失败会中止打包。正式分发不要启用 -PackExeForce。

如果要生成带本地授权的测试包,先生成当前机器的 license.dat:

python -m tools.license_dev --output license.dat --days 30 --customer local

正式接入激活服务器后,license.dat 应由服务器签发;客户端只内置公钥。

输出目录:

dist\DouyinGuaji-<version>\

主要文件:

  • DouyinGuajiGUI.exe:数据看板版桌面 GUI 主入口
  • web_gui.exe:Web GUI 服务入口
  • run_cli.exe:后台运行入口,桌面 GUI / Web GUI 会调用它
  • assets/、webui/、config/:运行所需资源
  • logs/、pic/、state/:运行时输出目录
  • license.dat:默认不随包分发;仅本地测试包需要时才使用 -IncludeLicense 显式复制

测试包如需临时带入本地 license.dat:

powershell -NoProfile -ExecutionPolicy Bypass -File packaging\pyinstaller\build_windows.ps1 -SkipInstall -IncludeLicense

生成安装包

先安装 Inno Setup 6,并确保 iscc.exe 在 PATH 中,然后运行:

iscc packaging\inno\douyin_guaji.iss /DMyAppVersion=3.3.3

输出目录:

dist\installer\DouyinGuaji-3.3.3-Setup.exe

发给别人前检查

  • 打包脚本会自动运行 python -m tools.distribution_manifest dist\DouyinGuaji-<version>,防止源码、调试产物、个人配置和旧日志混入分发目录。
  • 最终分发目录只应保留根目录三个 exe、一个 _internal/、运行时白名单 assets/、运行时白名单 webui/、config/README.md、logs/.keep、pic/.keep、state/.keep。正式分发不要包含 license.dat、README.md、artifacts/、tests/、源码目录、调试截图、临时模板或 debug/README 页面。
  • 目标电脑需要能使用 ADB,或者把 Android platform-tools 加入 PATH。
  • 首次启动 PaddleOCR 相关组件可能较慢,杀毒软件也可能扫描 exe。
  • config/config.json 是本地运行配置,默认不随安装包带个人配置;让使用者首次打开后在 GUI 中保存配置。
  • 默认 Cython 编译后仍要以 python -m tools.distribution_manifest dist\DouyinGuaji-<version> 的结果为准;PASS 才能发给别人。使用 -NoCythonForDevOnly 生成的明文包禁止分发。