Skip to content

Commit 0958710

Browse files
authored
Add cibuildwheel config (#113)
Add cibuildwheel config to publish wheels
1 parent ec9d1dd commit 0958710

File tree

5 files changed

+183
-4
lines changed

5 files changed

+183
-4
lines changed

.github/workflows/cibuildwheel.yml

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
name: Build
2+
3+
on:
4+
push:
5+
tags:
6+
# ytf did they invent their own syntax that's almost regex?
7+
# ** matches 'zero or more of any character'
8+
- 'release-v[0-9]+.[0-9]+.[0-9]+**'
9+
- 'prerelease-v[0-9]+.[0-9]+.[0-9]+**'
10+
jobs:
11+
build_wheels:
12+
name: Build wheels on ${{ matrix.os }}
13+
runs-on: ${{ matrix.os }}
14+
strategy:
15+
matrix:
16+
# macos-13 is an intel runner, macos-14 is apple silicon
17+
os: [ubuntu-latest, windows-latest, macos-13, macos-14]
18+
19+
steps:
20+
- uses: actions/checkout@v4
21+
- name: Build wheels
22+
uses: pypa/[email protected]
23+
env:
24+
CIBW_SOME_OPTION: value
25+
with:
26+
package-dir: .
27+
output-dir: wheelhouse
28+
config-file: "{package}/pyproject.toml"
29+
- uses: actions/upload-artifact@v4
30+
with:
31+
name: cibw-wheels-${{ matrix.os }}-${{ strategy.job-index }}
32+
path: ./wheelhouse/*.whl
33+
34+
build_sdist:
35+
name: Build source distribution
36+
runs-on: ubuntu-latest
37+
steps:
38+
- uses: actions/checkout@v4
39+
40+
- name: Build sdist
41+
run: pipx run build --sdist
42+
- uses: actions/upload-artifact@v4
43+
with:
44+
name: cibw-sdist
45+
path: dist/*.tar.gz
46+
create_release:
47+
needs: [build_wheels, build_sdist]
48+
runs-on: ubuntu-latest
49+
permissions:
50+
contents: write
51+
checks: write
52+
actions: read
53+
issues: read
54+
packages: write
55+
pull-requests: read
56+
repository-projects: read
57+
statuses: read
58+
steps:
59+
- name: Get the tag name and determine if it's a prerelease
60+
id: get_tag_info
61+
run: |
62+
FULL_TAG=${GITHUB_REF#refs/tags/}
63+
if [[ $FULL_TAG == release-* ]]; then
64+
TAG_NAME=${FULL_TAG#release-}
65+
IS_PRERELEASE=false
66+
elif [[ $FULL_TAG == prerelease-* ]]; then
67+
TAG_NAME=${FULL_TAG#prerelease-}
68+
IS_PRERELEASE=true
69+
else
70+
echo "Tag does not match expected patterns" >&2
71+
exit 1
72+
fi
73+
echo "FULL_TAG=$TAG_NAME" >> $GITHUB_ENV
74+
echo "TAG_NAME=$TAG_NAME" >> $GITHUB_ENV
75+
echo "IS_PRERELEASE=$IS_PRERELEASE" >> $GITHUB_ENV
76+
- uses: actions/download-artifact@v4
77+
with:
78+
# unpacks all CIBW artifacts into dist/
79+
pattern: cibw-*
80+
path: dist
81+
merge-multiple: true
82+
- name: Create Draft Release
83+
id: create_release
84+
uses: softprops/action-gh-release@v2
85+
if: startsWith(github.ref, 'refs/tags/')
86+
env:
87+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
88+
with:
89+
name: ${{ env.TAG_NAME }}
90+
draft: true
91+
prerelease: ${{ env.IS_PRERELEASE }}
92+
files: "./dist/*"

.github/workflows/publish_pypi.yml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# The cibuildwheel action triggers on creation of a release, this
2+
# triggers on publication.
3+
# The expected workflow is to create a draft release and let the wheels
4+
# upload, and then hit 'publish', which uploads to PyPi.
5+
6+
on:
7+
release:
8+
types:
9+
- published
10+
11+
jobs:
12+
upload_pypi:
13+
runs-on: ubuntu-latest
14+
environment:
15+
name: pypi
16+
url: https://pypi.org/p/srsly
17+
permissions:
18+
id-token: write
19+
contents: read
20+
if: github.event_name == 'release' && github.event.action == 'published'
21+
# or, alternatively, upload to PyPI on every tag starting with 'v' (remove on: release above to use this)
22+
# if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')
23+
steps:
24+
- uses: robinraju/release-downloader@v1
25+
with:
26+
tag: ${{ github.event.release.tag_name }}
27+
fileName: '*'
28+
out-file-path: 'dist'
29+
- uses: pypa/gh-action-pypi-publish@release/v1

.github/workflows/tests.yml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,18 @@ name: tests
22

33
on:
44
push:
5+
tags-ignore:
6+
- '**'
57
paths-ignore:
68
- "*.md"
9+
- ".github/cibuildwheel.yml"
10+
- ".github/publish_pypi.yml"
711
pull_request:
812
types: [opened, synchronize, reopened, edited]
913
paths-ignore:
1014
- "*.md"
11-
15+
- ".github/cibuildwheel.yml"
16+
- ".github/publish_pypi.yml"
1217
env:
1318
MODULE_NAME: 'srsly'
1419
RUN_MYPY: 'false'
@@ -27,7 +32,6 @@ jobs:
2732
steps:
2833
- name: Check out repo
2934
uses: actions/checkout@v3
30-
3135
- name: Configure Python version
3236
uses: actions/setup-python@v4
3337
with:

pyproject.toml

Lines changed: 55 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,60 @@
11
[build-system]
22
requires = [
33
"setuptools",
4-
"cython>=0.29.1,<0.30.0",
4+
"cython>=0.25",
55
]
66
build-backend = "setuptools.build_meta"
7+
8+
[tool.cibuildwheel]
9+
build = "*"
10+
skip = "pp* cp36* cp37* cp38*"
11+
test-skip = ""
12+
free-threaded-support = false
13+
14+
archs = ["native"]
15+
16+
build-frontend = "default"
17+
config-settings = {}
18+
dependency-versions = "pinned"
19+
environment = {}
20+
environment-pass = []
21+
build-verbosity = 0
22+
23+
before-all = ""
24+
before-build = ""
25+
repair-wheel-command = ""
26+
27+
test-command = ""
28+
before-test = ""
29+
test-requires = []
30+
test-extras = []
31+
32+
container-engine = "docker"
33+
34+
manylinux-x86_64-image = "manylinux2014"
35+
manylinux-i686-image = "manylinux2014"
36+
manylinux-aarch64-image = "manylinux2014"
37+
manylinux-ppc64le-image = "manylinux2014"
38+
manylinux-s390x-image = "manylinux2014"
39+
manylinux-pypy_x86_64-image = "manylinux2014"
40+
manylinux-pypy_i686-image = "manylinux2014"
41+
manylinux-pypy_aarch64-image = "manylinux2014"
42+
43+
musllinux-x86_64-image = "musllinux_1_2"
44+
musllinux-i686-image = "musllinux_1_2"
45+
musllinux-aarch64-image = "musllinux_1_2"
46+
musllinux-ppc64le-image = "musllinux_1_2"
47+
musllinux-s390x-image = "musllinux_1_2"
48+
49+
50+
[tool.cibuildwheel.linux]
51+
repair-wheel-command = "auditwheel repair -w {dest_dir} {wheel}"
52+
53+
[tool.cibuildwheel.macos]
54+
repair-wheel-command = "delocate-wheel --require-archs {delocate_archs} -w {dest_dir} -v {wheel}"
55+
56+
[tool.cibuildwheel.windows]
57+
58+
[tool.cibuildwheel.pyodide]
59+
60+

setup.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ classifiers =
2727
[options]
2828
zip_safe = true
2929
include_package_data = true
30-
python_requires = >=3.9
30+
python_requires = >=3.9,<3.14
3131
setup_requires =
3232
cython>=0.29.1
3333
install_requires =

0 commit comments

Comments
 (0)