Fixed Agent Packaging Script

This commit is contained in:
2025-04-24 01:02:22 -06:00
parent 9c68cdea84
commit f1203c4451
5 changed files with 63 additions and 36 deletions

25
.gitignore vendored
View File

@ -1,10 +1,19 @@
.vs/ # Python Byte-compiled / Optimized / DLL files
__pycache__/
*.py[cod]
*$py.class
# Compiled Release Files
Borealis-Agent.exe
Borealis-Server.exe
# Pyinstaller Files
/Data/Agent/Packaging_Data/
/Data/Server/Packaging_Data/
# Development Folders
/Server/ /Server/
/Agent/ /Agent/
/Pyinstaller_Temp/
/dist/ # Misc Files/Folders
Borealis-Agent.exe .vs/s
/Data/Agent/Packaging_Data/
Borealis-Server.exe
/Data/Server/Packaging_Data/
borealis_directory_structure.txt

View File

@ -1,4 +1,4 @@
#////////// PROJECT FILE SEPARATION LINE ////////// CODE AFTER THIS LINE ARE FROM: <ProjectRoot>/Agent/Package_Borealis-Agent.ps1 #////////// PROJECT FILE SEPARATION LINE ////////// CODE AFTER THIS LINE ARE FROM: <ProjectRoot>/Data/Agent/Package_Borealis-Agent.ps1
# Configuration # Configuration
$packagingDir = "Packaging_Data" $packagingDir = "Packaging_Data"
@ -12,39 +12,57 @@ $finalExeName = "$outputName.exe"
$requirementsPath = "requirements.txt" $requirementsPath = "requirements.txt"
$iconPath = "..\Borealis.ico" $iconPath = "..\Borealis.ico"
# figure out where everything lives
$scriptDir = Split-Path $MyInvocation.MyCommand.Definition -Parent
$projectRoot = Resolve-Path (Join-Path $scriptDir "..\..")
$embeddedPython = Join-Path $projectRoot 'Dependencies\Python\python.exe'
# Ensure Packaging_Data directory exists # Ensure Packaging_Data directory exists
if (-Not (Test-Path $packagingDir)) { if (-Not (Test-Path $packagingDir)) {
New-Item -ItemType Directory -Path $packagingDir | Out-Null New-Item -ItemType Directory -Path $packagingDir | Out-Null
} }
# Set up virtual environment # 1) Create or recreate virtual environment using the embedded Python
if (-Not (Test-Path "$venvDir\Scripts\Activate.ps1")) { if (-Not (Test-Path "$venvDir\Scripts\python.exe")) {
Write-Host "[SETUP] Creating virtual environment at $venvDir" Write-Host "[SETUP] Creating virtual environment at $venvDir using embedded Python"
python -m venv $venvDir & $embeddedPython -m venv --upgrade-deps $venvDir
} }
# Activate virtual environment # helper for calling into that venv
Write-Host "[INFO] Activating virtual environment" $venvPy = Join-Path $venvDir 'Scripts\python.exe'
. "$venvDir\Scripts\Activate.ps1"
# Install agent dependencies from requirements file # 2) Bootstrap pip (in case ensurepip wasnt automatic) and upgrade
Write-Host "[INFO] Ensuring pip is available in the venv"
& $venvPy -m ensurepip --upgrade
Write-Host "[INFO] Upgrading pip"
& $venvPy -m pip install --upgrade pip
# 3) Install your agents dependencies
Write-Host "[INFO] Installing agent dependencies from $requirementsPath" Write-Host "[INFO] Installing agent dependencies from $requirementsPath"
pip install --upgrade pip > $null & $venvPy -m pip install -r $requirementsPath
pip install -r $requirementsPath > $null
# Install PyInstaller # 4) Install PyInstaller into that same venv
Write-Host "[INFO] Installing PyInstaller" Write-Host "[INFO] Installing PyInstaller"
pip install pyinstaller > $null & $venvPy -m pip install pyinstaller
# Clean previous build artifacts # 5) Clean previous build artifacts
Write-Host "[INFO] Cleaning previous build artifacts" Write-Host "[INFO] Cleaning previous build artifacts"
Remove-Item -Recurse -Force $distDir, $buildDir, "$specPath\$outputName.spec" -ErrorAction SilentlyContinue Remove-Item -Recurse -Force $distDir, $buildDir, "$specPath\$outputName.spec" -ErrorAction SilentlyContinue
# Run PyInstaller to create single-file executable with custom icon # 6) Run PyInstaller
Write-Host "[INFO] Running PyInstaller with icon $iconPath" Write-Host "[INFO] Running PyInstaller with icon $iconPath"
pyinstaller --onefile --icon "$iconPath" --noconfirm --name $outputName --distpath $distDir --workpath $buildDir --specpath $specPath $agentScript & $venvPy -m PyInstaller `
--onefile `
--icon "$iconPath" `
--noconfirm `
--name $outputName `
--distpath $distDir `
--workpath $buildDir `
--specpath $specPath `
$agentScript
# Copy resulting executable to Agent folder # 7) Copy the final exe back into your Agent folder
if (Test-Path "$distDir\$finalExeName") { if (Test-Path "$distDir\$finalExeName") {
Copy-Item "$distDir\$finalExeName" ".\$finalExeName" -Force Copy-Item "$distDir\$finalExeName" ".\$finalExeName" -Force
Write-Host "[SUCCESS] Agent packaged at .\$finalExeName" Write-Host "[SUCCESS] Agent packaged at .\$finalExeName"

View File

@ -1,4 +1,4 @@
#////////// PROJECT FILE SEPARATION LINE ////////// CODE AFTER THIS LINE ARE FROM: <ProjectRoot>/Package-Borealis-Server.ps1 #////////// PROJECT FILE SEPARATION LINE ////////// CODE AFTER THIS LINE ARE FROM: <ProjectRoot>/Data/Server/Package-Borealis-Server.ps1
# ------------------- CONFIGURATION ------------------- # ------------------- CONFIGURATION -------------------
$venvDir = "Pyinstaller_Virtual_Environment" $venvDir = "Pyinstaller_Virtual_Environment"

View File

@ -152,7 +152,7 @@ switch ($choice) {
<# <#
Step: Build React App Step: Build React App
#> #>
Run-Step "ReactJS Web Frontend: Build App" { Run-Step "ReactJS Web Frontend: " {
Push-Location $webUIDestination Push-Location $webUIDestination
& $npmCmd run build & $npmCmd run build
Pop-Location Pop-Location

Binary file not shown.