Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add CI action to build python wheels for many platforms #219

Merged
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
23 changes: 8 additions & 15 deletions .github/workflows/build-and-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ jobs:
path: ./target/lakers-c-*.zip


build-lakers-python:
test-lakers-python:
needs: check-style
runs-on: ubuntu-latest

Expand All @@ -143,22 +143,20 @@ jobs:
- name: Checkout repo
uses: actions/checkout@v3

- name: Build Python package
- name: set up python
uses: actions/setup-python@v5
with:
python-version: '3.10'

- name: Test Python package
run: |
cd lakers-python
python3 -m venv .venv
source .venv/bin/activate
pip install --upgrade pip
pip install -U pip maturin pytest
pip install -U maturin pytest
pip freeze
maturin develop && pytest
maturin build

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


run-example-on-qemu:
Expand Down Expand Up @@ -247,11 +245,6 @@ jobs:
with:
name: lakers-c
path: ./release-artifacts
- name: Download artifacts
uses: actions/download-artifact@v3
with:
name: lakers-python
path: ./release-artifacts
- name: Release
uses: ncipollo/release-action@v1
with:
Expand Down
89 changes: 89 additions & 0 deletions .github/workflows/python-wheels.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
name: Build Python wheels

on:
push:
branches: [main]
tags: 'v*'
workflow_dispatch:

jobs:
build-python-wheels:
name: Build wheels on ${{ matrix.os }} with Python ${{ matrix.python-version }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [
ubuntu-latest,
windows-latest,
macos-13, # latest non-beta version
] # see https://docs.github.com/en/actions/using-github-hosted-runners/about-github-hosted-runners/about-github-hosted-runners
python-version: [
'3.10',
'3.11',
'3.12',
] # see https://devguide.python.org/versions/

steps:
- uses: actions/checkout@v4

- name: Set up rust
uses: dtolnay/rust-toolchain@stable
with:
toolchain: stable

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
architecture: x64

- name: Install maturin
run: python -m pip install maturin

- name: Build source distribution # do this only once
run: |
cd lakers-python
maturin build --sdist --out wheelhouse
if: matrix.os == 'ubuntu-latest' && matrix.python-version == '3.11'

- name: Build wheels
run: |
cd lakers-python
maturin build --release --out wheelhouse

- uses: actions/upload-artifact@v4
with:
name: wheel-${{ matrix.os }}-python-${{ matrix.python-version }}
path: ./lakers-python/wheelhouse/lakers_python*

release:
runs-on: ubuntu-latest
needs: [build-python-wheels]
if: >-
github.event_name == 'push' &&
startsWith(github.event.ref, 'refs/tags')

steps:
- uses: actions/checkout@v4

- name: set up python
uses: actions/setup-python@v5
with:
python-version: '3.10'

- run: pip install -U twine

- name: get wheelhouse artifacts
uses: actions/download-artifact@v4
with:
path: wheelhouse

- run: ls -lah ./wheelhouse/*/lakers_python*
- run: twine check ./wheelhouse/*/lakers_python*

- name: upload to pypi
run: twine upload ./wheelhouse/*/lakers_python*
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.PYPI_UPLOAD_TOKEN }}
Loading