fix(packaging): keep distribution minimal
This commit is contained in:
1 parent
c97e4edc74
commit
b74baef555
18 files changed
+492
-49
No files matched your search
+8
-2
@@ -58,7 +58,13 @@ dist\DouyinGuaji-<version>\
|
||||
- `run_cli.exe`:后台运行入口,桌面 GUI / Web GUI 会调用它
|
||||
- `assets/`、`webui/`、`config/`:运行所需资源
|
||||
- `logs/`、`pic/`、`state/`:运行时输出目录
|
||||
- `license.dat`:可选授权文件;打包脚本检测到项目根目录存在该文件时会复制进分发目录
|
||||
- `license.dat`:默认不随包分发;仅本地测试包需要时才使用 `-IncludeLicense` 显式复制
|
||||
|
||||
测试包如需临时带入本地 `license.dat`:
|
||||
|
||||
```powershell
|
||||
powershell -NoProfile -ExecutionPolicy Bypass -File packaging\pyinstaller\build_windows.ps1 -SkipInstall -IncludeLicense
|
||||
```
|
||||
|
||||
## 生成安装包
|
||||
|
||||
@@ -77,7 +83,7 @@ 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`。
|
||||
- 最终分发目录只应保留根目录三个 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 中保存配置。
|
||||
|
||||
@@ -4,6 +4,7 @@ param(
|
||||
[switch]$Obfuscate,
|
||||
[switch]$PackExe,
|
||||
[switch]$PackExeForce,
|
||||
[switch]$IncludeLicense,
|
||||
[string]$UpxDir = ""
|
||||
)
|
||||
|
||||
@@ -46,8 +47,6 @@ $CommonArgs = @(
|
||||
"--distpath", $DistRoot,
|
||||
"--workpath", (Join-Path $Root "build\pyinstaller"),
|
||||
"--paths", $BuildSourceRoot,
|
||||
"--add-data", "assets;assets",
|
||||
"--add-data", "webui;webui",
|
||||
"--add-data", "config\README.md;config",
|
||||
"--hidden-import", "PIL._tkinter_finder",
|
||||
"--hidden-import", "ttkbootstrap",
|
||||
@@ -91,9 +90,9 @@ if ($Obfuscate -and (Test-Path $HiddenImportsFile)) {
|
||||
$RunCliArgs = @()
|
||||
}
|
||||
|
||||
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 @RunCliArgs --name run_cli --console (Join-Path $BuildSourceRoot "bin\run_cli.py")
|
||||
python -m PyInstaller @CommonArgs --name DouyinGuajiGUI --windowed (Join-Path $BuildSourceRoot "gui\gui_app_entry.py")
|
||||
python -m PyInstaller @CommonArgs --name web_gui --console (Join-Path $BuildSourceRoot "gui\web_gui_entry.py")
|
||||
python -m PyInstaller @CommonArgs @RunCliArgs --name run_cli --console (Join-Path $BuildSourceRoot "bin\run_cli_entry.py")
|
||||
|
||||
foreach ($name in @("DouyinGuajiGUI", "web_gui", "run_cli")) {
|
||||
$srcDir = Join-Path $DistRoot $name
|
||||
@@ -107,12 +106,50 @@ foreach ($name in @("DouyinGuajiGUI", "web_gui", "run_cli")) {
|
||||
Remove-Item -LiteralPath $srcDir -Recurse -Force
|
||||
}
|
||||
|
||||
foreach ($dir in @("assets", "webui")) {
|
||||
$target = Join-Path $DistRoot $dir
|
||||
if (Test-Path $target) {
|
||||
Remove-Item -LiteralPath $target -Recurse -Force
|
||||
$RuntimeAssets = @(
|
||||
"coupon.png",
|
||||
"fav.png",
|
||||
"fudai.png",
|
||||
"fudai_icon_countdown_v20260618.png",
|
||||
"fudai_icon_pending_v20260618.png",
|
||||
"fudai_icon_purple_left_v20260618.png",
|
||||
"fudai_icon_red_left_v20260618.png",
|
||||
"fudai_task_status_dacheng_shape.png",
|
||||
"like.png",
|
||||
"x.png",
|
||||
"xin.png"
|
||||
)
|
||||
$AssetsTarget = Join-Path $DistRoot "assets"
|
||||
if (Test-Path $AssetsTarget) {
|
||||
Remove-Item -LiteralPath $AssetsTarget -Recurse -Force
|
||||
}
|
||||
New-Item -ItemType Directory -Force $AssetsTarget | Out-Null
|
||||
foreach ($name in $RuntimeAssets) {
|
||||
$src = Join-Path $Root "assets\$name"
|
||||
if (-not (Test-Path $src)) {
|
||||
throw "Missing runtime asset: assets\$name"
|
||||
}
|
||||
Copy-Item -LiteralPath (Join-Path $Root $dir) -Destination $target -Recurse -Force
|
||||
Copy-Item -LiteralPath $src -Destination (Join-Path $AssetsTarget $name) -Force
|
||||
}
|
||||
|
||||
$WebuiTarget = Join-Path $DistRoot "webui"
|
||||
if (Test-Path $WebuiTarget) {
|
||||
Remove-Item -LiteralPath $WebuiTarget -Recurse -Force
|
||||
}
|
||||
New-Item -ItemType Directory -Force $WebuiTarget | Out-Null
|
||||
Copy-Item -LiteralPath (Join-Path $Root "webui\index.html") -Destination (Join-Path $WebuiTarget "index.html") -Force
|
||||
Copy-Item -LiteralPath (Join-Path $Root "webui\styles.css") -Destination (Join-Path $WebuiTarget "styles.css") -Force
|
||||
Copy-Item -LiteralPath (Join-Path $Root "webui\app.js") -Destination (Join-Path $WebuiTarget "app.js") -Force
|
||||
foreach ($dir in @("css", "js", "partials")) {
|
||||
$srcDir = Join-Path $Root "webui\$dir"
|
||||
if (-not (Test-Path $srcDir)) {
|
||||
continue
|
||||
}
|
||||
$dstDir = Join-Path $WebuiTarget $dir
|
||||
New-Item -ItemType Directory -Force $dstDir | Out-Null
|
||||
Get-ChildItem -LiteralPath $srcDir -File | Where-Object {
|
||||
$_.Name -notlike "README*"
|
||||
} | Copy-Item -Destination $dstDir -Force
|
||||
}
|
||||
|
||||
New-Item -ItemType Directory -Force (Join-Path $DistRoot "config") | Out-Null
|
||||
@@ -124,12 +161,10 @@ foreach ($dir in @("logs", "pic", "state")) {
|
||||
}
|
||||
|
||||
$licensePath = Join-Path $Root "license.dat"
|
||||
if (Test-Path $licensePath) {
|
||||
if ($IncludeLicense -and (Test-Path $licensePath)) {
|
||||
Copy-Item -LiteralPath $licensePath -Destination (Join-Path $DistRoot "license.dat") -Force
|
||||
}
|
||||
|
||||
Copy-Item -LiteralPath (Join-Path $Root "README.md") -Destination (Join-Path $DistRoot "README.md") -Force
|
||||
|
||||
if ($PackExe) {
|
||||
$PackArgs = @($DistRoot)
|
||||
if ($UpxDir) {
|
||||
@@ -144,7 +179,12 @@ if ($PackExe) {
|
||||
}
|
||||
}
|
||||
|
||||
python -m tools.distribution_manifest $DistRoot
|
||||
$ManifestArgs = @($DistRoot)
|
||||
if ($IncludeLicense) {
|
||||
$ManifestArgs += "--allow-license"
|
||||
}
|
||||
|
||||
python -m tools.distribution_manifest @ManifestArgs
|
||||
if ($LASTEXITCODE -ne 0) {
|
||||
throw "Distribution manifest check failed with exit code $LASTEXITCODE"
|
||||
}
|
||||
@@ -154,7 +194,7 @@ if ($LASTEXITCODE -ne 0) {
|
||||
throw "Executable smoke check failed with exit code $LASTEXITCODE"
|
||||
}
|
||||
|
||||
python -m tools.distribution_manifest $DistRoot
|
||||
python -m tools.distribution_manifest @ManifestArgs
|
||||
if ($LASTEXITCODE -ne 0) {
|
||||
throw "Post-smoke distribution manifest check failed with exit code $LASTEXITCODE"
|
||||
}
|
||||
|
||||
@@ -3,5 +3,6 @@
|
||||
"url": "https://example.com/downloads/DouyinGuaji-3.3.4-Setup.exe",
|
||||
"sha256": "替换为安装包的 SHA256",
|
||||
"force": true,
|
||||
"notes": "强制更新说明"
|
||||
"notes": "强制更新说明",
|
||||
"client_config_note": "默认要求 manifest 和安装包均为 HTTPS 且同源。仅内网临时测试时,可在客户端 config.auto_update 中显式设置 require_https=false、allow_cross_origin=true。"
|
||||
}
|
||||
Reference in new issue
Block a user