mirror of
https://github.com/psycopg/psycopg2.git
synced 2024-11-25 18:33:44 +03:00
Strip debug symbols from binary packages
The _psycopg.so library goes down from 1.6mb to 300k in Linux packages.
This commit is contained in:
parent
8ef195f2ff
commit
d7c77f80b2
|
@ -41,6 +41,7 @@ done
|
||||||
|
|
||||||
# Bundle external shared libraries into the wheels
|
# Bundle external shared libraries into the wheels
|
||||||
for whl in "${prjdir}"/dist/*.whl; do
|
for whl in "${prjdir}"/dist/*.whl; do
|
||||||
|
"${dir}/strip_wheel.sh" "$whl"
|
||||||
auditwheel repair "$whl" -w "$distdir"
|
auditwheel repair "$whl" -w "$distdir"
|
||||||
done
|
done
|
||||||
|
|
||||||
|
|
|
@ -41,6 +41,7 @@ done
|
||||||
|
|
||||||
# Bundle external shared libraries into the wheels
|
# Bundle external shared libraries into the wheels
|
||||||
for whl in "${prjdir}"/dist/*.whl; do
|
for whl in "${prjdir}"/dist/*.whl; do
|
||||||
|
"${dir}/strip_wheel.sh" "$whl"
|
||||||
auditwheel repair "$whl" -w "$distdir"
|
auditwheel repair "$whl" -w "$distdir"
|
||||||
done
|
done
|
||||||
|
|
||||||
|
|
41
scripts/build/strip_wheel.sh
Executable file
41
scripts/build/strip_wheel.sh
Executable file
|
@ -0,0 +1,41 @@
|
||||||
|
#!/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. _psycopg2.so goes around
|
||||||
|
# 1.6M -> 300K (python 3.8, x86_64)
|
||||||
|
#
|
||||||
|
# This script is designed to run on a wheel archive before auditwheel.
|
||||||
|
|
||||||
|
set -euo pipefail
|
||||||
|
set -x
|
||||||
|
|
||||||
|
wheel=$(realpath "$1")
|
||||||
|
shift
|
||||||
|
|
||||||
|
# python or python3?
|
||||||
|
if which python > /dev/null; then
|
||||||
|
py=python
|
||||||
|
else
|
||||||
|
py=python3
|
||||||
|
fi
|
||||||
|
|
||||||
|
tmpdir=$(mktemp -d)
|
||||||
|
trap "rm -r ${tmpdir}" EXIT
|
||||||
|
|
||||||
|
cd "${tmpdir}"
|
||||||
|
$py -m zipfile -e "${wheel}" .
|
||||||
|
|
||||||
|
find . -name *.so -ls -exec strip "$@" {} \;
|
||||||
|
# Display the size after strip
|
||||||
|
find . -name *.so -ls
|
||||||
|
|
||||||
|
$py -m zipfile -c "${wheel}" *
|
||||||
|
|
||||||
|
cd -
|
Loading…
Reference in New Issue
Block a user