Skip to content

Commit

Permalink
Switch to Docker images for the Linux builds.
Browse files Browse the repository at this point in the history
  • Loading branch information
LTLA committed Oct 15, 2023
1 parent d1f364d commit 02e6eb6
Show file tree
Hide file tree
Showing 6 changed files with 56 additions and 98 deletions.
77 changes: 2 additions & 75 deletions .github/workflows/build-libraries.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,71 +2,10 @@ name: Build libraries

on:
push:
branches:
- master
tags:
- '*'
pull_request:

jobs:
build_manylinux_x86_64:
name: Build manylinux (x86_64)
runs-on: ubuntu-latest
container:
image: quay.io/pypa/manylinux2014_x86_64
env:
ARTIFACT_NAME: manylinux_x86_64

steps:
- name: Checkout
uses: actions/checkout@v3

- name: Set up CMake
uses: lukka/get-cmake@latest

- name: Install wget
run: yum install -y wget

- name: Run the build
run: |
git config --global --add safe.directory $(pwd)
./build.sh "${ARTIFACT_NAME}"
- name: Upload tarball
uses: actions/upload-artifact@v3
with:
name: ${{ env.ARTIFACT_NAME }}
path: hdf5/${{ env.ARTIFACT_NAME }}.tar.gz

build_musllinux_x86_64:
name: Build musllinux (x86_64)
runs-on: ubuntu-latest
container:
image: quay.io/pypa/musllinux_1_1_x86_64
env:
ARTIFACT_NAME: musllinux_x86_64

steps:
- name: Checkout
uses: actions/checkout@v3

- name: Install CMake
run: apk add --no-cache cmake

- name: Install wget
run: apk add --no-cache wget

- name: Run the build
run: |
git config --global --add safe.directory $(pwd)
./build.sh "${ARTIFACT_NAME}"
- name: Upload tarball
uses: actions/upload-artifact@v3
with:
name: ${{ env.ARTIFACT_NAME }}
path: hdf5/${{ env.ARTIFACT_NAME }}.tar.gz

build_macosx_x86_64:
name: Build MacOSX (x86_64)
runs-on: macOS-11
Expand Down Expand Up @@ -96,23 +35,11 @@ jobs:

publish:
name: Publish libraries
needs: [build_manylinux_x86_64, build_musllinux_x86_64, build_macosx_x86_64]
needs: [build_macosx_x86_64]
if: startsWith(github.ref, 'refs/tags/')
runs-on: ubuntu-latest

steps:
- name: Download manylinux (x86_64) artifact
uses: actions/download-artifact@v3
with:
name: manylinux_x86_64
path: artifacts

- name: Download musllinux (x86_64) artifact
uses: actions/download-artifact@v3
with:
name: musllinux_x86_64
path: artifacts

- name: Download macosx (x86_64) artifact
uses: actions/download-artifact@v3
with:
Expand All @@ -126,5 +53,5 @@ jobs:
- name: Publish release
uses: softprops/action-gh-release@v1
with:
name: "HDF5 1.12.2"
name: "HDF5 binaries (1.12.2)"
files: artifacts/*
27 changes: 27 additions & 0 deletions .github/workflows/create-docker.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
on:
push:
tags:
- '*'
workflow_dispatch:

name: Publish Docker image

jobs:
publish_docker:
runs-on: ubuntu-latest
strategy:
matrix:
arch: [manylinux_x86_64, musllinux_x86_64]

steps:
- name: Checkout
uses: actions/checkout@v3

- name: Publish to Registry
uses: elgohr/Publish-Docker-Github-Action@master
with:
name: ${{ github.repository }}/${{ matrix.arch }}:${{ github.ref_name }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
dockerfile: ${{ matrix.arch }}.dockerfile
registry: ghcr.io
7 changes: 6 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
# Build HDF5 libraries for Python packages

Pretty much does as I say.
Builds HDF5 libraries (version 1.12.2) so that they can be used for linking in various Python packages.
This attempts to match the build process used by [`cibuildwheel`](https://github.com/pypa/cibuildwheel):

- For `manylinux_x86_64`, we create a Docker image based on `quay.io/pypa/manylinux2014_x86_64`.
- For `musllinux_x86_64`, we create a Docker image based on `quay.io/pypa/musllinux_1_1_x86_64`.
- For `macosx_x86_64`, we build binaries using the `macosx-11` runner.
33 changes: 11 additions & 22 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,38 +3,30 @@
set -e
set -u

output=$1 # output file name for the CPack bundle.
options=${2:-""}

mkdir -p installs

# Setting up ZLIB
wget http://zlib.net/fossils/zlib-1.3.tar.gz -O zlib.tar.gz
tar -xvf zlib.tar.gz
cd zlib-1.3
cmake -S . -B build -DCMAKE_INSTALL_PREFIX=../installs ${options}
cmake --build build
cmake --install build
cd -
options=${1:-""}

# Setting up SZIP
git clone https://gitlab.dkrz.de/k202009/libaec
cd libaec
git checkout v1.0.6
cmake -S . -B build -DCMAKE_INSTALL_PREFIX=../installs ${options}
cmake -S . -B build -DCMAKE_BUILD_TYPE=Release
cmake --build build
cmake --install build
cd -
rm -rf libaec

# Setting up HDF5.
wget https://github.com/HDFGroup/hdf5/archive/refs/tags/hdf5-1_12_2.tar.gz -O bundle.tar.gz
curl -L https://github.com/HDFGroup/hdf5/archive/refs/tags/hdf5-1_12_2.tar.gz > bundle.tar.gz
tar -xf bundle.tar.gz
rm bundle.tar.gz

cwd=$(pwd)
mv hdf5-hdf5-1_12_2/ hdf5
cd hdf5

cmake -S . -B build \
-DBUILD_SHARED_LIBS=OFF \
-DBUILD_SHARED_LIBS=ON \
-DCMAKE_BUILD_TYPE=Release \
-DHDF5_BUILD_EXAMPLES=OFF \
-DHDF5_BUILD_TOOLS=OFF \
-DHDF5_BUILD_UTILS=OFF \
Expand All @@ -43,12 +35,9 @@ cmake -S . -B build \
-DHDF5_ENABLE_SZIP_SUPPORT=ON \
-DBUILD_TESTING=OFF \
-DUSE_LIBAEC=ON \
-DZLIB_INCLUDE_DIR=${cwd}/installs/include \
-DZLIB_LIBRARY=${cwd}/installs/lib/libz.a \
-DSZIP_INCLUDE_DIR=${cwd}/installs/include \
-DSZIP_LIBRARY=${cwd}/installs/lib/libsz.a \
-DCPACK_PACKAGE_FILE_NAME=${output} \
${options}

cmake --build build
cpack -G TGZ --config build/CPackConfig.cmake
cmake --install build
cd -
rm -rf hdf5
5 changes: 5 additions & 0 deletions manylinux_x86_64.dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
FROM quay.io/pypa/manylinux2014_x86_64
WORKDIR /home/root
COPY build.sh build.sh
RUN bash build.sh "-DCMAKE_INSTALL_PREFIX=/usr/local"
CMD ["/bin/bash"]
5 changes: 5 additions & 0 deletions musllinux_x86_64.dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
FROM quay.io/pypa/musllinux_1_1_x86_64
WORKDIR /home/root
COPY build.sh build.sh
RUN bash build.sh "-DCMAKE_INSTALL_PREFIX=/usr/local"
CMD ["/bin/bash"]

0 comments on commit 02e6eb6

Please sign in to comment.