3.5 KiB
3.5 KiB
Windows 打包说明
本目录提供两级交付方式:
- PyInstaller 便携目录:生成
dist/DouyinGuaji-<version>/,可直接复制给别人运行。 - 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
如果要生成混淆后的分发包,加 -Obfuscate:
powershell -NoProfile -ExecutionPolicy Bypass -File packaging\pyinstaller\build_windows.ps1 -SkipInstall -Obfuscate
混淆流程会先生成 build\obfuscated-src\,再让 PyInstaller 从该目录打包。该目录是中间产物,不要直接分发;最终仍然只分发 dist\DouyinGuaji-<version>\ 或 Inno 生成的安装包。
注意:PyArmor 试用版会在混淆文件头部留下 trial 标记,正式分发前建议购买/配置正式授权后重新打包。
如果要尝试对根目录 exe 做 UPX 加壳/压缩,可额外加 -PackExe -UpxDir <UPX目录>:
powershell -NoProfile -ExecutionPolicy Bypass -File packaging\pyinstaller\build_windows.ps1 -SkipInstall -Obfuscate -PackExe -UpxDir C:\path\to\upx
当前 PyInstaller 生成的 exe 带 GUARD_CF,UPX 默认会拒绝压缩。脚本提供 -PackExeForce 仅用于实验;验证中它会导致 exe 启动失败并报 Failed to load Python DLL,脚本已加入加壳后 smoke 检查,失败会中止打包。正式分发目前建议使用 -Obfuscate,不要启用 -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:可选授权文件;打包脚本检测到项目根目录存在该文件时会复制进分发目录
生成安装包
先安装 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。 - 目标电脑需要能使用 ADB,或者把 Android platform-tools 加入 PATH。
- 首次启动 PaddleOCR 相关组件可能较慢,杀毒软件也可能扫描 exe。
config/config.json是本地运行配置,默认不随安装包带个人配置;让使用者首次打开后在 GUI 中保存配置。- 启用
-Obfuscate后仍要以python -m tools.distribution_manifest dist\DouyinGuaji-<version>的结果为准;PASS 才能发给别人。