Skip to content

Commit 5ffd617

Browse files
committed
chore: use dynamic build of OpenSSL
1 parent e2b24d9 commit 5ffd617

File tree

3 files changed

+22
-5
lines changed

3 files changed

+22
-5
lines changed

docker/Dockerfile

+2-2
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ FROM build_cpython AS build_cpython312
140140
COPY build_scripts/cpython-pubkey-312-313.txt /build_scripts/cpython-pubkeys.txt
141141
RUN manylinux-entrypoint /build_scripts/build-cpython.sh 3.12.3
142142

143-
FROM build_cpython AS all_cpython
143+
FROM build_cpython_system_ssl AS all_cpython
144144
COPY build_scripts/finalize-python.sh /build_scripts/
145145
RUN --mount=type=bind,target=/build_cpython36,from=build_cpython36 \
146146
--mount=type=bind,target=/build_cpython37,from=build_cpython37 \
@@ -156,7 +156,7 @@ RUN --mount=type=bind,target=/build_cpython36,from=build_cpython36 \
156156

157157
FROM runtime_base
158158
COPY --from=build_git /manylinux-rootfs /
159-
COPY --from=build_cpython /manylinux-rootfs /
159+
COPY --from=build_cpython_system_ssl /manylinux-rootfs /
160160
COPY build_scripts /opt/_internal/build_scripts/
161161
RUN --mount=type=bind,target=/all_cpython,from=all_cpython \
162162
cp -rf /all_cpython/opt/_internal/* /opt/_internal/ && \

docker/build_scripts/build-cpython.sh

+15-1
Original file line numberDiff line numberDiff line change
@@ -43,17 +43,31 @@ if [ "${AUDITWHEEL_POLICY}" == "manylinux2014" ] ; then
4343
export TCLTK_LIBS="-ltk8.6 -ltcl8.6"
4444
fi
4545

46+
OPENSSL_EXTRA=""
47+
OPENSSL_PREFIX=$(find /opt/_internal -maxdepth 1 -name 'openssl*')
48+
if [ "${OPENSSL_PREFIX}" != "" ]; then
49+
OPENSSL_EXTRA="--with-openssl=${OPENSSL_PREFIX}"
50+
case "${CPYTHON_VERSION}" in
51+
3.8.*|3.9.*) export LD_RUN_PATH=${OPENSSL_PREFIX}/lib;;
52+
*) OPENSSL_EXTRA="${OPENSSL_EXTRA} --with-openssl-rpath=auto";;
53+
esac
54+
fi
55+
4656
# configure with hardening options only for the interpreter & stdlib C extensions
4757
# do not change the default for user built extension (yet?)
4858
./configure \
4959
CFLAGS_NODIST="${MANYLINUX_CFLAGS} ${MANYLINUX_CPPFLAGS} ${CFLAGS_EXTRA}" \
50-
LDFLAGS_NODIST="${MANYLINUX_LDFLAGS}" \
60+
LDFLAGS_NODIST="${MANYLINUX_LDFLAGS}" ${OPENSSL_EXTRA} \
5161
--prefix=${PREFIX} --disable-shared --with-ensurepip=no > /dev/null
5262
make > /dev/null
5363
make install > /dev/null
5464
popd
5565
rm -rf Python-${CPYTHON_VERSION} Python-${CPYTHON_VERSION}.tgz Python-${CPYTHON_VERSION}.tgz.asc
5666

67+
if [ "${OPENSSL_PREFIX}" != "" ]; then
68+
rm -rf ${OPENSSL_PREFIX}/bin ${OPENSSL_PREFIX}/include ${OPENSSL_PREFIX}/lib/pkgconfig ${OPENSSL_PREFIX}/lib/*.so
69+
fi
70+
5771
# We do not need precompiled .pyc and .pyo files.
5872
clean_pyc ${PREFIX}
5973

docker/build_scripts/build-openssl.sh

+5-2
Original file line numberDiff line numberDiff line change
@@ -35,15 +35,18 @@ else
3535
apk del openssl-dev
3636
fi
3737
38+
PREFIX=/opt/_internal/openssl-${OPENSSL_VERSION%.*}
39+
3840
fetch_source ${OPENSSL_ROOT}.tar.gz ${OPENSSL_DOWNLOAD_URL}
3941
check_sha256sum ${OPENSSL_ROOT}.tar.gz ${OPENSSL_HASH}
4042
tar -xzf ${OPENSSL_ROOT}.tar.gz
4143
pushd ${OPENSSL_ROOT}
42-
./config no-shared --prefix=/usr/local/ssl --openssldir=/usr/local/ssl --libdir=lib CPPFLAGS="${MANYLINUX_CPPFLAGS}" CFLAGS="${MANYLINUX_CFLAGS} -fPIC" CXXFLAGS="${MANYLINUX_CXXFLAGS} -fPIC" LDFLAGS="${MANYLINUX_LDFLAGS} -fPIC" > /dev/null
44+
./Configure --prefix=${PREFIX} --openssldir=${PREFIX} --libdir=lib CPPFLAGS="${MANYLINUX_CPPFLAGS}" CFLAGS="${MANYLINUX_CFLAGS}" CXXFLAGS="${MANYLINUX_CXXFLAGS}" LDFLAGS="${MANYLINUX_LDFLAGS} -Wl,-rpath,\$(LIBRPATH)" > /dev/null
4345
make > /dev/null
4446
make install_sw > /dev/null
4547
popd
4648
rm -rf ${OPENSSL_ROOT} ${OPENSSL_ROOT}.tar.gz
4749
50+
strip_ ${PREFIX}
4851
49-
/usr/local/ssl/bin/openssl version
52+
${PREFIX}/bin/openssl version

0 commit comments

Comments
 (0)