Skip to content

fix: add conditional stripping for Linux executables#5223

Open
vaibhavxlr wants to merge 2 commits into
psf:mainfrom
vaibhavxlr:fix/linux-exec
Open

fix: add conditional stripping for Linux executables#5223
vaibhavxlr wants to merge 2 commits into
psf:mainfrom
vaibhavxlr:fix/linux-exec

Conversation

@vaibhavxlr

@vaibhavxlr vaibhavxlr commented Jul 5, 2026

Copy link
Copy Markdown

Description

This essentially fixes #2291.

I tried building the Linux executable on my machine ( Ubuntu 24.04 x86_64 desktop running Python 3.14 ) and found that executable generated was around ~12M, roughly the same size of PE and Mach-O generated by the Github Action workflow.

On analysing the executable a bit, I found the main difference was the size of Python interpreter being bundled by PyInstaller. Following is the size comparison-

On my local-

-rw-r--r-- 1 root root 8.7M Mar 24 00:34 /usr/lib/x86_64-linux-gnu/libpython3.14.so.1.0

On Github Action runner-

-rwxrwxrwx 1 runner packer 31M Jun 28 21:54 /opt/hostedtoolcache/Python/3.14.6/x64/lib/libpython3.14.so.1.0

And this is what file command returned-

On my local-

/usr/lib/x86_64-linux-gnu/libpython3.14.so.1.0: ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), dynamically linked, BuildID[sha1]=0d148f3b8bdf451ed0e7e416957307e9b691032b, stripped

On Github Action runner-

/opt/hostedtoolcache/Python/3.14.6/x64/lib/libpython3.14.so.1.0: ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), dynamically linked, BuildID[sha1]=e6fdb4bf77689f4fbc54f28b6562a4c5121963df, with debug_info, not stripped

As we can see Github Action libpython is not stripped and carries DWARF data, as compared to what gets shipped on Ubuntu systems by default. It didn't make sense to me that release builds carried debug information anyway. I looked up a bit and found that PyInstaller offered --strip, which made sense over manually stripping the libpython provided by the runner's environment.

As it is not recommended to be used on Windows and the Mac executable seemed fine, I have added the appropriate matrix based check.

I ran the workflow on my fork and these are the results-
image

I also did some sanity tests locally by trying to format some projects using the above x86_64 build just to be on safer side.

Checklist - did you ...

  • Implement any code style changes under the --preview style, following the stability policy?
  • Add an entry in CHANGES.md if necessary?
  • Add / update tests if necessary?
  • Add new / update outdated documentation?

@vaibhavxlr vaibhavxlr changed the title fix: add conditional stripping for Linux executables (#2291) fix: add conditional stripping for Linux executables Jul 5, 2026
@cobaltt7

cobaltt7 commented Jul 5, 2026

Copy link
Copy Markdown
Collaborator

Thanks! Can you add a changelog entry?

@vaibhavxlr

Copy link
Copy Markdown
Author

Thanks! Can you add a changelog entry?

Hey, it's done.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Debug Linux self contained binary size + reduce if possible

2 participants