Skip to content
Closed
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
135 changes: 135 additions & 0 deletions .github/workflows/build_wheels.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,135 @@
name: Build

# TODO: only run on published releases
# on:
# release:
# types: [published]
on: [pull_request]

jobs:
build_wheels:
name: Build wheels on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
# macos-13 is an intel runner, macos-14 is apple silicon
os: [
ubuntu-latest,
ubuntu-24.04-arm,
# Failing, probably need to:
# - read https://github.com/mesonbuild/meson-python/issues/222
# - maybe try with https://github.com/numpy/numpy/blob/71eebaf8513dfd6ed40b0c689702d81e3f6f2527/.github/workflows/wheels.yml#L133
# - maybe try with https://github.com/matplotlib/matplotlib/blob/5054100eaf8b49cfd8d42cac9c224f9f5dd92508/.github/workflows/cibuildwheel.yml#L81
windows-2022,
# # windows-latest is moving target at the moment
# windows-latest,
# To make this work, likely need some more trickery, see:
# - https://github.com/matplotlib/matplotlib/blob/5054100eaf8b49cfd8d42cac9c224f9f5dd92508/pyproject.toml#L89
# windows-11-arm,
# Maybe something crazy required,
# see numpy's fun https://github.com/numpy/numpy/blob/main/.github/windows_arm64_steps/action.yml
macos-13,
macos-14,
]

steps:
- uses: actions/checkout@v5

- name: Setup Python
if: ${{ startsWith(matrix.os, 'windows') }}
uses: actions/setup-python@v5
with:
python-version: '3.x'

# Maybe not necessary, source:
# https://dvdhrm.github.io/2021/04/21/meson-msvc-github-actions/
# and
# https://github.com/numpy/numpy/blob/71eebaf8513dfd6ed40b0c689702d81e3f6f2527/.github/workflows/wheels.yml#L123
- name: Setup MSVC developer shell (32-bit)
if: ${{ matrix.os == 'windows-2022' }}
uses: bus1/cabuild/action/msdevshell@v1
with:
architecture: x64

- name: Install Fortran compiler
# When building from source, ensure we have a Fortran compiler
if: ${{ startsWith(matrix.os, 'macos') }}
uses: fortran-lang/setup-fortran@v1
id: setup-fortran
with:
# TODO: figure out whether we need/want to use other compilers too
compiler: "gcc"
version: "13"

- name: Set macOS-13 specific flags
if: matrix.os == 'macos-13'
run: |
echo "MACOSX_DEPLOYMENT_TARGET=13.0" >> "$GITHUB_ENV"

- name: Set macOS-14 specific flags
if: matrix.os == 'macos-14'
run: |
echo "MACOSX_DEPLOYMENT_TARGET=14.0" >> "$GITHUB_ENV"

- name: Build wheels
uses: pypa/cibuildwheel@v3.1.4
# env:
# CIBW_SOME_OPTION: value
# ...
with:
package-dir: .
output-dir: wheelhouse
config-file: "{package}/pyproject.toml"

- uses: actions/upload-artifact@v4
with:
name: cibw-wheels-${{ matrix.os }}-${{ strategy.job-index }}
path: wheelhouse/*.whl

make_sdist:
name: Make source distribution
runs-on: "ubuntu-latest"

steps:
- name: Check out repository
uses: actions/checkout@v4
with:
fetch-depth: 0

- uses: ./.github/actions/setup
with:
python-version: ${{ matrix.python-version }}
uv-dependency-install-flags: "--all-extras --group dev"

- name: Create source distribution
run: uv build --sdist

- name: Upload the source distribution artefact
uses: actions/upload-artifact@v4
with:
name: cibw-sdist
path: dist/*.tar.gz

deploy-pypi:
needs: [build_wheels, make_sdist]
# Having an environment for deployment is strongly recommend by PyPI
# https://docs.pypi.org/trusted-publishers/adding-a-publisher/#github-actions
# You can comment this line out if you don't want it.
# # TODO: turn back on when we only run this on main
# environment: deploy
# permissions:
# # this permission is mandatory for trusted publishing with PyPI
# id-token: write
runs-on: ubuntu-latest
steps:
- name: Download artefacts
uses: actions/download-artifact@v5
with:
pattern: cibw-*
path: dist
merge-multiple: true
- name: Publish to PyPI
run: |
ls dist
# uv publish
Loading