Skip to content

Cache openssl #1

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,13 @@ jobs:
uses: docker/[email protected]
if: matrix.use_qemu && fromJSON(env.USE_QEMU)

- name: Cache OpenSSL build
if: runner.os == 'Linux'
uses: actions/cache@v2
with:
path: .cache-openssl
key: ${{ matrix.os }}-${{ matrix.build }}${{ matrix.arch }}-${{ hashFiles('scripts/manylinux-build-and-install-openssl.sh') }}

- name: Build wheels
uses: pypa/[email protected]
if: (!matrix.use_qemu) || fromJSON(env.USE_QEMU)
Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -60,3 +60,6 @@ docs/_build
# IDE junk
.idea/*
*.swp

# OpenSSL build cache
.cache-openssl/
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ before-all = [

[tool.cibuildwheel.linux.environment]
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"
OPENSSL_CACHE_DIR = "home/runner/work/cmake-python-distributions/cmake-python-distributions/.cache-openssl"

[tool.cibuildwheel.macos.environment]
MACOSX_DEPLOYMENT_TARGET = "10.10"
Expand Down
83 changes: 47 additions & 36 deletions scripts/manylinux-build-and-install-openssl.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,48 +14,59 @@ OPENSSL_ROOT=openssl-3.0.0
# Hash from https://www.openssl.org/source/openssl-3.0.0.tar.gz.sha256
OPENSSL_HASH=59eedfcb46c25214c9bd37ed6078297b4df01d012267fe9e9eee31f61bc70536

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

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

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

pushd ${PERL_ROOT}
./Configure -des -Dprefix=/tmp/perl-openssl > /dev/null
make -j$(nproc) > /dev/null
make install > /dev/null
popd
export PATH=/tmp/perl-openssl/bin:${PATH}
else
if [ "${AUDITWHEEL_PLAT:0:9}" == "manylinux" ]; then
# more perl modules are needed than the bare minimum already installed in CentOS
# c.f. https://github.com/openssl/openssl/blob/openssl-3.0.0/NOTES-PERL.md#general-notes
yum -y install perl-core
if ! perl -e 'use 5.10.0' &> /dev/null; then
# perl>=5.10.0 is needed to build openssl
PERL_ROOT=perl-5.32.1
# Hash from https://www.cpan.org/src/5.0/perl-5.32.1.tar.gz.sha256.txt
PERL_HASH=03b693901cd8ae807231b1787798cf1f2e0b8a56218d07b7da44f784a7caeb2c

curl -fsSLO https://www.cpan.org/src/5.0/${PERL_ROOT}.tar.gz
check_sha256sum ${PERL_ROOT}.tar.gz ${PERL_HASH}
tar -xzf ${PERL_ROOT}.tar.gz
rm -rf ${PERL_ROOT}.tar.gz

pushd ${PERL_ROOT}
./Configure -des -Dprefix=/tmp/perl-openssl > /dev/null
make -j$(nproc) > /dev/null
make install > /dev/null
popd
export PATH=/tmp/perl-openssl/bin:${PATH}
else
if [ "${AUDITWHEEL_PLAT:0:9}" == "manylinux" ]; then
# more perl modules are needed than the bare minimum already installed in CentOS
# c.f. https://github.com/openssl/openssl/blob/openssl-3.0.0/NOTES-PERL.md#general-notes
yum -y install perl-core
fi
fi
fi

# Download
curl -fsSLO http://www.openssl.org/source/${OPENSSL_ROOT}.tar.gz
check_sha256sum ${OPENSSL_ROOT}.tar.gz ${OPENSSL_HASH}
tar -xzf ${OPENSSL_ROOT}.tar.gz
rm -rf ${OPENSSL_ROOT}.tar.gz
# Download
curl -fsSLO http://www.openssl.org/source/${OPENSSL_ROOT}.tar.gz
check_sha256sum ${OPENSSL_ROOT}.tar.gz ${OPENSSL_HASH}
tar -xzf ${OPENSSL_ROOT}.tar.gz
rm -rf ${OPENSSL_ROOT}.tar.gz

# Configure
pushd ${OPENSSL_ROOT}
./config no-shared -fPIC --prefix=/usr/local/ssl --openssldir=/usr/local/ssl > /dev/null
# Configure
pushd ${OPENSSL_ROOT}
./config no-shared -fPIC --prefix=/usr/local/ssl --openssldir=/usr/local/ssl > /dev/null

# Build
make -j$(nproc) > /dev/null
# Build
make -j$(nproc) > /dev/null

# Install
make install_sw DESTDIR=/tmp/${OPENSSL_ROOT}-root > /dev/null

# Create cache archive
mkdir -p "$(dirname ${OPENSSL_ARCHIVE})"
tar -C /tmp/${OPENSSL_ROOT}-root -czf "${OPENSSL_ARCHIVE}" usr

# Install
make install_sw > /dev/null
popd
rm -rf ${OPENSSL_ROOT}
fi

popd
rm -rf ${OPENSSL_ROOT}
tar -C / -xf "${OPENSSL_ARCHIVE}"