Add PyArmor obfuscation packaging flow

This commit is contained in:
Your Name committed 2026-06-17 23:42:15 +08:00
1 parent 5166678590
commit 11de0f75c7
4 files changed
+292 -5

No files matched your search

+11
View File
@@ -19,6 +19,16 @@ powershell -NoProfile -ExecutionPolicy Bypass -File packaging\pyinstaller\build_
powershell -NoProfile -ExecutionPolicy Bypass -File packaging\pyinstaller\build_windows.ps1 -SkipInstall
```
如果要生成混淆后的分发包,加 `-Obfuscate`:
```powershell
powershell -NoProfile -ExecutionPolicy Bypass -File packaging\pyinstaller\build_windows.ps1 -SkipInstall -Obfuscate
```
混淆流程会先生成 `build\obfuscated-src\`,再让 PyInstaller 从该目录打包。该目录是中间产物,不要直接分发;最终仍然只分发 `dist\DouyinGuaji-<version>\` 或 Inno 生成的安装包。
注意:PyArmor 试用版会在混淆文件头部留下 trial 标记,正式分发前建议购买/配置正式授权后重新打包。
如果要生成带本地授权的测试包,先生成当前机器的 `license.dat`:
```powershell
@@ -63,3 +73,4 @@ dist\installer\DouyinGuaji-3.3.3-Setup.exe
- 目标电脑需要能使用 ADB,或者把 Android platform-tools 加入 PATH。
- 首次启动 PaddleOCR 相关组件可能较慢,杀毒软件也可能扫描 exe。
- `config/config.json` 是本地运行配置,默认不随安装包带个人配置;让使用者首次打开后在 GUI 中保存配置。
- 启用 `-Obfuscate` 后仍要以 `python -m tools.distribution_manifest dist\DouyinGuaji-<version>` 的结果为准;PASS 才能发给别人。
+15 -5
View File
@@ -1,6 +1,7 @@
param(
[string]$Version = "",
[switch]$SkipInstall
[switch]$SkipInstall,
[switch]$Obfuscate
)
$ErrorActionPreference = "Stop"
@@ -15,6 +16,9 @@ if (-not $SkipInstall) {
python -m pip install --upgrade pip
python -m pip install -r requirements.txt
python -m pip install pyinstaller
if ($Obfuscate) {
python -m pip install pyarmor
}
}
$DistRoot = Join-Path $Root "dist\DouyinGuaji-$Version"
@@ -23,12 +27,18 @@ if (Test-Path $DistRoot) {
}
New-Item -ItemType Directory -Force $DistRoot | Out-Null
$BuildSourceRoot = $Root
if ($Obfuscate) {
$BuildSourceRoot = Join-Path $Root "build\obfuscated-src"
python -m tools.obfuscation_staging --source-root $Root --staging-root $BuildSourceRoot
}
$CommonArgs = @(
"--clean",
"--noconfirm",
"--distpath", $DistRoot,
"--workpath", (Join-Path $Root "build\pyinstaller"),
"--paths", $Root,
"--paths", $BuildSourceRoot,
"--add-data", "assets;assets",
"--add-data", "webui;webui",
"--add-data", "config\README.md;config",
@@ -36,9 +46,9 @@ $CommonArgs = @(
"--hidden-import", "ttkbootstrap"
)
python -m PyInstaller @CommonArgs --name DouyinGuajiGUI --windowed "gui\gui_app.py"
python -m PyInstaller @CommonArgs --name web_gui --console "gui\web_gui.py"
python -m PyInstaller @CommonArgs --name run_cli --console "bin\run_cli.py"
python -m PyInstaller @CommonArgs --name DouyinGuajiGUI --windowed (Join-Path $BuildSourceRoot "gui\gui_app.py")
python -m PyInstaller @CommonArgs --name web_gui --console (Join-Path $BuildSourceRoot "gui\web_gui.py")
python -m PyInstaller @CommonArgs --name run_cli --console (Join-Path $BuildSourceRoot "bin\run_cli.py")
foreach ($name in @("DouyinGuajiGUI", "web_gui", "run_cli")) {
$srcDir = Join-Path $DistRoot $name