From: Daniele Varrazzo Date: Mon, 8 Nov 2021 18:14:28 +0000 (+0100) Subject: Strip only psycopg dynamic libraries, not the system ones X-Git-Tag: 3.0.3~10^2~2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=53484c3c5852ad72b851a19d6f9838a828b9148d;p=thirdparty%2Fpsycopg.git Strip only psycopg dynamic libraries, not the system ones Stripping symbols is beneficial (reduction of 30% of the final package, > %90% of the installed libraries. However just running `auditwheel repair --strip` breaks some of the libraries included from the system, which fail at import with errors such as "ELF load command address/offset not properly aligned". --- diff --git a/.github/workflows/packages.yml b/.github/workflows/packages.yml index 3286ab92a..82f123113 100644 --- a/.github/workflows/packages.yml +++ b/.github/workflows/packages.yml @@ -115,7 +115,9 @@ jobs: CIBW_BUILD: ${{matrix.pyver}}-manylinux_${{matrix.arch}} CIBW_ARCHS_LINUX: auto aarch64 ppc64le CIBW_BEFORE_ALL_LINUX: ./tools/build/wheel_linux_before_all.sh - CIBW_REPAIR_WHEEL_COMMAND: 'auditwheel repair --strip -w {dest_dir} {wheel}' + CIBW_REPAIR_WHEEL_COMMAND: >- + ./tools/build/strip_wheel.sh {wheel} + && auditwheel repair -w {dest_dir} {wheel} CIBW_TEST_REQUIRES: ./psycopg[test] ./psycopg_pool CIBW_TEST_COMMAND: pytest {project}/tests -m 'not slow' --color yes CIBW_ENVIRONMENT: >- diff --git a/tools/build/strip_wheel.sh b/tools/build/strip_wheel.sh new file mode 100755 index 000000000..a5ca605c0 --- /dev/null +++ b/tools/build/strip_wheel.sh @@ -0,0 +1,24 @@ +#!/bin/bash + +# Strip symbols inplace from the libraries in a zip archive. +# +# Stripping symbols is beneficial (reduction of 30% of the final package, > +# %90% of the installed libraries. However just running `auditwheel repair +# --strip` breaks some of the libraries included from the system, which fail at +# import with errors such as "ELF load command address/offset not properly +# aligned". +# +# System libraries are already pretty stripped. Ours go around 24Mb -> 1.5Mb... +# +# This script is designed to run on a wheel archive before auditwheel. + +set -euo pipefail +set -x + +wheel=$(realpath "$1") +tmpdir=$(mktemp -d) +trap "rm -r ${tmpdir}" EXIT + +unzip -d "${tmpdir}" "${wheel}" +find "${tmpdir}" -name \*.so | xargs strip +(cd "${tmpdir}" && zip -fr ${wheel} *)