Skip to content

Fix packaged builds: bundle leapp_functions & assets, resolve report assets when frozen - #1646

Closed
abrignoni wants to merge 1 commit into
mainfrom
fix-pyinstaller-frozen-assets
Closed

abrignoni wants to merge 1 commit into
mainfrom
fix-pyinstaller-frozen-assets

Conversation

@abrignoni

Copy link
Copy Markdown
Owner

Problem

Building the CLI from scripts/pyinstaller/ileapp_macOS.spec on current main produces a broken binary. Two independent bugs, plus a size issue:

1. leapp_functions is not bundled → plugin loader crashes on startup

scripts/artifacts/apple_atx_images.py does:

from leapp_functions.parsers.apple_atx import decode_atx_file

Artifacts are loaded dynamically (plugin_loader.py), so PyInstaller's static analysis never sees leapp_functions and doesn't bundle it. Running the packaged binary:

ModuleNotFoundError: No module named 'leapp_functions.parsers'
[ileapp] Failed to execute script 'ileapp' due to unhandled exception!

This aborts the whole run (the loader imports every artifact at startup).

2. Report assets are resolved from Path.cwd() → no icons in a packaged binary

scripts/report.py loads its Tabler icons and correction JSON with paths relative to the current working directory:

Path.cwd().joinpath("assets/tabler_icons")
get_json_file_content('scripts/data/tabler_icon_correction.json')

That only works when iLEAPP is launched from the repo root. A packaged binary run from anywhere else logs:

Error: JSON file 'scripts/data/tabler_icon_correction.json' not found.
Error: File '.../assets/tabler_icons/home.svg' not found.

and generates a report with missing icons. The three CLI specs also never bundled assets/ at all (the GUI specs already do).

3. Size — unused heavy libs bundled

scipy, matplotlib, and pyarrow are imported by zero iLEAPP files (they come in transitively via pandas). They add a lot to the binary for nothing.

Fix

  • scripts/report.py — resolve assets/ and scripts/data/ from sys._MEIPASS when frozen, falling back to cwd from source (no behavior change when run from source). New _base_dir() helper.
  • All six specs (ileapp[_macOS/_Linux].spec, ileappGUI[_macOS/_Linux].spec) — add leapp_functions to datas + a hidden import for leapp_functions.parsers.apple_atx, and put the repo root on pathex so analysis can find it.
  • CLI specs — also bundle assets/ (the GUI specs already did).
  • All six specs — add scipy, matplotlib, pyarrow to excludes.

Testing

Built the macOS CLI (ileapp_macOS.spec) and verified end-to-end:

  • Loads all 295 artifacts, including apple_atx_images, with no import error.
  • Full parse of a test extraction from an unrelated working directory: report generates with Tabler icons rendered and no missing-asset errors.

The other five specs received the analogous change but were not built in this environment (no Windows/Linux here). They share the identical gaps, so the same fix applies.

…assets from _MEIPASS

PyInstaller CLI/GUI builds from main were broken:

1. leapp_functions not bundled. The apple_atx_images artifact imports
   leapp_functions.parsers.apple_atx; since artifacts load dynamically,
   PyInstaller never sees it, so the plugin loader crashed at startup with
   ModuleNotFoundError. Added leapp_functions to datas + a hidden import and
   put the repo root on pathex, on all six specs.

2. Report assets unreachable. report.py resolved assets/tabler_icons and
   scripts/data/*.json via Path.cwd(), which only works when run from the repo.
   A packaged binary launched elsewhere logged 'file not found' and produced a
   report with no icons. It now resolves from sys._MEIPASS when frozen. The CLI
   specs also did not bundle assets/ at all; added it (GUI specs already did).

3. Size. Excluded scipy, matplotlib and pyarrow (pulled in transitively via
   pandas but imported by zero iLEAPP files) to shrink the binaries.

Verified: built the macOS CLI from ileapp_macOS.spec, loaded all 295 artifacts
with no import error, and ran a full parse from an unrelated working directory
with icons rendered and no missing-asset errors. The other five specs received
the analogous change (not built here).
@JamesHabben JamesHabben added LEAPP Core Update related to LEAPP core framework Needs Cross Core Leveling for a PR that needs to be applied across other cores. remove once leveled to all. labels Jul 22, 2026
@abrignoni

Copy link
Copy Markdown
Owner Author

Closing as superseded.

The spec-file half of this landed on main in 4d0c4fc ("fix: declare the imports frozen builds crash without"), which bundles leapp_functions and assets in all six specs, additionally declares google.protobuf and PIL, and adds a regression test in admin/test/scripts/test_pyinstaller_unifiedlog_bundle.py.

The scripts/report.py half is obsolete: icon loading was rewritten to use the Tabler webfont CSS (scripts/_elements/tabler-icons.css), assets/tabler_icons/ was removed from the repo, and the remaining data paths resolve via Path(__file__).resolve().parent, which is already frozen-safe. The lint failure on this PR points at a line that no longer exists on main.

The only piece not applied is excludes=['scipy', 'matplotlib', 'pyarrow']. Those three are still unimported on main, but none is in requirements.txt or pulled transitively, so the exclusion is defensive only. If it's worth having, it belongs in a small PR against current main rather than a rebase of this branch across seven conflicting files.

@abrignoni abrignoni closed this Aug 7, 2026
@abrignoni
abrignoni deleted the fix-pyinstaller-frozen-assets branch September 19, 2026 13:32
Johann-PLW pushed a commit to Johann-PLW/iLEAPP that referenced this pull request Oct 7, 2026
Level the applicable ALEAPP abrignoni#1646 fixes with regression coverage.

Co-Authored-By: OpenAI Codex (GPT-6) <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

LEAPP Core Update related to LEAPP core framework Needs Cross Core Leveling for a PR that needs to be applied across other cores. remove once leveled to all.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants