-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild_exe.ps1
More file actions
82 lines (70 loc) · 2.22 KB
/
Copy pathbuild_exe.ps1
File metadata and controls
82 lines (70 loc) · 2.22 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
param(
[switch]$Clean
)
$ErrorActionPreference = "Stop"
$root = Split-Path -Parent $MyInvocation.MyCommand.Path
Set-Location $root
function Get-RunningPackagedApps {
$distRoot = Join-Path $root "dist"
Get-Process -ErrorAction SilentlyContinue |
Where-Object {
$_.ProcessName -in @("TithingVideoMaker", "TithingVideoMakerUI") -and
$_.Path -like "$distRoot*"
}
}
$runningApps = @(Get-RunningPackagedApps)
if ($runningApps.Count -gt 0) {
$processList = $runningApps | ForEach-Object { "$($_.ProcessName) (PID $($_.Id))" }
throw "Close running packaged apps before rebuilding: $($processList -join ', ')"
}
if ($Clean) {
Remove-Item build, dist -Recurse -Force -ErrorAction SilentlyContinue
}
function Move-TopLevelDataDirs {
param(
[Parameter(Mandatory = $true)]
[string]$AppName
)
$appDir = Join-Path $root "dist\$AppName"
$internalDir = Join-Path $appDir "_internal"
foreach ($name in @("assets", "backgrounds")) {
$from = Join-Path $internalDir $name
$to = Join-Path $appDir $name
if (Test-Path $from) {
if (Test-Path $to) {
Remove-Item $to -Recurse -Force
}
Move-Item $from $to
}
}
}
function Build-App {
param(
[Parameter(Mandatory = $true)]
[string]$AppName,
[Parameter(Mandatory = $true)]
[string]$EntryPoint,
[Parameter(Mandatory = $true)]
[string]$UiMode
)
poetry run pyinstaller `
--noconfirm `
--clean `
--name $AppName `
--onedir `
--contents-directory _internal `
$UiMode `
--add-data "assets;assets" `
--add-data "backgrounds;backgrounds" `
--copy-metadata imageio `
--copy-metadata imageio-ffmpeg `
--copy-metadata moviepy `
--copy-metadata proglog `
--collect-all imageio_ffmpeg `
--collect-submodules moviepy `
--collect-submodules proglog `
$EntryPoint
Move-TopLevelDataDirs -AppName $AppName
}
Build-App -AppName "TithingVideoMaker" -EntryPoint "main.py" -UiMode "--console"
Build-App -AppName "TithingVideoMakerUI" -EntryPoint "launch_ui.py" -UiMode "--windowed"