name: Build Python wheels
on:
workflow_call:
inputs:
os:
type: string
required: true
python-version:
type: string
required: true
jobs:
build:
runs-on: ${{ inputs.os }}
steps:
- uses: actions/checkout@v6
- name: Set up Python
uses: actions/setup-python@v6
with:
python-version: ${{ inputs.python-version }}
- name: Set up Rust
uses: dtolnay/rust-toolchain@stable
- name: Install dependencies (macOS)
if: runner.os == 'macOS'
run: |
brew install netcdf hdf5 zlib
- name: Configure native deps (macOS)
if: runner.os == 'macOS'
run: |
ZLIB_PREFIX="$(brew --prefix zlib)"
HDF5_PREFIX="$(brew --prefix hdf5)"
NETCDF_PREFIX="$(brew --prefix netcdf)"
BREW_PREFIX="$(brew --prefix)"
{
echo "LIBZ_SYS_STATIC=0"
echo "ZLIB_DIR=$ZLIB_PREFIX"
echo "HDF5_DIR=$HDF5_PREFIX"
echo "NETCDF_DIR=$NETCDF_PREFIX"
echo "PKG_CONFIG_PATH=$ZLIB_PREFIX/lib/pkgconfig:$HDF5_PREFIX/lib/pkgconfig:$NETCDF_PREFIX/lib/pkgconfig:$BREW_PREFIX/lib/pkgconfig"
echo "CPPFLAGS=-I$ZLIB_PREFIX/include -I$HDF5_PREFIX/include -I$NETCDF_PREFIX/include ${CPPFLAGS:-}"
echo "LDFLAGS=-L$ZLIB_PREFIX/lib -L$HDF5_PREFIX/lib -L$NETCDF_PREFIX/lib ${LDFLAGS:-}"
} >> "$GITHUB_ENV"
- name: Install maturin and pytest
run: pip install maturin pytest
- name: Build wheels
run: |
maturin build --release --features python --no-default-features --auditwheel repair
- name: Install built wheel
run: |
pip install --force-reinstall --find-links target/wheels ridal
- name: Smoke test
run: |
python -c "import ridal; print(ridal.__version__)"
python -m pytest
- name: Upload wheels (CI artifact)
uses: actions/upload-artifact@v7
with:
name: wheels-${{ inputs.os }}-py${{ inputs.python-version }}
path: target/wheels/*.whl