41 lines
2.1 KiB
PowerShell
41 lines
2.1 KiB
PowerShell
# Construye el programa de escritorio de Caudal para Windows: un solo caudal.exe
|
|
# que lleva dentro su Python y se usa desde el navegador, sin instalar nada.
|
|
# Es el mismo que construir.sh hace en Linux y en Mac.
|
|
#
|
|
# powershell -ExecutionPolicy Bypass -File empaquetado\escritorio\construir.ps1 [carpeta de trabajo]
|
|
#
|
|
# Deja el fichero en <carpeta de trabajo>\dist\caudal.exe. Necesita Python 3.10 o
|
|
# posterior (de python.org, con «py» instalado) e internet: baja PyInstaller y las
|
|
# dependencias de Caudal a un entorno propio dentro de la carpeta de trabajo.
|
|
param([string]$Obra = "")
|
|
$ErrorActionPreference = "Stop"
|
|
$Raiz = (Resolve-Path (Join-Path $PSScriptRoot "..\..")).Path
|
|
if (-not $Obra) { $Obra = Join-Path $Raiz "empaquetado\escritorio\obra" }
|
|
New-Item -ItemType Directory -Force -Path $Obra | Out-Null
|
|
|
|
py -3 -m venv "$Obra\venv"
|
|
if ($LASTEXITCODE -ne 0) { throw "No se pudo crear el entorno de Python (¿está instalado Python 3 con «py»?)." }
|
|
& "$Obra\venv\Scripts\python.exe" -m pip install --quiet --upgrade pip
|
|
& "$Obra\venv\Scripts\python.exe" -m pip install --quiet -r "$Raiz\programa\requirements.txt" "pyinstaller>=6"
|
|
if ($LASTEXITCODE -ne 0) { throw "No se pudieron instalar las dependencias." }
|
|
|
|
$P = "$Raiz\programa"
|
|
Push-Location $Obra
|
|
try {
|
|
& "$Obra\venv\Scripts\pyinstaller.exe" --noconfirm --clean --onefile --name caudal `
|
|
--paths "$P" `
|
|
--add-data "$P\cartera\web:cartera/web" `
|
|
--add-data "$P\cartera\ejemplo:cartera/ejemplo" `
|
|
--add-data "$P\cartera\fiscal\reglas:cartera/fiscal/reglas" `
|
|
--add-data "$P\cartera\serie_btc_eur.csv:cartera" `
|
|
--add-data "$P\cartera\serie_ipv.json:cartera" `
|
|
--add-data "$P\cartera\serie_tierra.json:cartera" `
|
|
--add-data "$P\cartera\serie_vpo.json:cartera" `
|
|
--distpath "$Obra\dist" --workpath "$Obra\build" --specpath "$Obra" `
|
|
"$Raiz\empaquetado\escritorio\caudal.py"
|
|
if ($LASTEXITCODE -ne 0) { throw "PyInstaller ha fallado." }
|
|
} finally { Pop-Location }
|
|
|
|
$Exe = Join-Path $Obra "dist\caudal.exe"
|
|
Get-Item $Exe | Format-List Name, Length
|
|
Write-Host "SHA256: $((Get-FileHash -Algorithm SHA256 $Exe).Hash.ToLower())"
|