Skip to content

Commit 8cd9901

Browse files
authored
Merge pull request #219 from geonnave/ci-build-wheels-multiplatform
Add CI action to build python wheels for many platforms
2 parents 9b7c1ae + 0f85f82 commit 8cd9901

File tree

2 files changed

+97
-15
lines changed

2 files changed

+97
-15
lines changed

.github/workflows/build-and-test.yml

+8-15
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ jobs:
132132
path: ./target/lakers-c-*.zip
133133

134134

135-
build-lakers-python:
135+
test-lakers-python:
136136
needs: check-style
137137
runs-on: ubuntu-latest
138138

@@ -143,22 +143,20 @@ jobs:
143143
- name: Checkout repo
144144
uses: actions/checkout@v3
145145

146-
- name: Build Python package
146+
- name: set up python
147+
uses: actions/setup-python@v5
148+
with:
149+
python-version: '3.10'
150+
151+
- name: Test Python package
147152
run: |
148153
cd lakers-python
149154
python3 -m venv .venv
150155
source .venv/bin/activate
151156
pip install --upgrade pip
152-
pip install -U pip maturin pytest
157+
pip install -U maturin pytest
153158
pip freeze
154159
maturin develop && pytest
155-
maturin build
156-
157-
- name: Upload artifact
158-
uses: actions/upload-artifact@v3
159-
with:
160-
name: lakers-python
161-
path: ./target/wheels/*.whl
162160
163161
164162
run-example-on-qemu:
@@ -247,11 +245,6 @@ jobs:
247245
with:
248246
name: lakers-c
249247
path: ./release-artifacts
250-
- name: Download artifacts
251-
uses: actions/download-artifact@v3
252-
with:
253-
name: lakers-python
254-
path: ./release-artifacts
255248
- name: Release
256249
uses: ncipollo/release-action@v1
257250
with:

.github/workflows/python-wheels.yml

+89
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
name: Build Python wheels
2+
3+
on:
4+
push:
5+
branches: [main]
6+
tags: 'v*'
7+
workflow_dispatch:
8+
9+
jobs:
10+
build-python-wheels:
11+
name: Build wheels on ${{ matrix.os }} with Python ${{ matrix.python-version }}
12+
runs-on: ${{ matrix.os }}
13+
strategy:
14+
fail-fast: false
15+
matrix:
16+
os: [
17+
ubuntu-latest,
18+
windows-latest,
19+
macos-13, # latest non-beta version
20+
] # see https://docs.github.com/en/actions/using-github-hosted-runners/about-github-hosted-runners/about-github-hosted-runners
21+
python-version: [
22+
'3.10',
23+
'3.11',
24+
'3.12',
25+
] # see https://devguide.python.org/versions/
26+
27+
steps:
28+
- uses: actions/checkout@v4
29+
30+
- name: Set up rust
31+
uses: dtolnay/rust-toolchain@stable
32+
with:
33+
toolchain: stable
34+
35+
- name: Set up Python
36+
uses: actions/setup-python@v5
37+
with:
38+
python-version: ${{ matrix.python-version }}
39+
architecture: x64
40+
41+
- name: Install maturin
42+
run: python -m pip install maturin
43+
44+
- name: Build source distribution # do this only once
45+
run: |
46+
cd lakers-python
47+
maturin build --sdist --out wheelhouse
48+
if: matrix.os == 'ubuntu-latest' && matrix.python-version == '3.11'
49+
50+
- name: Build wheels
51+
run: |
52+
cd lakers-python
53+
maturin build --release --out wheelhouse
54+
55+
- uses: actions/upload-artifact@v4
56+
with:
57+
name: wheel-${{ matrix.os }}-python-${{ matrix.python-version }}
58+
path: ./lakers-python/wheelhouse/lakers_python*
59+
60+
release:
61+
runs-on: ubuntu-latest
62+
needs: [build-python-wheels]
63+
if: >-
64+
github.event_name == 'push' &&
65+
startsWith(github.event.ref, 'refs/tags')
66+
67+
steps:
68+
- uses: actions/checkout@v4
69+
70+
- name: set up python
71+
uses: actions/setup-python@v5
72+
with:
73+
python-version: '3.10'
74+
75+
- run: pip install -U twine
76+
77+
- name: get wheelhouse artifacts
78+
uses: actions/download-artifact@v4
79+
with:
80+
path: wheelhouse
81+
82+
- run: ls -lah ./wheelhouse/*/lakers_python*
83+
- run: twine check ./wheelhouse/*/lakers_python*
84+
85+
- name: upload to pypi
86+
run: twine upload ./wheelhouse/*/lakers_python*
87+
env:
88+
TWINE_USERNAME: __token__
89+
TWINE_PASSWORD: ${{ secrets.PYPI_UPLOAD_TOKEN }}

0 commit comments

Comments
 (0)