Skip to content

Commit 698a516

Browse files
authored
chore: build wheel with limited api (#32)
1 parent a91fc22 commit 698a516

File tree

2 files changed

+87
-14
lines changed

2 files changed

+87
-14
lines changed

.github/workflows/publish.yml

Lines changed: 72 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,9 @@
11
name: publish
22

3-
on:
4-
push:
5-
tags:
6-
- v*
3+
on: [push, pull_request]
74

85
jobs:
9-
pypi:
6+
build:
107
runs-on: ubuntu-latest
118

129
steps:
@@ -15,18 +12,80 @@ jobs:
1512
uses: actions/setup-python@v2
1613
with:
1714
python-version: 3.9
15+
- name: Install python dependencies
16+
run: pip install Cython auditwheel
1817
- name: Build a source tarball
1918
run: python setup.py sdist
20-
- name: Build wheels
21-
uses: RalfG/python-wheels-manylinux-build@v0.4.2-manylinux2014_x86_64
22-
with:
23-
python-versions: 'cp39-cp39 cp310-cp310 cp311-cp311 cp312-cp312 cp313-cp313 cp314-cp314'
24-
build-requirements: 'cython'
25-
- name: Clean linux_x86_64.whl
26-
run: rm dist/*-linux_x86_64.whl
19+
- name: Build Wheel
20+
run: python setup.py bdist_wheel --py-limited-api=cp39
21+
- name: Repair Wheel
22+
run: find dist -name *.whl -print -exec auditwheel repair {} \;
23+
- name: Clean Non Audited Wheel
24+
run: rm -v dist/*-linux_x86_64.whl
2725
- name: Check build result
28-
run: ls -lh dist/
26+
run: |
27+
ls -lh dist
28+
find dist -name *.tar.gz -print -exec tar -ztvf {} \;
29+
ls -lh wheelhouse
30+
find wheelhouse -name *.whl -print -exec unzip -l {} \;
31+
- uses: actions/upload-artifact@v4
32+
with:
33+
name: wheel
34+
path: wheelhouse/*.whl
35+
- uses: actions/upload-artifact@v4
36+
with:
37+
name: sdist
38+
path: dist/*.tar.gz
39+
40+
test:
41+
needs: [build]
42+
runs-on: ubuntu-latest
43+
strategy:
44+
matrix:
45+
pyver: ["3.9", "3.10", "3.11", "3.12", "3.13", "3.14"]
46+
47+
steps:
48+
- uses: actions/checkout@v4
49+
with:
50+
# only checkout files for test
51+
sparse-checkout: |
52+
tests
53+
misc/test.sh
54+
- uses: actions/download-artifact@v4
55+
with:
56+
name: wheel
57+
path: wheel
58+
- name: Set up Python
59+
uses: actions/setup-python@v2
60+
with:
61+
python-version: ${{ matrix.pyver }}
62+
- name: Install python dependencies
63+
run: |
64+
pip install gevent
65+
pip install wheel/*.whl
66+
- name: Run test
67+
run: misc/test.sh
68+
69+
pypi:
70+
needs: [build, test]
71+
runs-on: ubuntu-latest
72+
73+
steps:
74+
- uses: actions/download-artifact@v4
75+
with:
76+
name: wheel
77+
path: dist
78+
- uses: actions/download-artifact@v4
79+
with:
80+
name: sdist
81+
path: dist
82+
- name: dump result
83+
run: |
84+
ls -lh dist
85+
find dist -name *.whl -print -exec unzip -l {} \;
86+
find dist -name *.tar.gz -print -exec tar -ztvf {} \;
2987
- name: Publish to PyPI
88+
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')
3089
uses: pypa/gh-action-pypi-publish@release/v1
3190
with:
3291
skip_existing: true

setup.py

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,24 @@
11
from glob import glob
22
from setuptools import setup, Extension
33

4-
version = "0.4.4"
4+
version = "0.5.0"
55

66

77
def readme():
88
with open("README.rst") as f:
99
return f.read()
1010

1111

12+
def make_limited_api_macro(version):
13+
s = 0
14+
step = 8
15+
pos = step * 3
16+
for i in version.split("."):
17+
s += int(i) << pos
18+
pos -= step
19+
return s
20+
21+
1222
include_dirs = ["include"]
1323
sources = glob("*.pyx") + glob("src/*.c")
1424
libraries = ["dl"]
@@ -50,6 +60,10 @@ def readme():
5060
sources,
5161
include_dirs=include_dirs,
5262
libraries=libraries,
63+
define_macros=[
64+
("Py_LIMITED_API", make_limited_api_macro("3.9")),
65+
],
66+
py_limited_api=True,
5367
)
5468
],
5569
)

0 commit comments

Comments
 (0)