Skip to content

Commit

Permalink
Keep libpython static libraries in compressed form (#1250)
Browse files Browse the repository at this point in the history
Fixes #91
  • Loading branch information
rdb authored and mayeut committed Jan 9, 2022
1 parent b3aff19 commit 209f6a4
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 6 deletions.
8 changes: 5 additions & 3 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -135,16 +135,18 @@ RUN manylinux-entrypoint /build_scripts/build-cpython.sh 3.10.1


FROM build_cpython AS all_python
COPY build_scripts/install-pypy.sh /build_scripts/install-pypy.sh
COPY build_scripts/pypy.sha256 /build_scripts/pypy.sha256
COPY build_scripts/install-pypy.sh \
build_scripts/pypy.sha256 \
build_scripts/finalize-python.sh \
/build_scripts/
RUN manylinux-entrypoint /build_scripts/install-pypy.sh 3.7 7.3.7
RUN manylinux-entrypoint /build_scripts/install-pypy.sh 3.8 7.3.7
COPY --from=build_cpython36 /opt/_internal /opt/_internal/
COPY --from=build_cpython37 /opt/_internal /opt/_internal/
COPY --from=build_cpython38 /opt/_internal /opt/_internal/
COPY --from=build_cpython39 /opt/_internal /opt/_internal/
COPY --from=build_cpython310 /opt/_internal /opt/_internal/
RUN hardlink -cv /opt/_internal
RUN manylinux-entrypoint /build_scripts/finalize-python.sh


FROM runtime_base
Expand Down
3 changes: 0 additions & 3 deletions docker/build_scripts/build-cpython.sh
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,6 @@ fi
popd
rm -rf Python-${CPYTHON_VERSION} Python-${CPYTHON_VERSION}.tgz Python-${CPYTHON_VERSION}.tgz.asc

# we don't need libpython*.a, and they're many megabytes
find ${PREFIX} -name '*.a' -print0 | xargs -0 rm -f

# We do not need precompiled .pyc and .pyo files.
clean_pyc ${PREFIX}

Expand Down
13 changes: 13 additions & 0 deletions docker/build_scripts/finalize-python.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/bin/bash

# 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 209f6a4

Please sign in to comment.