Skip to content

Commit 9a071e0

Browse files
committed
ci: use cache for OpenSSL build
1 parent 1ed6c5b commit 9a071e0

File tree

4 files changed

+58
-36
lines changed

4 files changed

+58
-36
lines changed

.github/workflows/build.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,13 @@ jobs:
9393
uses: docker/[email protected]
9494
if: matrix.use_qemu && fromJSON(env.USE_QEMU)
9595

96+
- name: Cache OpenSSL build
97+
if: runner.os == 'Linux'
98+
uses: actions/cache@v2
99+
with:
100+
path: .cache-openssl
101+
key: ${{ matrix.os }}-${{ matrix.build }}${{ matrix.arch }}-${{ hashFiles('scripts/manylinux-build-and-install-openssl.sh') }}
102+
96103
- name: Build wheels
97104
uses: pypa/[email protected]
98105
if: (!matrix.use_qemu) || fromJSON(env.USE_QEMU)

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,3 +60,6 @@ docs/_build
6060
# IDE junk
6161
.idea/*
6262
*.swp
63+
64+
# OpenSSL build cache
65+
.cache-openssl/

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ before-all = [
3131

3232
[tool.cibuildwheel.linux.environment]
3333
SKBUILD_CONFIGURE_OPTIONS = "-DOPENSSL_ROOT_DIR:PATH=/usr/local/ssl -DCMAKE_JOB_POOL_COMPILE:STRING=compile -DCMAKE_JOB_POOL_LINK:STRING=link -DCMAKE_JOB_POOLS:STRING=compile=2;link=1"
34+
OPENSSL_CACHE_DIR = "home/runner/work/cmake-python-distributions/cmake-python-distributions/.cache-openssl"
3435

3536
[tool.cibuildwheel.macos.environment]
3637
MACOSX_DEPLOYMENT_TARGET = "10.10"

scripts/manylinux-build-and-install-openssl.sh

Lines changed: 47 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -14,48 +14,59 @@ OPENSSL_ROOT=openssl-3.0.0
1414
# Hash from https://www.openssl.org/source/openssl-3.0.0.tar.gz.sha256
1515
OPENSSL_HASH=59eedfcb46c25214c9bd37ed6078297b4df01d012267fe9e9eee31f61bc70536
1616

17-
cd /tmp
17+
OPENSSL_ARCHIVE=/host/${OPENSSL_CACHE_DIR}/${OPENSSL_ROOT}-${AUDITWHEEL_PLAT}.tar.gz
1818

19-
if ! perl -e 'use 5.10.0' &> /dev/null; then
20-
# perl>=5.10.0 is needed to build openssl
21-
PERL_ROOT=perl-5.32.1
22-
# Hash from https://www.cpan.org/src/5.0/perl-5.32.1.tar.gz.sha256.txt
23-
PERL_HASH=03b693901cd8ae807231b1787798cf1f2e0b8a56218d07b7da44f784a7caeb2c
2419

25-
curl -fsSLO https://www.cpan.org/src/5.0/${PERL_ROOT}.tar.gz
26-
check_sha256sum ${PERL_ROOT}.tar.gz ${PERL_HASH}
27-
tar -xzf ${PERL_ROOT}.tar.gz
28-
rm -rf ${PERL_ROOT}.tar.gz
20+
if ! [ -e "${OPENSSL_ARCHIVE}" ]; then
21+
cd /tmp
2922

30-
pushd ${PERL_ROOT}
31-
./Configure -des -Dprefix=/tmp/perl-openssl > /dev/null
32-
make -j$(nproc) > /dev/null
33-
make install > /dev/null
34-
popd
35-
export PATH=/tmp/perl-openssl/bin:${PATH}
36-
else
37-
if [ "${AUDITWHEEL_PLAT:0:9}" == "manylinux" ]; then
38-
# more perl modules are needed than the bare minimum already installed in CentOS
39-
# c.f. https://github.com/openssl/openssl/blob/openssl-3.0.0/NOTES-PERL.md#general-notes
40-
yum -y install perl-core
23+
if ! perl -e 'use 5.10.0' &> /dev/null; then
24+
# perl>=5.10.0 is needed to build openssl
25+
PERL_ROOT=perl-5.32.1
26+
# Hash from https://www.cpan.org/src/5.0/perl-5.32.1.tar.gz.sha256.txt
27+
PERL_HASH=03b693901cd8ae807231b1787798cf1f2e0b8a56218d07b7da44f784a7caeb2c
28+
29+
curl -fsSLO https://www.cpan.org/src/5.0/${PERL_ROOT}.tar.gz
30+
check_sha256sum ${PERL_ROOT}.tar.gz ${PERL_HASH}
31+
tar -xzf ${PERL_ROOT}.tar.gz
32+
rm -rf ${PERL_ROOT}.tar.gz
33+
34+
pushd ${PERL_ROOT}
35+
./Configure -des -Dprefix=/tmp/perl-openssl > /dev/null
36+
make -j$(nproc) > /dev/null
37+
make install > /dev/null
38+
popd
39+
export PATH=/tmp/perl-openssl/bin:${PATH}
40+
else
41+
if [ "${AUDITWHEEL_PLAT:0:9}" == "manylinux" ]; then
42+
# more perl modules are needed than the bare minimum already installed in CentOS
43+
# c.f. https://github.com/openssl/openssl/blob/openssl-3.0.0/NOTES-PERL.md#general-notes
44+
yum -y install perl-core
45+
fi
4146
fi
42-
fi
4347

44-
# Download
45-
curl -fsSLO http://www.openssl.org/source/${OPENSSL_ROOT}.tar.gz
46-
check_sha256sum ${OPENSSL_ROOT}.tar.gz ${OPENSSL_HASH}
47-
tar -xzf ${OPENSSL_ROOT}.tar.gz
48-
rm -rf ${OPENSSL_ROOT}.tar.gz
48+
# Download
49+
curl -fsSLO http://www.openssl.org/source/${OPENSSL_ROOT}.tar.gz
50+
check_sha256sum ${OPENSSL_ROOT}.tar.gz ${OPENSSL_HASH}
51+
tar -xzf ${OPENSSL_ROOT}.tar.gz
52+
rm -rf ${OPENSSL_ROOT}.tar.gz
4953

50-
# Configure
51-
pushd ${OPENSSL_ROOT}
52-
./config no-shared -fPIC --prefix=/usr/local/ssl --openssldir=/usr/local/ssl > /dev/null
54+
# Configure
55+
pushd ${OPENSSL_ROOT}
56+
./config no-shared -fPIC --prefix=/usr/local/ssl --openssldir=/usr/local/ssl > /dev/null
5357

54-
# Build
55-
make -j$(nproc) > /dev/null
58+
# Build
59+
make -j$(nproc) > /dev/null
60+
61+
# Install
62+
make install_sw DESTDIR=/tmp/${OPENSSL_ROOT}-root > /dev/null
63+
64+
# Create cache archive
65+
mkdir -p "$(dirname ${OPENSSL_ARCHIVE})"
66+
tar -C /tmp/${OPENSSL_ROOT}-root -czf "${OPENSSL_ARCHIVE}" usr
5667

57-
# Install
58-
make install_sw > /dev/null
68+
popd
69+
rm -rf ${OPENSSL_ROOT}
70+
fi
5971

60-
popd
61-
rm -rf ${OPENSSL_ROOT}
72+
tar -C / -xf "${OPENSSL_ARCHIVE}"

0 commit comments

Comments
 (0)