Skip to content

Commit 68f6a54

Browse files
authored
limited api wheels for 3.12+ with cython 3.1 (#2051)
no longer need dev cython for 3.13t
1 parent 0584dfe commit 68f6a54

File tree

4 files changed

+39
-11
lines changed

4 files changed

+39
-11
lines changed

.github/workflows/test.yml

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,10 @@ concurrency:
2525

2626
env:
2727
FORCE_COLOR: "1"
28+
# only affects Windows, but easiest to set here for now
29+
SETUPTOOLS_ENABLE_FEATURES: "legacy-editable"
30+
# don't compile Cython if we are building from source
31+
NO_CYTHON_COMPILE: "true"
2832

2933
jobs:
3034
test:
@@ -71,10 +75,11 @@ jobs:
7175
- os: ubuntu-22.04
7276
python: "3.11"
7377
zmq: head
78+
tornado: head
7479

7580
- os: ubuntu-24.04
7681
python: "3.12"
77-
tornado: head
82+
abi: cp312
7883

7984
- os: ubuntu-24.04
8085
python: "3.13"
@@ -124,9 +129,6 @@ jobs:
124129
if: ${{ matrix.free_threading }}
125130
run: |
126131
echo "PYTHON_GIL=0" >> "$GITHUB_ENV"
127-
# need prerelease Cython until 3.1 is out
128-
echo "PIP_PRE=1" >> "$GITHUB_ENV"
129-
echo "PIP_EXTRA_INDEX_URL=https://pypi.anaconda.org/scientific-python-nightly-wheels/simple" >> "$GITHUB_ENV"
130132
echo "EXTRA_PIP=--no-binary coverage" >> "$GITHUB_ENV"
131133
132134
- name: setup coverage
@@ -187,6 +189,11 @@ jobs:
187189
echo "PYZMQ_BACKEND=${{ matrix.backend }}" >> "$GITHUB_ENV"
188190
pip install cffi
189191
192+
- name: set stable ABI
193+
if: matrix.abi
194+
run: |
195+
echo "PIP_CONFIG_SETTINGS=wheel.py-api=${{ matrix.abi }}" >> "$GITHUB_ENV"
196+
190197
- name: install libzmq-dev
191198
if: matrix.zmq == 'head'
192199
run: |

CMakeLists.txt

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,13 @@ set(CMAKE_POLICY_DEFAULT_CMP0077 NEW)
55
list(PREPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake)
66
find_package(
77
Python
8-
COMPONENTS Interpreter Development.Module
8+
COMPONENTS Interpreter Development.Module ${SKBUILD_SABI_COMPONENT}
99
REQUIRED)
1010

1111
# Python_SOABI isn't always right when cross-compiling
1212
# SKBUILD_SOABI seems to be
1313
if (DEFINED SKBUILD_SOABI AND NOT "${SKBUILD_SOABI}" STREQUAL "${Python_SOABI}")
14-
message(WARNING "SKBUILD_SOABI=${SKBUILD_SOABI} != Python_SOABI=${Python_SOABI}; likely cross-compiling, using SOABI=${SKBUILD_SOABI} from scikit-build")
14+
message(WARNING "SKBUILD_SOABI=${SKBUILD_SOABI} != Python_SOABI=${Python_SOABI}; likely cross-compiling or Limited API, using SOABI=${SKBUILD_SOABI} from scikit-build")
1515
set(Python_SOABI "${SKBUILD_SOABI}")
1616
endif()
1717

@@ -431,9 +431,16 @@ endif()
431431

432432
file(MAKE_DIRECTORY ${ZMQ_BACKEND_DEST})
433433

434+
if(NOT "${SKBUILD_SABI_COMPONENT}" STREQUAL "")
435+
# set stable ABI
436+
set(SABI_ARG "USE_SABI;${SKBUILD_SABI_VERSION}")
437+
message(STATUS "Building with stable ABI ${Python_SOABI} for ${SKBUILD_SABI_VERSION}")
438+
endif()
439+
434440
python_add_library(
435441
${ZMQ_EXT_NAME} MODULE
436442
WITH_SOABI
443+
${SABI_ARG}
437444
${ZMQ_C}
438445
)
439446

pyproject.toml

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,11 @@ install.components = ["pyzmq"]
6262
if.env.PYZMQ_BACKEND = "cffi"
6363
build.requires = ["cffi"]
6464

65+
[[tool.scikit-build.overrides]]
66+
if.any.env.PYZMQ_LATEST_CYTHON = true
67+
build.requires = ["cython @ https://github.com/cython/cython/archive/HEAD.tar.gz"]
68+
69+
6570
[tool.ruff]
6671

6772
[tool.ruff.format]
@@ -149,6 +154,10 @@ build-verbosity = "1"
149154
enable = ["cpython-freethreading", "pypy"]
150155
test-requires = ["pytest>=6", "importlib_metadata"]
151156
test-command = "pytest -vsx {package}/tools/test_wheel.py"
157+
build-frontend = "build"
158+
159+
[tool.cibuildwheel.environment]
160+
NO_CYTHON_COMPILE = "true"
152161

153162
[tool.cibuildwheel.linux]
154163
before-all = "bash tools/install_libzmq.sh"
@@ -195,16 +204,20 @@ repair-wheel-command = """\
195204
"cmake.define.ZMQ_HAVE_IPC" = "OFF"
196205
"cmake.define.POLLER" = "select"
197206

198-
199207
# manylinux2010 for (less) old cp37-9, pp37-8
200208
[[tool.cibuildwheel.overrides]]
201209
select = "cp3{7,8,9}-* pp3{7,8}-*"
202210
manylinux-x86_64-image = "manylinux2010"
203211
manylinux-i686-image = "manylinux2010"
204212

213+
# build limited-api wheels for 3.12
214+
[[tool.cibuildwheel.overrides]]
215+
select = "cp312-*"
216+
inherit.config-settings = "append"
217+
config-settings."wheel.py-api" = "cp312"
218+
before-build = "pip install abi3audit"
219+
inherit.repair-wheel-command = "append"
220+
repair-wheel-command = "abi3audit --strict --report {wheel}"
221+
205222
# note: manylinux_2_28 builds are added
206223
# in .github/workflows/wheels.yml
207-
208-
[[tool.cibuildwheel.overrides]]
209-
select = "cp313t-*"
210-
build-frontend = "pip; args: -v --pre --extra-index-url https://pypi.anaconda.org/scientific-python-nightly-wheels/simple"

tools/wheel-requirements.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
1+
abi3audit
12
cibuildwheel==2.23.*
23
delvewheel==1.10.*; sys_platform == 'win32'

0 commit comments

Comments
 (0)