fix(packaging): keep distribution minimal

This commit is contained in:
Your Name committed 2026-06-18 11:14:04 +08:00
1 parent c97e4edc74
commit b74baef555
18 files changed
+492 -49

No files matched your search

+55 -15
View File
@@ -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"
}