diff --git a/scripts/build.ps1 b/scripts/build.ps1 index 6127dfa7..3b00848b 100644 --- a/scripts/build.ps1 +++ b/scripts/build.ps1 @@ -22,9 +22,13 @@ try { '--additional-hooks-dir=Pyinstaller/hooks', "--add-data=pyproject.toml$([System.IO.Path]::PathSeparator).", '--icon=res/icon.ico') - if (-not $WineCompat) { + # Don't UPX compress if trying to be Wine Compatible, or on Linux (handled manually below) + if (-not $WineCompat -and -not $IsLinux) { $arguments += '--upx-dir=scripts/.upx' } + else { + $arguments += '--noupx' + } if ($SupportsSplashScreen) { # https://github.com/pyinstaller/pyinstaller/issues/9022 $arguments += @('--splash=res/splash.png') @@ -43,7 +47,7 @@ try { '--strip') } - Write-Output $arguments + Write-Output "pyinstaller $($arguments -join ' ')" & uv run --active pyinstaller @arguments if ($IsLinux) { @@ -53,6 +57,13 @@ try { Move-Item build/AppDir/AutoSplit/_internal build/AppDir/_internal Remove-Item build/AppDir/AutoSplit + # PyInstaller's --strip breaks ELF load command alignment in all of numpy's vendored libs. + # Restore all original unstripped libraries from site-packages. + $numpyLibsSrc = uv run --active python -c "import numpy, pathlib; print(pathlib.Path(numpy.__file__).parent.parent / 'numpy.libs')" + if (Test-Path $numpyLibsSrc) { + Copy-Item -Path "$numpyLibsSrc/*" -Destination 'build/AppDir/_internal/numpy.libs/' -Force + } + if ([System.Runtime.InteropServices.RuntimeInformation]::OSArchitecture -eq 'X64') { # Technically UPX works for Linux executables, but trying to compress .so can still result in Segmentation fault # https://github.com/orgs/pyinstaller/discussions/8922#discussioncomment-13185670 @@ -64,7 +75,9 @@ try { $_.Directory -like '*/AppDir/_internal' -or # _internal/PySide6/Qt/*/*.so* causes Segmentation fault # _internal/PySide6/Qt/plugins/*/*.so* breaks style - $_.Directory -like '*/AppDir/_internal/PySide6/Qt/*' + $_.Directory -like '*/AppDir/_internal/PySide6/Qt/*' -or + # numpy.libs: --strip breaks ELF load alignment in all bundled libs (restored below) — skip UPX to avoid re-breaking them + $_.Directory -like '*/AppDir/_internal/numpy.libs' ) } try {