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: >-
--- /dev/null
+#!/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} *)