Skip to content

Commit 6034425

Browse files
committed
Switch to Docker images for the Linux builds.
This allows cibuildwheel to just use the new images rather than having to do a song and dance to install the HDF5 libraries before wheel building.
1 parent d1f364d commit 6034425

11 files changed

+145
-139
lines changed
+15-84
Original file line numberDiff line numberDiff line change
@@ -1,72 +1,11 @@
11
name: Build libraries
22

33
on:
4-
push:
5-
branches:
6-
- master
4+
create:
75
tags:
86
- '*'
9-
pull_request:
107

118
jobs:
12-
build_manylinux_x86_64:
13-
name: Build manylinux (x86_64)
14-
runs-on: ubuntu-latest
15-
container:
16-
image: quay.io/pypa/manylinux2014_x86_64
17-
env:
18-
ARTIFACT_NAME: manylinux_x86_64
19-
20-
steps:
21-
- name: Checkout
22-
uses: actions/checkout@v3
23-
24-
- name: Set up CMake
25-
uses: lukka/get-cmake@latest
26-
27-
- name: Install wget
28-
run: yum install -y wget
29-
30-
- name: Run the build
31-
run: |
32-
git config --global --add safe.directory $(pwd)
33-
./build.sh "${ARTIFACT_NAME}"
34-
35-
- name: Upload tarball
36-
uses: actions/upload-artifact@v3
37-
with:
38-
name: ${{ env.ARTIFACT_NAME }}
39-
path: hdf5/${{ env.ARTIFACT_NAME }}.tar.gz
40-
41-
build_musllinux_x86_64:
42-
name: Build musllinux (x86_64)
43-
runs-on: ubuntu-latest
44-
container:
45-
image: quay.io/pypa/musllinux_1_1_x86_64
46-
env:
47-
ARTIFACT_NAME: musllinux_x86_64
48-
49-
steps:
50-
- name: Checkout
51-
uses: actions/checkout@v3
52-
53-
- name: Install CMake
54-
run: apk add --no-cache cmake
55-
56-
- name: Install wget
57-
run: apk add --no-cache wget
58-
59-
- name: Run the build
60-
run: |
61-
git config --global --add safe.directory $(pwd)
62-
./build.sh "${ARTIFACT_NAME}"
63-
64-
- name: Upload tarball
65-
uses: actions/upload-artifact@v3
66-
with:
67-
name: ${{ env.ARTIFACT_NAME }}
68-
path: hdf5/${{ env.ARTIFACT_NAME }}.tar.gz
69-
709
build_macosx_x86_64:
7110
name: Build MacOSX (x86_64)
7211
runs-on: macOS-11
@@ -86,45 +25,37 @@ jobs:
8625
- name: Run the build
8726
run: |
8827
git config --global --add safe.directory $(pwd)
89-
./build.sh "${ARTIFACT_NAME}" "-DCMAKE_OSX_ARCHITECTURES=x86_64"
28+
./build_macosx.sh "x86_64" ${ARTIFACT_NAME}
9029
91-
- name: Upload tarball
30+
- name: Move tarballs
31+
run: |
32+
mkdir artifacts
33+
mv libaec/libaec-*.tar.gz artifacts
34+
mv libhdf5/libhdf5-*.tar.gz artifacts
35+
36+
- name: Upload tarballs
9237
uses: actions/upload-artifact@v3
9338
with:
94-
name: ${{ env.ARTIFACT_NAME }}
95-
path: hdf5/${{ env.ARTIFACT_NAME }}.tar.gz
39+
path: artifacts/*.tar.gz
9640

9741
publish:
9842
name: Publish libraries
99-
needs: [build_manylinux_x86_64, build_musllinux_x86_64, build_macosx_x86_64]
43+
needs: [build_macosx_x86_64]
10044
if: startsWith(github.ref, 'refs/tags/')
10145
runs-on: ubuntu-latest
10246

10347
steps:
104-
- name: Download manylinux (x86_64) artifact
105-
uses: actions/download-artifact@v3
106-
with:
107-
name: manylinux_x86_64
108-
path: artifacts
109-
110-
- name: Download musllinux (x86_64) artifact
111-
uses: actions/download-artifact@v3
112-
with:
113-
name: musllinux_x86_64
114-
path: artifacts
115-
11648
- name: Download macosx (x86_64) artifact
11749
uses: actions/download-artifact@v3
11850
with:
119-
name: macosx_x86_64
120-
path: artifacts
51+
path: dump
12152

12253
- name: List artifacts
12354
run: ls -R
124-
working-directory: artifacts
55+
working-directory: dump
12556

12657
- name: Publish release
12758
uses: softprops/action-gh-release@v1
12859
with:
129-
name: "HDF5 1.12.2"
130-
files: artifacts/*
60+
name: "HDF5 binaries (1.12.2)"
61+
files: dump/*/*

.github/workflows/create-docker.yaml

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
on:
2+
create:
3+
tags:
4+
- '*'
5+
6+
name: Create Docker images
7+
8+
jobs:
9+
create_docker:
10+
runs-on: ubuntu-latest
11+
strategy:
12+
matrix:
13+
arch: [manylinux_x86_64, musllinux_x86_64]
14+
15+
steps:
16+
- name: Checkout
17+
uses: actions/checkout@v3
18+
19+
- name: Publish to Registry
20+
uses: elgohr/Publish-Docker-Github-Action@master
21+
with:
22+
name: ${{ github.repository }}/${{ matrix.arch }}:${{ github.ref_name }}
23+
username: ${{ github.actor }}
24+
password: ${{ secrets.GITHUB_TOKEN }}
25+
dockerfile: ${{ matrix.arch }}.dockerfile
26+
registry: ghcr.io

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@
33
hdf5-*
44
zlib-*
55
libaec/
6+
installs/

README.md

+6-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
11
# Build HDF5 libraries for Python packages
22

3-
Pretty much does as I say.
3+
Builds HDF5 libraries (version 1.12.2) so that they can be used for linking in various Python packages.
4+
This attempts to match the build process used by [`cibuildwheel`](https://github.com/pypa/cibuildwheel):
5+
6+
- For `manylinux_x86_64`, we create a Docker image based on `quay.io/pypa/manylinux2014_x86_64`.
7+
- For `musllinux_x86_64`, we create a Docker image based on `quay.io/pypa/musllinux_1_1_x86_64`.
8+
- For `macosx_x86_64`, we build binaries using the `macosx-11` runner.

build.sh

-54
This file was deleted.

build_linux.sh

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#!/bin/bash
2+
3+
set -e
4+
set -u
5+
6+
hdf5_options=${1:-""}
7+
8+
./setup_aec.sh
9+
cd libaec
10+
cmake --install build
11+
cd -
12+
rm -rf libaec
13+
14+
./setup_hdf5.sh ${hdf5_options}
15+
cd libhdf5
16+
cmake --install build
17+
cd -
18+
rm -rf libhdf5

build_macosx.sh

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#!/bin/bash
2+
3+
set -e
4+
set -u
5+
6+
arch=${1}
7+
package_name=${2}
8+
9+
mkdir installs
10+
install_dir=$(pwd)/installs
11+
12+
./setup_aec.sh "-DCMAKE_OSX_ARCHITECTURES=${arch} -DCPACK_PACKAGE_FILE_NAME=libaec-${package_name} -DCMAKE_INSTALL_PREFIX=${install_dir}"
13+
cd libaec
14+
cmake --install build
15+
cpack -G TGZ --config build/CPackConfig.cmake
16+
cd -
17+
18+
./setup_hdf5.sh "-DCMAKE_OSX_ARCHITECTURES=${arch} -DCPACK_PACKAGE_FILE_NAME=libhdf5-${package_name} -DCMAKE_INSTALL_PREFIX=${install_dir}"
19+
cd libhdf5
20+
cmake --install build
21+
cpack -G TGZ --config build/CPackConfig.cmake
22+
cd -

manylinux_x86_64.dockerfile

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
FROM quay.io/pypa/manylinux2014_x86_64
2+
WORKDIR /home/root
3+
COPY setup* .
4+
COPY build_linux.sh .
5+
RUN bash build_linux.sh "-DCMAKE_INSTALL_PREFIX=/usr/local"
6+
CMD ["/bin/bash"]

musllinux_x86_64.dockerfile

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
FROM quay.io/pypa/musllinux_1_1_x86_64
2+
WORKDIR /home/root
3+
COPY setup* .
4+
COPY build_linux.sh .
5+
RUN bash build_linux.sh "-DCMAKE_INSTALL_PREFIX=/usr/local"
6+
CMD ["/bin/bash"]

setup_aec.sh

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#!/bin/bash
2+
3+
set -e
4+
set -u
5+
6+
aec_options=${1:-""}
7+
8+
git clone https://gitlab.dkrz.de/k202009/libaec
9+
cd libaec
10+
git checkout v1.0.6
11+
cmake -S . -B build \
12+
-DCMAKE_BUILD_TYPE=Release \
13+
${aec_options}
14+
cmake --build build
15+
cd -

setup_hdf5.sh

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
#!/bin/bash
2+
3+
set -e
4+
set -u
5+
6+
hdf5_options=${1:-""}
7+
8+
curl -L https://github.com/HDFGroup/hdf5/archive/refs/tags/hdf5-1_12_2.tar.gz > bundle.tar.gz
9+
tar -xf bundle.tar.gz
10+
rm bundle.tar.gz
11+
12+
cwd=$(pwd)
13+
mv hdf5-hdf5-1_12_2/ libhdf5
14+
cd libhdf5
15+
16+
cmake -S . -B build \
17+
-DBUILD_SHARED_LIBS=ON \
18+
-DCMAKE_BUILD_TYPE=Release \
19+
-DHDF5_BUILD_EXAMPLES=OFF \
20+
-DHDF5_BUILD_TOOLS=OFF \
21+
-DHDF5_BUILD_UTILS=OFF \
22+
-DHDF5_BUILD_CPP_LIB=ON \
23+
-DHDF5_ENABLE_Z_LIB_SUPPORT=ON \
24+
-DHDF5_ENABLE_SZIP_SUPPORT=ON \
25+
-DBUILD_TESTING=OFF \
26+
-DUSE_LIBAEC=ON \
27+
${hdf5_options}
28+
29+
cmake --build build
30+
cd -

0 commit comments

Comments
 (0)