Repository navigation
Shrink win install - #2346
Shrink win install#2346
Conversation
There was a problem hiding this comment.
Warning
Copilot couldn't run its full agentic review because it didn't start before the timeout. Make sure your repository has a runner available, or add a copilot-code-review.yml file specifying one with the runs-on attribute. See the docs for more details.
Copilot review overview
3 open issues
What changed in this PR
Reduces PyInstaller bundle size by excluding unused pymavlink dialects and trimming platform-irrelevant / unused packaged files from the build artifacts.
Changes:
- Filter
pymavlinkhidden imports to only include required MAVLink dialects and exclude the rest explicitly. - Exclude
lxmland prune unnecessary binaries/data (e.g., non-target selenium-manager binaries, unused PIL/matplotlib assets). - Tighten collected package data on macOS/Linux by excluding translation sources and build artifacts.
| File | Description |
|---|---|
| windows/ardupilot_methodic_configurator.spec | Filters pymavlink dialect modules, excludes lxml, and prunes unused binaries/datas (platform-specific + unused assets). |
| macos/ardupilot_methodic_configurator.spec | Adds re, narrows collected data files, filters pymavlink dialects, excludes lxml, and prunes unused binaries/datas. |
| linux/ardupilot_methodic_configurator.spec | Adds re, narrows collected data files, filters pymavlink dialects, excludes lxml, and prunes unused binaries/datas. |
Review effort: Lite
| _UNUSED_FILE_PATTERNS = ( | ||
| re.compile(r"(^|[\\/])PIL[\\/]_avif\.[^\\/]*$"), # AVIF images are not used | ||
| re.compile(r"(^|[\\/])matplotlib[\\/]mpl-data[\\/]fonts[\\/](afm|pdfcorefonts)[\\/]"), # only used by PostScript/PDF output | ||
| ) |
| # Pymavlink ships one large module per MAVLink dialect; the application only uses these. | ||
| USED_MAVLINK_DIALECTS = {"all", "ardupilotmega"} | ||
|
|
||
|
|
||
| def _is_unused_mavlink_dialect(module_name: str) -> bool: | ||
| parts = module_name.split(".") | ||
| return len(parts) >= 4 and parts[:2] == ["pymavlink", "dialects"] and parts[3] not in USED_MAVLINK_DIALECTS |
| # Remove files that the application cannot use on this platform or does not need. | ||
| _UNUSED_PATH_PREFIXES = tuple( | ||
| os.path.join("selenium", "webdriver", "common", folder) + os.sep for folder in ("macos", "windows") | ||
| ) # selenium wheels bundle selenium-manager for every OS | ||
| _UNUSED_FILE_PATTERNS = ( | ||
| re.compile(r"(^|[\\/])PIL[\\/]_avif\.[^\\/]*$"), # AVIF images are not used | ||
| re.compile(r"(^|[\\/])matplotlib[\\/]mpl-data[\\/]fonts[\\/](afm|pdfcorefonts)[\\/]"), # only used by PostScript/PDF output | ||
| ) | ||
|
|
||
|
|
||
| def _is_unused_file(entry: tuple) -> bool: | ||
| destination = os.path.normpath(entry[0]) | ||
| return destination.startswith(_UNUSED_PATH_PREFIXES) or any(pattern.search(destination) for pattern in _UNUSED_FILE_PATTERNS) |
Previous review (2026-11-09)Automated review note — AI-generated (Claude+Codex), validated against the live diff. Please sanity-check before acting. Reviewed at head The size reductions work and the kept dialects, plugins and log validation still run in the frozen Linux build, but one environment-dependent startup crash should be fixed. Should fix
Minor (2)
Copilot's missing |
316de3d to
0950a70
Compare
☂️ Code Coverage
Overall Coverage
New FilesNo new covered files... Modified FilesNo covered modified files...
|
Previous review (2026-11-09)Automated review note — AI-generated (Claude+Codex), validated against the live diff. Please sanity-check before acting. Reviewed at head The bundle shrink holds up and the frozen Linux build works; one CodeQL-flagged regex should still be simplified. This review is of head Should fix
Minor (2)
Not fully reviewed: native Windows and macOS frozen runs, Linux arm64, frozen GUI flows (FC connection, tuning plots, Selenium web tools) and the full GUI pytest suite were not exercised. |
…ries
The 5.1.0 installer grew by about 3.8 MB over 5.0.2 (62.3 -> 66.1 MB).
Inspecting the bundle showed that much of it is never used on Windows or
by the application at all:
- Pillow's _avif extension (7.5 MB): AVIF images are not used. Pillow
treats the plug-in as optional and falls back cleanly.
- selenium-manager for Linux and macOS (about 17 MB): selenium wheels bundle
one binary per OS, and only the Windows one can run. It is still used by
the web log tools to locate the Chrome driver, so it is kept.
- lxml (6.7 MB): only imported lazily by pymavlink's dialect generator
(mavgen) and its optional log-metadata parser, neither of which the
application uses.
- 11 unused MAVLink dialect modules, in both the v10 and v20 variants
(about 34 MB of source, a large part of the 26.9 MB exe):
collect_submodules("pymavlink") bundled every dialect. Only "all"
(mavutil's default dialect) and "ardupilotmega" (imported directly by the
app) are kept.
- matplotlib afm/pdfcorefonts data (1.3 MB): only used by the PostScript
and PDF backends.
Dialect modules are removed both from the hidden imports and through
Analysis(excludes=...) so that static imports cannot pull them back in.
Binaries and data are filtered in the TOC by destination path, so
the Windows selenium-manager.exe and the Tk/Pillow libraries that are
needed stay untouched.
Verified with a test PyInstaller build (Python 3.14 venv, so not a strict
before/after with the 3.15 installer): the removed files are absent, the
exe shrank from 26.9 MB to 19.7 MB, and the frozen exe runs --version,
--help and --validate-bin-log on tests/fixtures/backend_log_80k.bin.
The installer applies solid LZMA, which already deduplicates the similar
dialect files, so the final installer saving is expected to be a fraction
of the uncompressed numbers.
Signed-off-by: Amilcar do Carmo Lucas <amilcar.lucas@iav.de>
The Linux and macOS specs bundled the same unused content that was removed
from the Windows spec:
- Every pymavlink MAVLink dialect (about 42 MB of source) through
collect_submodules("pymavlink"). Only "all" (mavutil's default dialect)
and "ardupilotmega" (imported directly by the app) are kept, in both the
v10 and v20 variants. Unused dialects are removed from the hidden imports
and through Analysis(excludes=...) so static imports cannot pull them back.
- lxml, which pymavlink imports only in its dialect generator and in an
optional log-metadata parser that the application never uses.
- Pillow's _avif extension, because AVIF images are not used.
- matplotlib's afm and pdfcorefonts data, only used by PostScript/PDF output.
- selenium-manager binaries for the other operating systems. Linux keeps
the linux* binaries and macOS keeps the macos one.
- The .po and .pot translation sources (about 5 MB), because collect_data_files
shipped every non-Python file. Only the compiled .mo files are needed.
collect_data_files now also skips any build/ and dist/ directory inside the
package, so a previous local PyInstaller output is not bundled recursively.
Verified by building the Linux spec with Python 3.15.2 on a development
machine: the removed files are absent, the Linux selenium-manager binaries
are kept, and the frozen executable validates a sample .bin log. The macOS
spec received the identical change but could not be built there.
Signed-off-by: Amilcar do Carmo Lucas <amilcar.lucas@iav.de>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
0950a70 to
8b78224
Compare
|
Automated review note — AI-generated (Claude+Codex), validated against the live diff. Please sanity-check before acting. Reviewed at head Nothing blocking at head |


Description
Do not ship unused files
Checklist
git commit --signoff)Testing
Describe how you tested these changes: