From 4130747519a7c87161f33fccefe8a81baec44742 Mon Sep 17 00:00:00 2001 From: Sylwester Arabas Date: Tue, 17 Feb 2026 20:29:10 +0100 Subject: [PATCH 1/4] CI: cache compiled h5py wheel instead of entire site-packages --- .github/workflows/mpi.yml | 59 +++++++++++++++++++++++---------------- 1 file changed, 35 insertions(+), 24 deletions(-) diff --git a/.github/workflows/mpi.yml b/.github/workflows/mpi.yml index 04e04222..b5a599d3 100644 --- a/.github/workflows/mpi.yml +++ b/.github/workflows/mpi.yml @@ -57,45 +57,56 @@ jobs: - uses: actions/setup-python@v5 with: python-version: ${{ matrix.python-version }} - - run: | - echo pip_user_site=$(python -c "import sysconfig; print(sysconfig.get_path('purelib'))") >> $GITHUB_ENV - echo toml_ci_md5=$(cat pyproject.toml .github/workflows/mpi.yml \ - | python -c "import hashlib;print(hashlib.md5(open(0,'rb').read()).hexdigest())") >> $GITHUB_ENV - - id: cache - uses: actions/cache@v4 - with: - path: ${{ env.pip_user_site }} - key: ${{ matrix.platform }}-${{ matrix.mpi }}-${{ matrix.python-version }}-${{ env.toml_ci_md5 }} - - if: steps.cache.outputs.cache-hit != 'true' - uses: mpi4py/setup-mpi@v1 + - uses: mpi4py/setup-mpi@v1 with: mpi: ${{ matrix.mpi }} - - if: steps.cache.outputs.cache-hit != 'true' && matrix.mpi == 'mpich' + + - if: matrix.mpi == 'mpich' run: echo _ch="ch" >> $GITHUB_ENV - - if: steps.cache.outputs.cache-hit != 'true' && startsWith(matrix.platform, 'ubuntu-') + + - if: startsWith(matrix.platform, 'ubuntu-') run: | sudo apt-get update && sudo apt-get install -y libhdf5-mpi$_ch-dev pkg-config lscpu - - if: steps.cache.outputs.cache-hit != 'true' && startsWith(matrix.platform, 'ubuntu-') && matrix.mpi == 'mpich' + HDF5_VERSION=$(dpkg-query -W -f='${Version}' libhdf5-mpi$_ch-dev) + echo "HDF5_VERSION=$HDF5_VERSION" >> $GITHUB_ENV + + - if: startsWith(matrix.platform, 'ubuntu-') && matrix.mpi == 'mpich' run: | echo HDF5_LIBDIR=/usr/lib/x86_64-linux-gnu/hdf5/mpich >> $GITHUB_ENV echo HDF5_INCLUDEDIR=/usr/include/hdf5/mpich >> $GITHUB_ENV - - if: steps.cache.outputs.cache-hit != 'true' && startsWith(matrix.platform, 'macos-') + + - if: startsWith(matrix.platform, 'macos-') run: | - brew install hdf5-mpi && echo HDF5_DIR="$(brew --cellar hdf5-mpi)/$(brew list --versions hdf5-mpi | grep -Eo '[0-9]+\.[0-9]+\.[0-9]+')" >> $GITHUB_ENV + brew install hdf5-mpi + HDF5_VERSION=$(brew list --versions hdf5-mpi | awk '{print $2}') + echo "HDF5_VERSION=$HDF5_VERSION" >> $GITHUB_ENV + echo HDF5_DIR="$(brew --prefix hdf5-mpi)" >> $GITHUB_ENV sysctl -a | grep cpu | grep hw - - if: steps.cache.outputs.cache-hit != 'true' + + - id: cache-h5py + uses: actions/cache@v4 + with: + path: wheelhouse + key: > + ${{ matrix.platform }}- + ${{ matrix.mpi }}- + ${{ matrix.python-version }}- + hdf5-${{ env.HDF5_VERSION }}- + h5py-3.13.0 + + - if: steps.cache-h5py.outputs.cache-hit != 'true' run: | - HDF5_MPI="ON" CC=mpicc pip install --no-binary=h5py h5py==3.13.0 + mkdir -p wheelhouse + HDF5_MPI="ON" CC=mpicc \ + pip wheel --no-binary=h5py h5py==3.13.0 -w wheelhouse + + - run: | + pip install --no-index --find-links=wheelhouse h5py==3.13.0 pip install -e .[tests] -e ./examples[tests] -e ./MPI[tests] + - run: pip show numpy - - id: cache-save - if: steps.cache.outputs.cache-hit != 'true' - uses: actions/cache/save@v4 - with: - path: ${{ env.pip_user_site }} - key: ${{ matrix.platform }}-${{ matrix.mpi }}-${{ matrix.python-version }}-${{ env.toml_ci_md5 }} tests: needs: [tests_setup] From 7db89d9e9e8ce0e596c190ee9c010408609a5ec8 Mon Sep 17 00:00:00 2001 From: Sylwester Arabas Date: Tue, 17 Feb 2026 20:33:59 +0100 Subject: [PATCH 2/4] use --no-build-isolation --- .github/workflows/mpi.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/mpi.yml b/.github/workflows/mpi.yml index b5a599d3..2d8b8560 100644 --- a/.github/workflows/mpi.yml +++ b/.github/workflows/mpi.yml @@ -100,7 +100,7 @@ jobs: run: | mkdir -p wheelhouse HDF5_MPI="ON" CC=mpicc \ - pip wheel --no-binary=h5py h5py==3.13.0 -w wheelhouse + pip wheel --no-binary=h5py --no-build-isolation h5py==3.13.0 -w wheelhouse - run: | pip install --no-index --find-links=wheelhouse h5py==3.13.0 From 846ba6dc4c72b370beb13254507a4a4cfe686b0e Mon Sep 17 00:00:00 2001 From: Sylwester Arabas Date: Tue, 17 Feb 2026 20:40:19 +0100 Subject: [PATCH 3/4] pre-install Cython --- .github/workflows/mpi.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/mpi.yml b/.github/workflows/mpi.yml index 2d8b8560..4e948fd2 100644 --- a/.github/workflows/mpi.yml +++ b/.github/workflows/mpi.yml @@ -99,8 +99,9 @@ jobs: - if: steps.cache-h5py.outputs.cache-hit != 'true' run: | mkdir -p wheelhouse - HDF5_MPI="ON" CC=mpicc \ - pip wheel --no-binary=h5py --no-build-isolation h5py==3.13.0 -w wheelhouse + pip install --upgrade pip setuptools wheel + pip install Cython numpy mpi4py + HDF5_MPI="ON" CC=mpicc pip wheel --no-binary=h5py --no-build-isolation h5py==3.13.0 -w wheelhouse - run: | pip install --no-index --find-links=wheelhouse h5py==3.13.0 From d8806406e4a79599ff0e7a2f5da9a59e551ad495 Mon Sep 17 00:00:00 2001 From: Sylwester Arabas Date: Tue, 17 Feb 2026 22:23:27 +0100 Subject: [PATCH 4/4] pre-instal pkgconfig --- .github/workflows/mpi.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/mpi.yml b/.github/workflows/mpi.yml index 4e948fd2..a2f7281d 100644 --- a/.github/workflows/mpi.yml +++ b/.github/workflows/mpi.yml @@ -100,7 +100,7 @@ jobs: run: | mkdir -p wheelhouse pip install --upgrade pip setuptools wheel - pip install Cython numpy mpi4py + pip install Cython numpy mpi4py pkgconfig HDF5_MPI="ON" CC=mpicc pip wheel --no-binary=h5py --no-build-isolation h5py==3.13.0 -w wheelhouse - run: |