Fixed Agent Packaging Script
This commit is contained in:
parent
9c68cdea84
commit
f1203c4451
25
.gitignore
vendored
25
.gitignore
vendored
@ -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/
|
||||
/Agent/
|
||||
/Pyinstaller_Temp/
|
||||
/dist/
|
||||
Borealis-Agent.exe
|
||||
/Data/Agent/Packaging_Data/
|
||||
Borealis-Server.exe
|
||||
/Data/Server/Packaging_Data/
|
||||
borealis_directory_structure.txt
|
||||
|
||||
# Misc Files/Folders
|
||||
.vs/s
|
@ -1,50 +1,68 @@
|
||||
#////////// 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
|
||||
$packagingDir = "Packaging_Data"
|
||||
$venvDir = "$packagingDir\Pyinstaller_Virtual_Environment"
|
||||
$distDir = "$packagingDir\dist"
|
||||
$buildDir = "$packagingDir\build"
|
||||
$specPath = "$packagingDir"
|
||||
$agentScript = "borealis-agent.py"
|
||||
$outputName = "Borealis-Agent"
|
||||
$finalExeName = "$outputName.exe"
|
||||
$packagingDir = "Packaging_Data"
|
||||
$venvDir = "$packagingDir\Pyinstaller_Virtual_Environment"
|
||||
$distDir = "$packagingDir\dist"
|
||||
$buildDir = "$packagingDir\build"
|
||||
$specPath = "$packagingDir"
|
||||
$agentScript = "borealis-agent.py"
|
||||
$outputName = "Borealis-Agent"
|
||||
$finalExeName = "$outputName.exe"
|
||||
$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
|
||||
if (-Not (Test-Path $packagingDir)) {
|
||||
New-Item -ItemType Directory -Path $packagingDir | Out-Null
|
||||
}
|
||||
|
||||
# Set up virtual environment
|
||||
if (-Not (Test-Path "$venvDir\Scripts\Activate.ps1")) {
|
||||
Write-Host "[SETUP] Creating virtual environment at $venvDir"
|
||||
python -m venv $venvDir
|
||||
# 1) Create or recreate virtual environment using the embedded Python
|
||||
if (-Not (Test-Path "$venvDir\Scripts\python.exe")) {
|
||||
Write-Host "[SETUP] Creating virtual environment at $venvDir using embedded Python"
|
||||
& $embeddedPython -m venv --upgrade-deps $venvDir
|
||||
}
|
||||
|
||||
# Activate virtual environment
|
||||
Write-Host "[INFO] Activating virtual environment"
|
||||
. "$venvDir\Scripts\Activate.ps1"
|
||||
# helper for calling into that venv
|
||||
$venvPy = Join-Path $venvDir 'Scripts\python.exe'
|
||||
|
||||
# Install agent dependencies from requirements file
|
||||
# 2) Bootstrap pip (in case ensurepip wasn’t 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 agent’s dependencies
|
||||
Write-Host "[INFO] Installing agent dependencies from $requirementsPath"
|
||||
pip install --upgrade pip > $null
|
||||
pip install -r $requirementsPath > $null
|
||||
& $venvPy -m pip install -r $requirementsPath
|
||||
|
||||
# Install PyInstaller
|
||||
# 4) Install PyInstaller into that same venv
|
||||
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"
|
||||
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"
|
||||
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") {
|
||||
Copy-Item "$distDir\$finalExeName" ".\$finalExeName" -Force
|
||||
Write-Host "[SUCCESS] Agent packaged at .\$finalExeName"
|
||||
|
@ -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 -------------------
|
||||
$venvDir = "Pyinstaller_Virtual_Environment"
|
||||
|
@ -152,7 +152,7 @@ switch ($choice) {
|
||||
<#
|
||||
Step: Build React App
|
||||
#>
|
||||
Run-Step "ReactJS Web Frontend: Build App" {
|
||||
Run-Step "ReactJS Web Frontend: " {
|
||||
Push-Location $webUIDestination
|
||||
& $npmCmd run build
|
||||
Pop-Location
|
||||
|
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user