blob: bfcd302565797b294b5549d25ae3f923d88e03e2 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
|
#!/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
source /etc/os-release
dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
wheel=$(realpath "$1")
shift
tmpdir=$(mktemp -d)
trap "rm -r ${tmpdir}" EXIT
cd "${tmpdir}"
python -m zipfile -e "${wheel}" .
echo "
Libs before:"
# Busybox doesn't have "find -ls"
find . -name \*.so | xargs ls -l
# On Debian, print the package versions libraries come from
echo "
Dependencies versions of '_psycopg.so' library:"
"${dir}/print_so_versions.sh" "$(find . -name \*_psycopg\*.so)"
find . -name \*.so -exec strip "$@" {} \;
echo "
Libs after:"
find . -name \*.so | xargs ls -l
python -m zipfile -c ${wheel} *
cd -
|