-
-
Notifications
You must be signed in to change notification settings - Fork 12
230 lines (206 loc) · 6.66 KB
/
python-package.yml
File metadata and controls
230 lines (206 loc) · 6.66 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
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
name: Build
on:
workflow_dispatch:
inputs:
build_type:
description: 'Type of build to run'
required: true
default: 'all'
type: choice
options:
- all
- wheels
- sdist
create_release:
description: 'Create a new release'
required: true
type: boolean
default: false
upload_to_pypi:
description: 'Upload to PyPI'
required: true
type: boolean
default: false
permissions:
contents: read
jobs:
extract_version:
runs-on: ubuntu-latest
outputs:
version: ${{ steps.get_version.outputs.VERSION }}
permissions:
contents: read
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.12'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install toml
- name: Get version from pyproject.toml
id: get_version
run: |
VERSION=$(python -c "
import toml
import sys
try:
data = toml.load('pyproject.toml')
if 'tool' in data and 'poetry' in data['tool']:
version = data['tool']['poetry']['version']
elif 'project' in data:
version = data['project']['version']
else:
raise KeyError('Unable to find version in pyproject.toml')
print(version)
except Exception as e:
print(f'Error: {str(e)}', file=sys.stderr)
sys.exit(1)
")
echo "VERSION=$VERSION" >> $GITHUB_OUTPUT
build_wheels:
name: Build wheel ${{ matrix.python }}-${{ matrix.buildplat[1] }}-${{ matrix.buildplat[2] }}
runs-on: ${{ matrix.buildplat[0] }}
permissions:
contents: read
if: github.event.inputs.build_type == 'all' || github.event.inputs.build_type == 'wheels'
strategy:
fail-fast: false
matrix:
buildplat:
- [ubuntu-22.04, manylinux_x86_64, ""]
- [ubuntu-22.04, musllinux_x86_64, ""]
- [macos-13, macosx_x86_64, openblas]
- [macos-13, macosx_x86_64, accelerate]
- [macos-14, macosx_arm64, accelerate]
- [windows-2019, win_amd64, ""]
- [windows-2019, win32, ""]
python: ["cp310", "cp311", "cp312", "pp310", "cp313", "cp313t"]
exclude:
- buildplat: [windows-2019, win32, ""]
python: "pp310"
- buildplat: [ ubuntu-22.04, musllinux_x86_64, "" ]
python: "pp310"
- buildplat: [ macos-14, macosx_arm64, accelerate ]
python: "pp310"
- buildplat: [ windows-2019, win_amd64, "" ]
python: "cp313t"
- buildplat: [ windows-2019, win32, "" ]
python: "cp313t"
- buildplat: [ macos-13, macosx_x86_64, openblas]
python: "cp313t"
steps:
- uses: actions/checkout@v4
- name: Setup MSVC (32-bit)
if: ${{ matrix.buildplat[1] == 'win32' }}
uses: bus1/cabuild/action/msdevshell@e22aba57d6e74891d059d66501b6b5aed8123c4d # v1
with:
architecture: 'x86'
- name: Set up Python
uses: actions/setup-python@v3
with:
python-version: '3.x'
- name: Install cibuildwheel
run: |
python -m pip install --upgrade pip
python -m pip install cibuildwheel==2.22.0
- name: Build wheel
uses: pypa/cibuildwheel@ee63bf16da6cddfb925f542f2c7b59ad50e93969 # 2.22
env:
CIBW_PRERELEASE_PYTHONS: True
CIBW_FREE_THREADED_SUPPORT: True
CIBW_BUILD: ${{ matrix.python }}-${{ matrix.buildplat[1] }}
- name: install wheel
shell: bash
run: |
python -m pip install ./wheelhouse/*-${{ matrix.python }}-${{ matrix.buildplat[1] }}-${{ matrix.buildplat[2] }}.whl
- name: Test package import and basic functionality
shell: python
run: |
import sudio
from sudio import Master
# Example basic tests
print("Sudio version:", sudio.__version__)
# Attempt to create a Master instance
master = Master()
print("Master instance created successfully")
- uses: actions/upload-artifact@v3
with:
name: ${{ matrix.python }}-${{ matrix.buildplat[1] }}-${{ matrix.buildplat[2] }}
path: ./wheelhouse/*.whl
build_sdist:
name: Build sdist
runs-on: ubuntu-latest
permissions:
contents: read
if: github.event.inputs.build_type == 'all' || github.event.inputs.build_type == 'sdist'
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v3
with:
python-version: '3.11'
- name: Build sdist
run: |
python -m pip install -U pip build
python -m build --sdist -Csetup-args=-Dallow-noblas=true
- name: Check README rendering for PyPI
run: |
python -m pip install twine
twine check dist/*
- uses: actions/upload-artifact@v3
with:
path: ./dist/*
upload_pypi:
needs: [build_wheels, build_sdist]
runs-on: ubuntu-latest
permissions:
id-token: write
if: github.event.inputs.upload_to_pypi == 'true'
steps:
- uses: actions/download-artifact@v3
with:
name: artifact
path: dist
- name: List Build contents
run: ls -l dist
- uses: pypa/gh-action-pypi-publish@release/v1
with:
user: __token__
password: ${{ secrets.PYPI_TOKEN }}
skip_existing: true
create_release:
needs: [extract_version, build_wheels, build_sdist, upload_pypi]
runs-on: ubuntu-latest
permissions:
contents: write
if: github.event.inputs.create_release == 'true'
steps:
- uses: actions/checkout@v4
- name: Download all artifacts
uses: actions/download-artifact@v3
with:
name: artifact
path: dist
- name: Create and push tag
run: |
git config user.name github-actions
git config user.email github-actions@github.com
git tag v${{ needs.extract_version.outputs.version }}
git push origin v${{ needs.extract_version.outputs.version }}
- name: Create Release
id: create_release
uses: softprops/action-gh-release@v1
with:
tag_name: v${{ needs.extract_version.outputs.version }}
name: Release v${{ needs.extract_version.outputs.version }}
draft: false
prerelease: false
generate_release_notes: true
files: |
dist/**/*.whl
dist/**/*.tar.gz
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}