]> git.ipfire.org Git - thirdparty/psycopg.git/commitdiff
Strip only psycopg dynamic libraries, not the system ones
authorDaniele Varrazzo <daniele.varrazzo@gmail.com>
Mon, 8 Nov 2021 18:14:28 +0000 (19:14 +0100)
committerDaniele Varrazzo <daniele.varrazzo@gmail.com>
Mon, 8 Nov 2021 19:02:19 +0000 (20:02 +0100)
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".

.github/workflows/packages.yml
tools/build/strip_wheel.sh [new file with mode: 0755]

index 3286ab92ad22e6884286d99bd53380d5ec43bf9a..82f1231138d5ee003257b88db0fcbb8118a64f41 100644 (file)
@@ -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 (executable)
index 0000000..a5ca605
--- /dev/null
@@ -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} *)