Skip to content

Commit 06bea41

Browse files
authored
Support python with ssl (#96)
1 parent 47a2b72 commit 06bea41

File tree

2 files changed

+28
-5
lines changed

2 files changed

+28
-5
lines changed

Dockerfile.python

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ RUN apt update -y -q && apt upgrade -y -q && apt update -y -q && \
1111
apt -q install -y \
1212
curl \
1313
git \
14-
libssl-dev \
1514
unzip \
15+
patchelf \
1616
xz-utils
1717

1818
RUN mkdir -p /root

python/build.sh

Lines changed: 27 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,24 +18,47 @@ fi
1818
REVISION="python-${VERSION}"
1919
initialise "${REVISION}" "${OUTPUT}" "${LAST_REVISION}"
2020

21-
DEST=/root/built
21+
SSL_PREFIX=/root/ssl
22+
SSL_VERSION=3.3.2
23+
curl -sL https://github.com/openssl/openssl/releases/download/openssl-${SSL_VERSION}/openssl-${SSL_VERSION}.tar.gz | tar zxf -
24+
pushd openssl-${SSL_VERSION}
25+
./Configure --prefix=${SSL_PREFIX}
26+
make -j$(nproc)
27+
make install_sw
28+
popd
29+
30+
# Python seems to hardcode ssldir/lib and not ssldir/lib64
31+
ln -s lib64 ${SSL_PREFIX}/lib
32+
33+
# The rpath below seems to not quite "take"
34+
export LD_LIBRARY_PATH=${SSL_PREFIX}/lib64
35+
36+
DEST=/root/python
2237

2338
curl -sL https://www.python.org/ftp/python/${VERSION}/Python-${VERSION}.tgz | tar zxf -
2439
pushd Python-${VERSION}
2540
./configure \
2641
--prefix=${DEST} \
27-
--enable-optimizations \
28-
--without-pymalloc
42+
--with-openssl=${SSL_PREFIX} \
43+
--with-openssl-rpath=${SSL_PREFIX}/lib64 \
44+
--without-pymalloc \
45+
--enable-optimizations
2946

3047
make -j$(nproc)
3148
make install
3249
popd
3350

51+
# copy SSL SOs to the same directory as the native python modules
52+
cp ${SSL_PREFIX}/lib64/*.so* /root/python/lib/python*/lib-dynload/
53+
54+
# then patch the ssl to look at $ORIGIN to find the crypto libs
55+
patchelf --set-rpath \$ORIGIN /root/python/lib/python*/lib-dynload/_ssl*.so
56+
3457
# strip executables
3558
find ${DEST} -type f -perm /u+x -exec strip -d {} \;
3659

3760
# delete tests and static libraries to save disk space
3861
find ${DEST} -type d -name test -exec rm -rf {} +
39-
find ${DEST} -type f -name *.a -delete
62+
find ${DEST} -type f -name '*.a' -delete
4063

4164
complete "${DEST}" "${FULLNAME}" "${OUTPUT}"

0 commit comments

Comments
 (0)