Skip to content
Merged
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
230 changes: 210 additions & 20 deletions .github/workflows/pypi-wheels-cpu.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,12 @@ on:
- published
workflow_dispatch:

env:
DEPS_CACHE_KEY: cibw-deps-manylinux_2_28-x86_64-hdf5_1.14.6-tiff_4.6.0-hypre_2.31.0-amrex_25.03-tinyprof-noeb-nofort-nompicxx-v9

jobs:
build_wheels:
name: Build manylinux wheels on ubuntu-latest
build_core_and_cp39:
name: Build C++ core, cp39 & pure-Python wheels
runs-on: ubuntu-latest

steps:
Expand All @@ -32,35 +35,50 @@ jobs:
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.x"
python-version: "3.12"

- name: Install cibuildwheel
run: python -m pip install cibuildwheel==2.22.0
- name: Install cibuildwheel and build
run: python -m pip install cibuildwheel==2.22.0 build

- name: Cache native dependencies
uses: actions/cache@v4
with:
path: .cibw-deps-cache
key: cibw-deps-manylinux_2_28-x86_64-hdf5_1.14.6-tiff_4.6.0-hypre_2.31.0-amrex_25.03-tinyprof-noeb-nofort-nompicxx-v8
path: /tmp/cibw-deps-cache
key: ${{ env.DEPS_CACHE_KEY }}

- name: Cache ccache objects (core + cp39)
uses: actions/cache@v4
with:
path: /tmp/cibw-ccache
key: ccache-cpu-manylinux_2_28-cp39-${{ github.sha }}
restore-keys: |
ccache-cpu-manylinux_2_28-cp39-

- name: Build wheels
- name: Build cp39 wheel and populate core ccache
run: python -m cibuildwheel --output-dir wheelhouse
env:
CIBW_BUILD: "cp39-* cp310-* cp311-* cp312-* cp313-*"
CIBW_BUILD: "cp39-*"
CIBW_SKIP: "*musllinux* *i686*"
CIBW_ARCHS_LINUX: "x86_64"
CIBW_MANYLINUX_X86_64_IMAGE: manylinux_2_28

CIBW_BEFORE_ALL_LINUX: >
set -e &&
export CCACHE_DISABLE=1 &&
dnf install -y epel-release &&
dnf --enablerepo=powertools install -y
openmpi-devel gcc-c++ wget git
openmpi-devel gcc-c++ wget git xz
zlib-devel libjpeg-turbo-devel python3-pip &&
wget -q https://github.com/ccache/ccache/releases/download/v4.10.2/ccache-4.10.2-linux-x86_64.tar.xz -O /tmp/ccache.tar.xz &&
tar xf /tmp/ccache.tar.xz -C /usr/bin --strip-components=1 &&
rm -f /tmp/ccache.tar.xz &&
mkdir -p /host/tmp/cibw-ccache &&
chmod -R a+rwX /host/tmp/cibw-ccache &&
pip3 install "cmake>=3.28,<4" &&
export PATH=/usr/lib64/openmpi/bin:$PATH &&
if [ -f /project/.cibw-deps-cache/deps.tar.gz ]; then
export PATH=/usr/local/bin:/usr/lib64/openmpi/bin:$PATH &&
if [ -f /host/tmp/cibw-deps-cache/deps.tar.gz ]; then
echo "=== Restoring cached dependencies ===" &&
tar xzf /project/.cibw-deps-cache/deps.tar.gz -C / ;
tar xzf /host/tmp/cibw-deps-cache/deps.tar.gz -C / ;
else
echo "=== Building dependencies from source ===" &&
wget -q https://github.com/HDFGroup/hdf5/releases/download/hdf5_1.14.6/hdf5-1.14.6.tar.gz &&
Expand Down Expand Up @@ -113,22 +131,32 @@ jobs:
-DCMAKE_POSITION_INDEPENDENT_CODE=ON &&
cmake --build /tmp/amrex/build -j$(nproc) &&
cmake --install /tmp/amrex/build &&
strip --strip-debug /usr/local/lib/libamrex_3d.a /usr/local/lib/libHYPRE.a /usr/local/lib/libhdf5*.a /usr/local/lib/libtiff.a 2>/dev/null || true &&
mkdir -p /project/.cibw-deps-cache &&
tar czf /project/.cibw-deps-cache/deps.tar.gz /usr/local ;
(strip --strip-debug /usr/local/lib/libamrex_3d.a /usr/local/lib/libHYPRE.a /usr/local/lib/libhdf5*.a /usr/local/lib/libtiff.a 2>/dev/null || true) &&
mkdir -p /host/tmp/cibw-deps-cache &&
tar czf /host/tmp/cibw-deps-cache/deps.tar.gz /usr/local &&
chmod -R a+rwX /host/tmp/cibw-deps-cache ;
fi

CIBW_BEFORE_BUILD: pip install "cmake>=3.28,<4"
CIBW_BEFORE_BUILD: pip install "cmake>=3.28,<4" && rm -rf /tmp/oi-build

CIBW_ENVIRONMENT_LINUX: >
PATH="/usr/lib64/openmpi/bin:$PATH"
PATH="/usr/local/bin:/usr/lib64/openmpi/bin:$PATH"
CCACHE_DIR="/host/tmp/cibw-ccache"
CCACHE_BASEDIR="/project"
CCACHE_NOHASHDIR="true"
SKBUILD_BUILD_DIR="/tmp/oi-build"
CMAKE_C_COMPILER="mpicc"
CMAKE_CXX_COMPILER="mpicxx"
CMAKE_C_COMPILER_LAUNCHER="ccache"
CMAKE_CXX_COMPILER_LAUNCHER="ccache"
CMAKE_PREFIX_PATH="/usr/local"
CMAKE_GENERATOR="Unix Makefiles"
CMAKE_ARGS="-DFETCHCONTENT_BASE_DIR=/tmp/fc-deps"
SETUPTOOLS_SCM_PRETEND_VERSION="${{ steps.version.outputs.version }}"

CIBW_REPAIR_WHEEL_COMMAND_LINUX: >
ccache -s &&
chmod -R a+rwX /host/tmp/cibw-ccache &&
auditwheel repair -w {dest_dir} {wheel}
--exclude libmpi.so
--exclude libmpi.so.12
Expand All @@ -144,15 +172,177 @@ jobs:
--exclude libmpi_mpifh.so.40
--exclude libgomp.so.1

- name: Upload wheels as artifacts
- name: Verify host caches populated
run: |
ls -lh /tmp/cibw-deps-cache/deps.tar.gz
du -sh /tmp/cibw-ccache

- name: Build pure-Python fallback wheel (py3-none-any)
env:
SETUPTOOLS_SCM_PRETEND_VERSION: ${{ steps.version.outputs.version }}
run: |
python -m build --wheel --outdir wheelhouse \
-Cwheel.platlib=false \
-Ccmake.define.OPENIMPALA_PURE_PYTHON=ON
ls -lh wheelhouse/
python -m zipfile -l wheelhouse/*-py3-none-any.whl
if python -m zipfile -l wheelhouse/*-py3-none-any.whl | grep -q '_core'; then
echo "::error::Pure-Python wheel unexpectedly contains compiled _core module"
exit 1
fi

- name: Upload cp39 and pure-Python wheels
uses: actions/upload-artifact@v4
with:
name: cibw-wheels-part-cp39
path: ./wheelhouse/*.whl
retention-days: 1

build_matrix_wheels:
name: Build ${{ matrix.py }} manylinux wheel
needs: build_core_and_cp39
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
py: [cp310, cp311, cp312, cp313]

steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
submodules: recursive
fetch-depth: 0

- name: Extract version from tag
id: version
run: |
if [[ "$GITHUB_REF_NAME" == v* ]]; then
VERSION="${GITHUB_REF_NAME#v}"
else
VERSION="$(git describe --tags --abbrev=0 | sed 's/^v//')"
fi
echo "version=${VERSION}" >> "$GITHUB_OUTPUT"

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.12"

- name: Install cibuildwheel
run: python -m pip install cibuildwheel==2.22.0

- name: Restore native dependencies cache
uses: actions/cache/restore@v4
with:
path: /tmp/cibw-deps-cache
key: ${{ env.DEPS_CACHE_KEY }}

- name: Cache ccache objects (${{ matrix.py }})
uses: actions/cache@v4
with:
path: /tmp/cibw-ccache
key: ccache-cpu-manylinux_2_28-${{ matrix.py }}-${{ github.sha }}
restore-keys: |
ccache-cpu-manylinux_2_28-cp39-${{ github.sha }}
ccache-cpu-manylinux_2_28-${{ matrix.py }}-
ccache-cpu-manylinux_2_28-cp39-

- name: Build ${{ matrix.py }} wheel
run: python -m cibuildwheel --output-dir wheelhouse
env:
CIBW_BUILD: "${{ matrix.py }}-*"
CIBW_SKIP: "*musllinux* *i686*"
CIBW_ARCHS_LINUX: "x86_64"
CIBW_MANYLINUX_X86_64_IMAGE: manylinux_2_28

CIBW_BEFORE_ALL_LINUX: >
set -e &&
dnf install -y epel-release &&
dnf --enablerepo=powertools install -y
openmpi-devel gcc-c++ wget git xz
zlib-devel libjpeg-turbo-devel python3-pip &&
tar xzf /host/tmp/cibw-deps-cache/deps.tar.gz -C / &&
wget -q https://github.com/ccache/ccache/releases/download/v4.10.2/ccache-4.10.2-linux-x86_64.tar.xz -O /tmp/ccache.tar.xz &&
tar xf /tmp/ccache.tar.xz -C /usr/bin --strip-components=1 &&
rm -f /tmp/ccache.tar.xz &&
mkdir -p /host/tmp/cibw-ccache &&
chmod -R a+rwX /host/tmp/cibw-ccache &&
pip3 install "cmake>=3.28,<4"

CIBW_BEFORE_BUILD: pip install "cmake>=3.28,<4" && rm -rf /tmp/oi-build

CIBW_ENVIRONMENT_LINUX: >
PATH="/usr/local/bin:/usr/lib64/openmpi/bin:$PATH"
CCACHE_DIR="/host/tmp/cibw-ccache"
CCACHE_BASEDIR="/project"
CCACHE_NOHASHDIR="true"
SKBUILD_BUILD_DIR="/tmp/oi-build"
CMAKE_C_COMPILER="mpicc"
CMAKE_CXX_COMPILER="mpicxx"
CMAKE_C_COMPILER_LAUNCHER="ccache"
CMAKE_CXX_COMPILER_LAUNCHER="ccache"
CMAKE_PREFIX_PATH="/usr/local"
CMAKE_GENERATOR="Unix Makefiles"
CMAKE_ARGS="-DFETCHCONTENT_BASE_DIR=/tmp/fc-deps"
SETUPTOOLS_SCM_PRETEND_VERSION="${{ steps.version.outputs.version }}"

CIBW_REPAIR_WHEEL_COMMAND_LINUX: >
ccache -s &&
chmod -R a+rwX /host/tmp/cibw-ccache &&
auditwheel repair -w {dest_dir} {wheel}
--exclude libmpi.so
--exclude libmpi.so.12
--exclude libmpi.so.40
--exclude libmpi_cxx.so
--exclude libmpi_cxx.so.1
--exclude libmpi_cxx.so.40
--exclude libopen-rte.so
--exclude libopen-rte.so.40
--exclude libopen-pal.so
--exclude libopen-pal.so.40
--exclude libmpi_mpifh.so
--exclude libmpi_mpifh.so.40
--exclude libgomp.so.1

- name: Upload ${{ matrix.py }} wheel
uses: actions/upload-artifact@v4
with:
name: cibw-wheels-part-${{ matrix.py }}
path: ./wheelhouse/*.whl
retention-days: 1

bundle_wheels:
name: Bundle CPU & pure-Python wheels
needs: [build_core_and_cp39, build_matrix_wheels]
runs-on: ubuntu-latest

steps:
- name: Download all wheel parts
uses: actions/download-artifact@v4
with:
pattern: cibw-wheels-part-*
merge-multiple: true
path: wheelhouse/

- name: Verify complete wheelhouse (5 manylinux + 1 pure-Python)
run: |
ls -lh wheelhouse/
COUNT=$(ls -1 wheelhouse/*.whl | wc -l)
if [ "$COUNT" -ne 6 ]; then
echo "::error::Expected 6 wheels (cp39..cp313 + py3-none-any), found $COUNT"
exit 1
fi

- name: Upload unified wheelhouse artifact
uses: actions/upload-artifact@v4
with:
name: cibw-wheels
path: ./wheelhouse/*.whl

publish_to_pypi:
name: Publish wheels to PyPI
needs: build_wheels
needs: bundle_wheels
runs-on: ubuntu-latest
# Only publish on release; workflow_dispatch leaves the artifact for manual
# inspection without touching PyPI.
Expand Down
Loading
Loading