Skip to content

Commit 9c74407

Browse files
author
root
committed
add new gh action and fix poetry version in gh actions
1 parent 4f880aa commit 9c74407

2 files changed

Lines changed: 273 additions & 0 deletions

File tree

Lines changed: 272 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,272 @@
1+
name: Build Wheels
2+
3+
on:
4+
workflow_dispatch:
5+
pull_request:
6+
push:
7+
tags:
8+
- "v*.*.*"
9+
10+
jobs:
11+
build_sdist:
12+
name: "sdist"
13+
runs-on: ${{ matrix.os }}
14+
strategy:
15+
fail-fast: false
16+
matrix:
17+
os: [ubuntu-latest]
18+
steps:
19+
- name: Check out repository
20+
uses: actions/checkout@v4
21+
with:
22+
fetch-depth: 0
23+
24+
- name: Set up python 3.12
25+
uses: actions/setup-python@v5
26+
with:
27+
python-version: "3.12"
28+
29+
- name: Install poetry
30+
uses: snok/install-poetry@v1
31+
32+
- name: Build sdist
33+
run: |
34+
poetry self add "poetry-dynamic-versioning[plugin]"
35+
poetry build --format=sdist
36+
37+
- uses: actions/upload-artifact@v4
38+
with:
39+
name: wheels-sdist
40+
path: dist/*.tar.gz
41+
42+
build_wheels_windows:
43+
name: "${{ matrix.os }} ${{ matrix.cibw_archs }} ${{ matrix.cibw_build }}"
44+
runs-on: ${{ matrix.os }}
45+
strategy:
46+
fail-fast: false
47+
matrix:
48+
os: [windows-latest]
49+
cibw_build: ["cp38-*", "cp39-*", "cp310-*", "cp311-*", "cp312-*"]
50+
cibw_archs: ["AMD64", "x86", "ARM64"]
51+
exclude:
52+
- os: windows-latest
53+
cibw_build: "cp38-*"
54+
cibw_archs: "ARM64"
55+
56+
steps:
57+
- name: "Set environment variables (Windows)"
58+
shell: pwsh
59+
run: |
60+
(Get-ItemProperty "HKLM:System\CurrentControlSet\Control\FileSystem").LongPathsEnabled
61+
62+
- name: Sanitize matrix.cibw_build
63+
id: sanitize_build
64+
run: echo "CIBW_BUILD_SANITIZED=$(echo '${{ matrix.cibw_build }}' | sed 's/\*/_/g')" >> $GITHUB_ENV
65+
shell: bash
66+
67+
- name: Check out repository
68+
uses: actions/checkout@v4
69+
with:
70+
fetch-depth: 0
71+
72+
- name: Set up python 3.12
73+
uses: actions/setup-python@v5
74+
with:
75+
python-version: "3.12"
76+
77+
- name: Install poetry
78+
uses: snok/install-poetry@v1
79+
with:
80+
virtualenvs-create: false
81+
virtualenvs-in-project: false
82+
installer-parallel: false # Currently there seems to be some race-condition in windows
83+
84+
- name: Build wheels
85+
uses: pypa/cibuildwheel@v2.16.5
86+
env:
87+
CIBW_ARCHS: ${{ matrix.cibw_archs }}
88+
CIBW_BUILD: ${{ matrix.cibw_build }}
89+
CIBW_TEST_SKIP: "*-win_arm64"
90+
CIBW_TEST_REQUIRES: pytest
91+
CIBW_TEST_COMMAND: pytest {package}/tests
92+
93+
- uses: actions/upload-artifact@v4
94+
with:
95+
name: wheels-${{ matrix.os }}-${{ env.CIBW_BUILD_SANITIZED }}-${{ matrix.cibw_archs }}
96+
path: wheelhouse/*.whl
97+
98+
build_wheels_linux:
99+
name: "${{ matrix.os }} ${{ matrix.cibw_archs }} ${{ matrix.cibw_build }}"
100+
runs-on: ${{ matrix.os }}
101+
strategy:
102+
fail-fast: false
103+
matrix:
104+
os: [ubuntu-latest]
105+
cibw_build: ["cp38-*", "cp39-*", "cp310-*", "cp311-*", "cp312-*"]
106+
cibw_archs: ["x86_64", "i686", "aarch64", "ppc64le"]
107+
108+
steps:
109+
- name: Check out repository
110+
uses: actions/checkout@v4
111+
with:
112+
fetch-depth: 0
113+
114+
- name: Sanitize matrix.cibw_build
115+
id: sanitize_build
116+
run: echo "CIBW_BUILD_SANITIZED=$(echo '${{ matrix.cibw_build }}' | sed 's/\*/_/g')" >> $GITHUB_ENV
117+
shell: bash
118+
119+
- name: Set up QEMU
120+
if: matrix.cibw_archs != 'x86_64'
121+
uses: docker/setup-qemu-action@v3
122+
with:
123+
platforms: all
124+
125+
- name: Set up python 3.12
126+
uses: actions/setup-python@v5
127+
with:
128+
python-version: "3.12"
129+
130+
- name: Install poetry
131+
uses: snok/install-poetry@v1
132+
with:
133+
virtualenvs-create: false
134+
virtualenvs-in-project: false
135+
136+
- name: Build wheels
137+
uses: pypa/cibuildwheel@v2.16.5
138+
env:
139+
CIBW_ARCHS: ${{ matrix.cibw_archs }}
140+
CIBW_BUILD: ${{ matrix.cibw_build }}
141+
CIBW_TEST_REQUIRES: pytest
142+
CIBW_TEST_COMMAND: pytest {package}/tests
143+
144+
- uses: actions/upload-artifact@v4
145+
with:
146+
name: wheels-${{ matrix.os }}-${{ env.CIBW_BUILD_SANITIZED }}-${{ matrix.cibw_archs }}
147+
path: wheelhouse/*.whl
148+
149+
build_wheels_macos:
150+
name: "${{ matrix.os }} ${{ matrix.cibw_archs }} ${{ matrix.cibw_build }}"
151+
runs-on: ${{ matrix.os }}
152+
strategy:
153+
fail-fast: false
154+
matrix:
155+
os: [macos-13]
156+
cibw_build: ["cp38-*", "cp39-*", "cp310-*", "cp311-*", "cp312-*"]
157+
cibw_archs: ["x86_64"]
158+
env:
159+
SYSTEM_VERSION_COMPAT: 0 # https://github.com/actions/setup-python/issues/469#issuecomment-1192522949
160+
steps:
161+
- name: Check out repository
162+
uses: actions/checkout@v4
163+
with:
164+
fetch-depth: 0
165+
166+
- name: Sanitize matrix.cibw_build
167+
id: sanitize_build
168+
run: echo "CIBW_BUILD_SANITIZED=$(echo '${{ matrix.cibw_build }}' | sed 's/\*/_/g')" >> $GITHUB_ENV
169+
shell: bash
170+
171+
- name: Set up python 3.12
172+
uses: actions/setup-python@v5
173+
with:
174+
python-version: "3.12"
175+
176+
- name: Install poetry
177+
uses: snok/install-poetry@v1
178+
with:
179+
virtualenvs-create: false
180+
virtualenvs-in-project: false
181+
182+
- name: Build wheels
183+
uses: pypa/cibuildwheel@v2.16.5
184+
env:
185+
CIBW_ARCHS: ${{ matrix.cibw_archs }}
186+
CIBW_BUILD: ${{ matrix.cibw_build }}
187+
CIBW_TEST_REQUIRES: pytest
188+
CIBW_TEST_COMMAND: pytest {package}/tests
189+
190+
- uses: actions/upload-artifact@v4
191+
with:
192+
name: wheels-${{ matrix.os }}-${{ env.CIBW_BUILD_SANITIZED }}-${{ matrix.cibw_archs }}
193+
path: wheelhouse/*.whl
194+
195+
build_wheels_macos_arm64:
196+
name: "${{ matrix.os }} ${{ matrix.cibw_archs }} ${{ matrix.cibw_build }}"
197+
runs-on: ${{ matrix.os }}
198+
strategy:
199+
matrix:
200+
os: [macos-13]
201+
cibw_build: ["cp38-*", "cp39-*", "cp310-*", "cp311-*", "cp312-*"]
202+
cibw_archs: ["arm64"]
203+
204+
steps:
205+
- name: Check out repository
206+
uses: actions/checkout@v4
207+
with:
208+
fetch-depth: 0
209+
210+
- uses: actions/setup-python@v5
211+
with:
212+
python-version: "3.12"
213+
214+
- name: Build wheels
215+
uses: pypa/cibuildwheel@v2.16.5
216+
env:
217+
CIBW_BUILD: ${{ matrix.cibw_build }}
218+
CIBW_ARCHS: ${{ matrix.cibw_archs }}
219+
CIBW_TEST_SKIP: "*-macosx_arm64"
220+
CIBW_TEST_REQUIRES: pytest
221+
CIBW_TEST_COMMAND: pytest {package}/tests
222+
CIBW_REPAIR_WHEEL_COMMAND: |
223+
echo "Target delocate archs: {delocate_archs}"
224+
225+
ORIGINAL_WHEEL={wheel}
226+
227+
echo "Running delocate-listdeps to list linked original wheel dependencies"
228+
delocate-listdeps --all $ORIGINAL_WHEEL
229+
230+
echo "Renaming .whl file when architecture is 'macosx_arm64'"
231+
RENAMED_WHEEL=${ORIGINAL_WHEEL//x86_64/arm64}
232+
233+
echo "Wheel will be renamed to $RENAMED_WHEEL"
234+
mv $ORIGINAL_WHEEL $RENAMED_WHEEL
235+
236+
echo "Running delocate-wheel command on $RENAMED_WHEEL"
237+
delocate-wheel --require-archs {delocate_archs} -w {dest_dir} -v $RENAMED_WHEEL
238+
239+
echo "Running delocate-listdeps to list linked wheel dependencies"
240+
WHEEL_SIMPLE_FILENAME="${RENAMED_WHEEL##*/}"
241+
delocate-listdeps --all {dest_dir}/$WHEEL_SIMPLE_FILENAME
242+
243+
echo "DONE."
244+
245+
- uses: actions/upload-artifact@v4
246+
with:
247+
name: wheels-${{ matrix.os }}-${{ matrix.cibw_build }}-${{ matrix.cibw_archs }}
248+
path: ./wheelhouse/*.whl
249+
250+
upload_to_pypi:
251+
if: github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags/v')
252+
needs:
253+
[
254+
"build_sdist",
255+
"build_wheels_windows",
256+
"build_wheels_linux",
257+
"build_wheels_macos",
258+
"build_wheels_macos_arm64",
259+
]
260+
runs-on: ubuntu-latest
261+
steps:
262+
- uses: actions/download-artifact@v4
263+
with:
264+
path: wheels
265+
pattern: wheels-*
266+
merge-multiple: true
267+
268+
- uses: pypa/gh-action-pypi-publish@release/v1
269+
with:
270+
password: ${{ secrets.PYPI_TOKEN }}
271+
packages_dir: wheels/
272+
skip_existing: true

.github/workflows/tests.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ jobs:
7777
- name: Install poetry
7878
uses: snok/install-poetry@v1
7979
with:
80+
version: 1.8.5
8081
virtualenvs-create: true
8182
virtualenvs-in-project: true
8283
installer-parallel: false # Currently there seems to be some race-condition in windows

0 commit comments

Comments
 (0)