Skip to content

Commit

Permalink
Build shared libpython.so
Browse files Browse the repository at this point in the history
Our project (http://git.ligo.org/lscsoft/lalsuite,
https://pypi.org/project/lalsuite/) distributes several C command
line programs that embed Python interpreters by linking against
libpython, plus some Python C extensions modules (which of course
do not link against libpython).

For those rare cases like ours where Python embedding is required,
using a shared library libpython permits auditwheel to deduplicate
libpython and store only one copy in the wheel.
  • Loading branch information
lpsinger committed Feb 2, 2024
1 parent 1785b0b commit 5d8c92e
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 9 deletions.
4 changes: 2 additions & 2 deletions docker/build_scripts/build-cpython.sh
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ fi
# do not change the default for user built extension (yet?)
./configure \
CFLAGS_NODIST="${MANYLINUX_CFLAGS} ${MANYLINUX_CPPFLAGS} ${CFLAGS_EXTRA}" \
LDFLAGS_NODIST="${MANYLINUX_LDFLAGS}" \
--prefix=${PREFIX} --disable-shared --with-ensurepip=no > /dev/null
LDFLAGS_NODIST="${MANYLINUX_LDFLAGS} -Wl,--rpath=${PREFIX}/lib" \
--prefix=${PREFIX} --enable-shared --with-ensurepip=no > /dev/null
make > /dev/null
make install > /dev/null
popd
Expand Down
7 changes: 0 additions & 7 deletions docker/build_scripts/finalize-python.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,4 @@
# Stop at any error, show all commands
set -exuo pipefail

# most people don't need libpython*.a, and they're many megabytes.
# compress them all together for best efficiency
pushd /opt/_internal
XZ_OPT=-9e tar -cJf static-libs-for-embedding-only.tar.xz cpython-*/lib/libpython*.a
popd
find /opt/_internal -name '*.a' -print0 | xargs -0 rm -f

hardlink -cv /opt/_internal

0 comments on commit 5d8c92e

Please sign in to comment.