-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.ps1
More file actions
136 lines (117 loc) · 3.92 KB
/
Copy pathbuild.ps1
File metadata and controls
136 lines (117 loc) · 3.92 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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
# ============================================
# Build Script for MultiDeck Audio Player
# PowerShell Version
# ============================================
param(
[switch]$Debug,
[switch]$OneFile,
[switch]$Clean
)
$ErrorActionPreference = "Stop"
# Configuration
$AppName = "MultiDeck Audio Player"
$SpecFile = "multideck.spec"
$DistDir = "dist"
$BuildDir = "build"
function Write-ColorOutput($ForegroundColor) {
$fc = $host.UI.RawUI.ForegroundColor
$host.UI.RawUI.ForegroundColor = $ForegroundColor
if ($args) {
Write-Output $args
}
$host.UI.RawUI.ForegroundColor = $fc
}
Write-Host ""
Write-ColorOutput Green "============================================"
Write-ColorOutput Green " Building $AppName"
Write-ColorOutput Green "============================================"
Write-Host ""
# Check if virtual environment exists
if (-not (Test-Path "venv\Scripts\Activate.ps1")) {
Write-ColorOutput Red "Error: Virtual environment not found."
Write-Host "Please create it first with: python -m venv venv"
exit 1
}
# Activate virtual environment
Write-ColorOutput Yellow "Activating virtual environment..."
& ".\venv\Scripts\Activate.ps1"
# Check if PyInstaller is installed
$pyinstaller = pip show pyinstaller 2>$null
if (-not $pyinstaller) {
Write-ColorOutput Yellow "PyInstaller not found. Installing..."
pip install pyinstaller
if ($LASTEXITCODE -ne 0) {
Write-ColorOutput Red "Error: Failed to install PyInstaller."
exit 1
}
}
# Install dependencies
Write-ColorOutput Yellow "Checking dependencies..."
pip install -r requirements.txt
if ($LASTEXITCODE -ne 0) {
Write-ColorOutput Red "Error: Failed to install dependencies."
exit 1
}
# Clean previous builds
if ($Clean -or $true) {
Write-ColorOutput Yellow "Cleaning previous builds..."
if (Test-Path $BuildDir) {
Remove-Item -Recurse -Force $BuildDir
}
if (Test-Path "$DistDir\MultiDeck") {
Remove-Item -Recurse -Force "$DistDir\MultiDeck"
}
}
# Build PyInstaller arguments
$pyinstallerArgs = @("--clean", "--noconfirm")
if ($Debug) {
Write-ColorOutput Yellow "Debug mode enabled - console window will be visible"
# Modify spec temporarily or use command line
}
if ($OneFile) {
Write-ColorOutput Yellow "Building single-file executable..."
$pyinstallerArgs += "--onefile"
$pyinstallerArgs += "src\main.py"
$pyinstallerArgs += "--name=MultiDeck"
$pyinstallerArgs += "--windowed"
$pyinstallerArgs += "--add-data=locale;locale"
$pyinstallerArgs += "--add-data=docs;docs"
$pyinstallerArgs += "--hidden-import=numpy"
$pyinstallerArgs += "--hidden-import=sounddevice"
$pyinstallerArgs += "--hidden-import=soundfile"
$pyinstallerArgs += "--hidden-import=wx.adv"
$pyinstallerArgs += "--collect-data=sounddevice"
$pyinstallerArgs += "--collect-data=soundfile"
} else {
$pyinstallerArgs += $SpecFile
}
# Run PyInstaller
Write-ColorOutput Yellow "Running PyInstaller..."
& pyinstaller @pyinstallerArgs
if ($LASTEXITCODE -ne 0) {
Write-ColorOutput Red "Error: PyInstaller build failed."
exit 1
}
# Copy additional files and folders
Write-ColorOutput Yellow "Copying additional files and folders..."
$outputDir = if ($OneFile) { $DistDir } else { "$DistDir\MultiDeck" }
if (Test-Path "LICENSE") {
Copy-Item "LICENSE" $outputDir -Force
}
if (Test-Path "config.ini.example") {
Copy-Item "config.ini.example" $outputDir -Force
}
Write-Host ""
Write-ColorOutput Green "============================================"
Write-ColorOutput Green " Build completed successfully!"
Write-ColorOutput Green "============================================"
Write-Host ""
Write-Host "Output directory: $outputDir"
Write-Host ""
# Show build size
$size = (Get-ChildItem $outputDir -Recurse | Measure-Object -Property Length -Sum).Sum
$sizeMB = [math]::Round($size / 1MB, 2)
Write-Host "Total size: $sizeMB MB"
Write-Host ""
# Deactivate virtual environment
deactivate