fix: add conditional stripping for Linux executables (#5223)
* fix: add conditional stripping for Linux executables (#2291)
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* Apply suggestion from @cobaltt7
---------
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: cobalt <61329810+cobaltt7@users.noreply.github.com>
diff --git a/.github/workflows/publish_binaries.yml b/.github/workflows/publish_binaries.yml
index 49e48b9..3de10c7 100644
--- a/.github/workflows/publish_binaries.yml
+++ b/.github/workflows/publish_binaries.yml
@@ -23,22 +23,27 @@
pathsep: ";"
asset_name: black_windows.exe
executable_mime: "application/vnd.microsoft.portable-executable"
+ strip: false
- os: windows-11-arm
pathsep: ";"
asset_name: black_windows-arm.exe
executable_mime: "application/vnd.microsoft.portable-executable"
+ strip: false
- os: ubuntu-latest
pathsep: ":"
asset_name: black_linux
executable_mime: "application/x-executable"
+ strip: true
- os: ubuntu-24.04-arm
pathsep: ":"
asset_name: black_linux-arm
executable_mime: "application/x-executable"
+ strip: true
- os: macos-latest
pathsep: ":"
asset_name: black_macos
executable_mime: "application/x-mach-binary"
+ strip: false
permissions:
contents: write # Needed to upload to release
@@ -56,8 +61,9 @@
- name: Build executable with PyInstaller
run:
- python -m PyInstaller -F --name ${{ matrix.asset_name }} --add-data
- 'src/blib2to3${{ matrix.pathsep }}blib2to3' src/black/__main__.py
+ python -m PyInstaller -F ${{ matrix.strip && '--strip' || '' }} --name ${{
+ matrix.asset_name }} --add-data 'src/blib2to3${{ matrix.pathsep }}blib2to3'
+ src/black/__main__.py
- name: Quickly test executable
run: |
diff --git a/CHANGES.md b/CHANGES.md
index 591a3bf..bfe4cae 100644
--- a/CHANGES.md
+++ b/CHANGES.md
@@ -68,6 +68,9 @@
<!-- Changes to how Black is packaged, such as dependency requirements -->
+- Reduce the size of Linux standalone binaries by stripping debug symbols during the
+ PyInstaller release build (#5223)
+
### Parser
<!-- Changes to the parser or to version autodetection -->