Skip to content

Commit

Permalink
Build wheels with cibuildwheel (#31)
Browse files Browse the repository at this point in the history
* Run cibuildwheel in the build environments

* Refactor build environment setup into its own action

* Name custom action correctly

* Specify a shell for each command

* Move cibuildwheel into its own workflow

* Run pytest after building wheels

* Don't build wheels when testing.

* Rename the test CI workflow
  • Loading branch information
kalekundert committed Aug 28, 2023
1 parent cf73337 commit fbd80d4
Show file tree
Hide file tree
Showing 3 changed files with 62 additions and 57 deletions.
24 changes: 24 additions & 0 deletions .github/actions/setup-build-env/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: Setup build environment
description: "Install ninja and a fortran compiler"

# It's assumed that `actions/setup-python` is run before this one.

runs:
using: "composite"
steps:
- uses: awvwgk/setup-fortran@v1

- run: pip install --upgrade pip
shell: bash

- if: runner.os == 'Linux'
run: sudo apt-get install -y ninja-build
shell: bash

- if: runner.os == 'macOS'
run: brew install ninja
shell: bash

- if: runner.os == 'Windows'
run: choco install ninja
shell: bash
74 changes: 37 additions & 37 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Wheels
name: Publish

on:
workflow_dispatch:
Expand All @@ -7,40 +7,40 @@ on:
- published

jobs:
make_sdist:
name: Make SDist
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0 # Optional, use if you use setuptools_scm
submodules: true # Optional, use if you have submodules

- name: Build SDist
run: pipx run build --sdist

- uses: actions/upload-artifact@v3
with:
path: dist/*.tar.gz
make_sdist:
name: Make SDist
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- run: pipx run build --sdist
- uses: actions/upload-artifact@v3
with:
path: dist/*.tar.gz

build_wheels:
name: Wheel on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]

steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
submodules: true

- uses: pypa/cibuildwheel@v2.15

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

build_wheels:
name: Build wheel (${{ matrix.os }})
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
# Excluding windows because it doesn't work. I think that static
# linking might not be compatible with cibuildwheel, and `delvewheel`
# might be a better approach.
os: [ubuntu-latest, macos-latest]

steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: 3.x
- uses: ./.github/actions/setup-build-env
- uses: pypa/cibuildwheel@v2.15
env:
CIBW_TEST_REQUIRES: pytest
CIBW_TEST_COMMAND: pytest {package}
CIBW_SKIP: cp312-* # skip 3.12 until `pip install numpy` works

- uses: actions/upload-artifact@v3
with:
path: wheelhouse/*.whl

21 changes: 1 addition & 20 deletions .github/workflows/ci.yml → .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,26 +25,7 @@ jobs:
- uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- uses: awvwgk/setup-fortran@v1

- name: Install build dependencies
run: |
pip install --upgrade pip
- name: Install build dependencies (Linux)
if: startsWith(matrix.os, 'ubuntu')
run: |
sudo apt-get install -y ninja-build
- name: Install build dependencies (Mac OS)
if: startsWith(matrix.os, 'macos')
run: |
brew install ninja
- name: Install build dependencies (Windows)
if: startsWith(matrix.os, 'windows')
run: |
choco install ninja
- uses: ./.github/actions/setup-build-env

- name: Install py3nj
run: |
Expand Down

0 comments on commit fbd80d4

Please sign in to comment.