Fix encrypted package runtime validation
This commit is contained in:
1 parent
abcee63776
commit
cc4caef6e1
7 files changed
+352
-21
No files matched your search
@@ -31,9 +31,13 @@ if (Test-Path $DistRoot) {
|
||||
New-Item -ItemType Directory -Force $DistRoot | Out-Null
|
||||
|
||||
$BuildSourceRoot = $Root
|
||||
$HiddenImportsFile = Join-Path $Root "build\obfuscation-hidden-imports.json"
|
||||
if ($Obfuscate) {
|
||||
$BuildSourceRoot = Join-Path $Root "build\obfuscated-src"
|
||||
python -m tools.obfuscation_staging --source-root $Root --staging-root $BuildSourceRoot
|
||||
python -m tools.obfuscation_staging --source-root $Root --staging-root $BuildSourceRoot --hidden-imports-output $HiddenImportsFile
|
||||
if ($LASTEXITCODE -ne 0) {
|
||||
throw "PyArmor obfuscation failed with exit code $LASTEXITCODE"
|
||||
}
|
||||
}
|
||||
|
||||
$CommonArgs = @(
|
||||
@@ -46,12 +50,49 @@ $CommonArgs = @(
|
||||
"--add-data", "webui;webui",
|
||||
"--add-data", "config\README.md;config",
|
||||
"--hidden-import", "PIL._tkinter_finder",
|
||||
"--hidden-import", "ttkbootstrap"
|
||||
"--hidden-import", "ttkbootstrap",
|
||||
"--hidden-import", "logging.handlers",
|
||||
"--collect-submodules", "douyin",
|
||||
"--collect-submodules", "gui",
|
||||
"--collect-submodules", "operations"
|
||||
)
|
||||
|
||||
$ExcludedOptionalModules = @(
|
||||
"easyocr",
|
||||
"matplotlib",
|
||||
"modelscope",
|
||||
"pandas",
|
||||
"pytest",
|
||||
"scipy",
|
||||
"skimage",
|
||||
"tensorflow",
|
||||
"torch",
|
||||
"torchvision"
|
||||
)
|
||||
foreach ($name in $ExcludedOptionalModules) {
|
||||
$CommonArgs += @("--exclude-module", $name)
|
||||
}
|
||||
|
||||
if ($Obfuscate -and (Test-Path $HiddenImportsFile)) {
|
||||
$HiddenImports = Get-Content -LiteralPath $HiddenImportsFile -Raw | ConvertFrom-Json
|
||||
$CliOnlyHiddenImportRoots = @("cv2", "numpy", "paddleocr", "paddle")
|
||||
$RunCliArgs = @()
|
||||
foreach ($name in $HiddenImports) {
|
||||
$nameText = [string]$name
|
||||
$rootName = ($nameText -split "\.")[0]
|
||||
if ($CliOnlyHiddenImportRoots -contains $rootName) {
|
||||
$RunCliArgs += @("--hidden-import", $nameText)
|
||||
} else {
|
||||
$CommonArgs += @("--hidden-import", $nameText)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$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 --name run_cli --console (Join-Path $BuildSourceRoot "bin\run_cli.py")
|
||||
python -m PyInstaller @CommonArgs @RunCliArgs --name run_cli --console (Join-Path $BuildSourceRoot "bin\run_cli.py")
|
||||
|
||||
foreach ($name in @("DouyinGuajiGUI", "web_gui", "run_cli")) {
|
||||
$srcDir = Join-Path $DistRoot $name
|
||||
@@ -60,7 +101,7 @@ foreach ($name in @("DouyinGuajiGUI", "web_gui", "run_cli")) {
|
||||
$dstInternal = Join-Path $DistRoot "_internal"
|
||||
if (Test-Path $srcInternal) {
|
||||
New-Item -ItemType Directory -Force $dstInternal | Out-Null
|
||||
Copy-Item -LiteralPath (Join-Path $srcInternal "*") -Destination $dstInternal -Recurse -Force
|
||||
Get-ChildItem -LiteralPath $srcInternal -Force | Copy-Item -Destination $dstInternal -Recurse -Force
|
||||
}
|
||||
Remove-Item -LiteralPath $srcDir -Recurse -Force
|
||||
}
|
||||
@@ -103,6 +144,19 @@ if ($PackExe) {
|
||||
}
|
||||
|
||||
python -m tools.distribution_manifest $DistRoot
|
||||
if ($LASTEXITCODE -ne 0) {
|
||||
throw "Distribution manifest check failed with exit code $LASTEXITCODE"
|
||||
}
|
||||
|
||||
python -m tools.exe_packing $DistRoot --smoke-only
|
||||
if ($LASTEXITCODE -ne 0) {
|
||||
throw "Executable smoke check failed with exit code $LASTEXITCODE"
|
||||
}
|
||||
|
||||
python -m tools.distribution_manifest $DistRoot
|
||||
if ($LASTEXITCODE -ne 0) {
|
||||
throw "Post-smoke distribution manifest check failed with exit code $LASTEXITCODE"
|
||||
}
|
||||
|
||||
Write-Host "[OK] Portable package: $DistRoot"
|
||||
Write-Host "[NEXT] If Inno Setup is installed: iscc packaging\inno\douyin_guaji.iss /DMyAppVersion=$Version"
|
||||
Reference in new issue
Block a user