Skip to content

Commit 9fc1a89

Browse files
authored
feat: build mpdecimal for cpython 3.13+ (pypa#1709)
1 parent 0f80307 commit 9fc1a89

File tree

4 files changed

+67
-19
lines changed

4 files changed

+67
-19
lines changed

docker/Dockerfile

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -83,14 +83,14 @@ RUN export GIT_ROOT=git-2.47.0 && \
8383
export GIT_DOWNLOAD_URL=https://www.kernel.org/pub/software/scm/git && \
8484
manylinux-entrypoint /build_scripts/build-git.sh
8585

86-
87-
FROM build_base AS build_cpython_system_ssl
86+
FROM build_base AS build_sqlite3
8887
COPY build_scripts/build-sqlite3.sh /build_scripts/
8988
RUN export SQLITE_AUTOCONF_ROOT=sqlite-autoconf-3470000 && \
9089
export SQLITE_AUTOCONF_HASH=83eb21a6f6a649f506df8bd3aab85a08f7556ceed5dbd8dea743ea003fc3a957 && \
9190
export SQLITE_AUTOCONF_DOWNLOAD_URL=https://www.sqlite.org/2024 && \
9291
manylinux-entrypoint /build_scripts/build-sqlite3.sh
9392

93+
FROM build_base AS build_tcl_tk
9494
COPY build_scripts/build-tcltk.sh /build_scripts/
9595
RUN export TCL_ROOT=tcl8.6.14 && \
9696
export TCL_HASH=5880225babf7954c58d4fb0f5cf6279104ce1cd6aa9b71e9a6322540e1c4de66 && \
@@ -99,9 +99,21 @@ RUN export TCL_ROOT=tcl8.6.14 && \
9999
export TK_HASH=8ffdb720f47a6ca6107eac2dd877e30b0ef7fac14f3a84ebbd0b3612cee41a94 && \
100100
manylinux-entrypoint /build_scripts/build-tcltk.sh
101101

102-
COPY build_scripts/build-cpython.sh /build_scripts/
102+
FROM build_base AS build_mpdecimal
103+
COPY build_scripts/build-mpdecimal.sh /build_scripts/
104+
RUN export MPDECIMAL_ROOT=mpdecimal-4.0.0 && \
105+
export MPDECIMAL_HASH=942445c3245b22730fd41a67a7c5c231d11cb1b9936b9c0f76334fb7d0b4468c && \
106+
export MPDECIMAL_DOWNLOAD_URL=https://www.bytereef.org/software/mpdecimal/releases && \
107+
manylinux-entrypoint /build_scripts/build-mpdecimal.sh
103108

104109

110+
FROM build_base AS build_cpython_system_ssl
111+
COPY --from=build_tcl_tk /manylinux-buildfs /
112+
COPY --from=build_mpdecimal /manylinux-buildfs /
113+
COPY --from=build_sqlite3 /manylinux-buildfs /
114+
COPY build_scripts/build-cpython.sh /build_scripts/
115+
RUN if command -v apk >/dev/null 2>&1; then ldconfig /; else ldconfig; fi
116+
105117
FROM build_cpython_system_ssl AS build_cpython
106118
COPY build_scripts/build-openssl.sh /build_scripts/
107119
RUN export OPENSSL_ROOT=openssl-3.0.15 && \
@@ -118,7 +130,6 @@ FROM build_cpython_system_ssl AS build_cpython37
118130
COPY build_scripts/cpython-pubkeys.txt /build_scripts/cpython-pubkeys.txt
119131
RUN manylinux-entrypoint /build_scripts/build-cpython.sh 3.7.17
120132

121-
122133
FROM build_cpython AS build_cpython38
123134
COPY build_scripts/ambv-pubkey.txt /build_scripts/cpython-pubkeys.txt
124135
RUN manylinux-entrypoint /build_scripts/build-cpython.sh 3.8.20
@@ -149,8 +160,10 @@ RUN manylinux-entrypoint /build_scripts/build-cpython.sh 3.13.0 nogil
149160

150161

151162
FROM runtime_base
163+
COPY --from=build_tcl_tk /manylinux-rootfs /
164+
COPY --from=build_mpdecimal /manylinux-rootfs /
165+
COPY --from=build_sqlite3 /manylinux-rootfs /
152166
COPY --from=build_git /manylinux-rootfs /
153-
COPY --from=build_cpython_system_ssl /manylinux-rootfs /
154167
COPY build_scripts /opt/_internal/build_scripts/
155168
RUN --mount=type=bind,target=/build_cpython36,from=build_cpython36 \
156169
--mount=type=bind,target=/build_cpython37,from=build_cpython37 \
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
#!/bin/bash
2+
# Top-level build script called from Dockerfile
3+
4+
# Stop at any error, show all commands
5+
set -exuo pipefail
6+
7+
# Get script directory
8+
MY_DIR=$(dirname "${BASH_SOURCE[0]}")
9+
10+
# Get build utilities
11+
source $MY_DIR/build_utils.sh
12+
13+
# Install a more recent mpdecimal
14+
check_var ${MPDECIMAL_ROOT}
15+
check_var ${MPDECIMAL_HASH}
16+
check_var ${MPDECIMAL_DOWNLOAD_URL}
17+
18+
PREFIX=/opt/_internal/${MPDECIMAL_ROOT%%.*}
19+
20+
fetch_source ${MPDECIMAL_ROOT}.tar.gz ${MPDECIMAL_DOWNLOAD_URL}
21+
check_sha256sum ${MPDECIMAL_ROOT}.tar.gz ${MPDECIMAL_HASH}
22+
tar xfz ${MPDECIMAL_ROOT}.tar.gz
23+
pushd ${MPDECIMAL_ROOT}
24+
# add rpath
25+
sed -i "s|^Libs:|Libs: -Wl,--enable-new-dtags,-rpath=\${libdir} |g" ./libmpdec/.pc/libmpdec.pc.in
26+
DESTDIR=/manylinux-rootfs do_standard_install --prefix=${PREFIX} --enable-shared --enable-pc --disable-doc --disable-static --disable-cxx
27+
popd
28+
rm -rf ${MPDECIMAL_ROOT} ${MPDECIMAL_ROOT}.tar.gz
29+
30+
# Strip what we can
31+
strip_ /manylinux-rootfs
32+
33+
# Install for build
34+
mkdir /manylinux-buildfs
35+
cp -rlf /manylinux-rootfs/* /manylinux-buildfs/
36+
# copy pkgconfig
37+
mkdir -p /manylinux-buildfs/usr/local/lib/pkgconfig/
38+
ln -s ${PREFIX}/lib/pkgconfig/libmpdec.pc /manylinux-buildfs/usr/local/lib/pkgconfig/libmpdec.pc
39+
40+
# Clean-up for runtime
41+
rm -rf /manylinux-rootfs/${PREFIX}/lib/pkgconfig /manylinux-rootfs/${PREFIX}/include

docker/build_scripts/build-sqlite3.sh

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,9 @@ rm /manylinux-rootfs/usr/local/lib/libsqlite3.a
2828
# Strip what we can
2929
strip_ /manylinux-rootfs
3030

31-
# Install
32-
cp -rlf /manylinux-rootfs/* /
33-
if [ "${BASE_POLICY}" == "musllinux" ]; then
34-
ldconfig /
35-
elif [ "${BASE_POLICY}" == "manylinux" ]; then
36-
ldconfig
37-
fi
31+
# Install for build
32+
mkdir /manylinux-buildfs
33+
cp -rlf /manylinux-rootfs/* /manylinux-buildfs/
3834

3935
# Clean-up for runtime
4036
rm -rf /manylinux-rootfs/usr/local/share

docker/build_scripts/build-tcltk.sh

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ check_var ${TK_HASH}
2121
if [ "${AUDITWHEEL_POLICY}" == "manylinux2014" ] ; then
2222
yum erase -y tcl tk
2323
else
24+
mkdir -p /manylinux-rootfs
25+
mkdir -p /manylinux-buildfs
2426
exit 0
2527
fi
2628

@@ -50,13 +52,9 @@ rm /manylinux-rootfs/usr/local/lib/libtkstub8.6.a
5052
# Strip what we can
5153
strip_ /manylinux-rootfs
5254

53-
# Install
54-
cp -rlf /manylinux-rootfs/* /
55-
if [ "${BASE_POLICY}" == "musllinux" ]; then
56-
ldconfig /
57-
elif [ "${BASE_POLICY}" == "manylinux" ]; then
58-
ldconfig
59-
fi
55+
# Install for build
56+
mkdir /manylinux-buildfs
57+
cp -rlf /manylinux-rootfs/* /manylinux-buildfs/
6058

6159
# Clean-up for runtime
6260
rm -rf /manylinux-rootfs/usr/local/share

0 commit comments

Comments
 (0)