-
-
Notifications
You must be signed in to change notification settings - Fork 641
203 lines (175 loc) · 6.6 KB
/
python.yml
File metadata and controls
203 lines (175 loc) · 6.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
name: Python
# Build on every branch push, tag push, and pull request change:
on: [push, pull_request]
jobs:
check_format:
name: Check Python code format
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install uv
uses: astral-sh/setup-uv@v4
with:
version: "latest"
- name: Set up Python and install dependencies
working-directory: tests/python
run: uv sync --project . --python 3.13
- name: Check code format
working-directory: tests/python
run: uv run --project . black --check ../..
build_wheels_quick:
name: Build wheels for quick testing
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
fetch-tags: true # Optional, use if you use setuptools_scm
- name: Build wheels
uses: pypa/[email protected]
env:
CIBW_ARCHS_LINUX: "x86_64"
# We do not need to support Python 3.6–3.8, and we only need
# manylinux for testing. PyPy isn't useful as this is a binary
# extension.
CIBW_SKIP: pp* cp36-* cp37-* cp38-* *-musllinux_*
- uses: actions/upload-artifact@v4
with:
name: cibw-wheels-quick
path: ./wheelhouse/*.whl
test_wheels:
name: Test wheels with Python ${{ matrix.python-version }} and NumPy ${{ matrix.numpy-version }}
needs: [build_wheels_quick]
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
include:
- python-version: "3.9"
numpy-version: "1.25.2"
- python-version: "3.10"
numpy-version: "1.26.4"
- python-version: "3.11"
numpy-version: "1.26.4"
- python-version: "3.12"
numpy-version: "1.26.4"
- python-version: "3.11"
numpy-version: "2.4.2"
- python-version: "3.12"
numpy-version: "2.4.2"
steps:
- uses: actions/checkout@v4
- name: Install uv
uses: astral-sh/setup-uv@v4
with:
version: "latest"
- name: Download wheel artifacts
uses: actions/download-artifact@v4
with:
pattern: cibw-wheels-quick
path: dist
merge-multiple: true
- name: Set up Python ${{ matrix.python-version }} and install dependencies
working-directory: tests/python
run: uv sync --project . --python ${{ matrix.python-version }}
- name: Install NumPy ${{ matrix.numpy-version }}
working-directory: tests/python
run: |
uv pip install --project . --only-binary :all: numpy==${{ matrix.numpy-version }}
- name: Install manylinux wheel built for Python ${{ matrix.python-version }}
working-directory: tests/python
run: uv pip install --project . ../../dist/*cp$(echo ${{ matrix.python-version }} | tr -d .)*.whl
- name: Run tests
working-directory: tests/python
run: uv run --project . pytest
build_wheels_main:
name: Build remaining wheels on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
fetch-tags: true # Optional, use if you use setuptools_scm
- name: Build wheels
uses: pypa/[email protected]
env:
CIBW_ARCHS_MACOS: "x86_64 universal2 arm64"
CIBW_ARCHS_WINDOWS: "AMD64 x86"
# disable aarm64 build since its too slow to build(docker + qemu)
CIBW_ARCHS_LINUX: "x86_64 i686"
# We do not need to support Python 3.6–3.8, and the quick build
# has already taken care of manylinux. PyPy isn't useful as this is
# a binary extension.
CIBW_SKIP: pp* cp36-* cp37-* cp38-* *-manylinux_x86_64
- uses: actions/upload-artifact@v4
with:
name: cibw-wheels-main-${{ matrix.os }}-${{ strategy.job-index }}
path: ./wheelhouse/*.whl
# It looks cibuildwheels did not clean build folder(CMake), and it results to Windows arm64 build failure(trying to reuse x86 build of .obj)
# So supply separated build job for Windows ARM64 build
# TODO: clean build folder using CIBW_BEFORE_ALL?
build_wheels_win_arm64:
name: Build ARM64 wheels on Windows
runs-on: windows-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
fetch-tags: true # Optional, use if you use setuptools_scm
- name: Build wheels
uses: pypa/[email protected]
env:
CIBW_ARCHS_WINDOWS: "ARM64"
CIBW_SKIP: pp*
- uses: actions/upload-artifact@v4
with:
name: cibw-wheels-win-arm64
path: ./wheelhouse/*.whl
make_sdist:
name: Make SDist
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0 # Optional, use if you use setuptools_scm
fetch-tags: true # Optional, use if you use setuptools_scm
- name: Build SDist
run: pipx run build --sdist
- uses: actions/upload-artifact@v4
with:
name: cibw-sdist
path: dist/*.tar.gz
upload_all:
needs: [build_wheels_quick, build_wheels_main, build_wheels_win_arm64, make_sdist]
runs-on: ubuntu-latest
environment: release
permissions:
# IMPORTANT: this permission is mandatory for trusted publishing
id-token: write
# upload to PyPI on every tag starting with 'v'
# NOTE: Without github.event_name & githug.ref check, `upload_all` task is still triggered on 'main' branch push.
# (then get 'Branch "main" is not allowed to deploy to release due to environment protection rules.' error)
# So still do event_name and github.ref check.
# TODO: Make it work only using Github `environment` feature.
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')
# alternatively, to publish when a GitHub Release is created, use the following rule:
# if: github.event_name == 'push' && github.event.action == 'published'
steps:
- uses: actions/download-artifact@v4
with:
pattern: cibw-*
path: dist
merge-multiple: true
- uses: pypa/gh-action-pypi-publish@release/v1
with:
# Use Trusted Publisher feature:
# https://docs.pypi.org/trusted-publishers/
# so no use of PYPI_API_TOKEN
#password: ${{ secrets.PYPI_API_TOKEN }}
#
# Avoid race condition when using multiple CIs
skip-existing: true
verbose: true