25 lines
1.8 KiB
PowerShell
25 lines
1.8 KiB
PowerShell
$ErrorActionPreference = 'Stop'
|
|
$taskRoot = $PSScriptRoot
|
|
$python = Join-Path $taskRoot '.venv\Scripts\python.exe'
|
|
if (!(Test-Path -LiteralPath $python)) { throw 'Create .venv and install requirements-dev.txt first.' }
|
|
$buildOriginalPath = $env:PATH
|
|
$buildOriginalCache = $env:PYINSTALLER_CONFIG_DIR
|
|
$basePython = & $python -c 'import sys; print(sys.base_prefix)'
|
|
# Do not accidentally bundle unrelated DLLs from other developer tools on PATH.
|
|
$env:PATH = @((Split-Path -Parent $python), $basePython, (Join-Path $basePython 'DLLs'), (Join-Path $env:SystemRoot 'System32'), $env:SystemRoot) -join ';'
|
|
$env:PYINSTALLER_CONFIG_DIR = Join-Path $taskRoot '.build-cache'
|
|
Push-Location $taskRoot
|
|
try {
|
|
& $python -m PyInstaller --noconfirm --clean --windowed --onedir --name FusionInputReceiver --exclude-module PySide6.QtWebEngineCore --exclude-module PySide6.QtWebEngineWidgets --exclude-module PySide6.QtQml --exclude-module PySide6.QtQuick --exclude-module tkinter --exclude-module matplotlib --exclude-module numpy --collect-submodules grpc --add-data 'protocol;protocol' main.py
|
|
if ($LASTEXITCODE -ne 0) { throw 'PyInstaller failed.' }
|
|
Copy-Item -LiteralPath (Join-Path $taskRoot '使用说明.txt') -Destination (Join-Path $taskRoot 'dist\FusionInputReceiver\使用说明.txt') -Force
|
|
Copy-Item -LiteralPath (Join-Path $taskRoot 'protocol') -Destination (Join-Path $taskRoot 'dist\FusionInputReceiver\protocol') -Recurse -Force
|
|
$archive = Join-Path $taskRoot 'dist\融合输入接收器_Windows_x64.zip'
|
|
Compress-Archive -LiteralPath (Join-Path $taskRoot 'dist\FusionInputReceiver') -DestinationPath $archive -Force
|
|
Get-Item -LiteralPath $archive | Select-Object FullName, Length
|
|
} finally {
|
|
Pop-Location
|
|
$env:PATH = $buildOriginalPath
|
|
$env:PYINSTALLER_CONFIG_DIR = $buildOriginalCache
|
|
}
|