Skip to content

Commit f75d502

Browse files
authored
update cibuildwheel to 3.1 (adds Python 3.14, android wheels) (#2113)
1 parent 11e96ab commit f75d502

File tree

5 files changed

+61
-9
lines changed

5 files changed

+61
-9
lines changed

.github/workflows/wheels.yml

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ jobs:
6767
CIBW_SKIP: "${{ matrix.cibw.skip || '' }}"
6868
CIBW_ARCHS: "${{ matrix.cibw.arch || 'auto' }}"
6969
CIBW_MANYLINUX_X86_64_IMAGE: "${{ matrix.cibw.manylinux_x86_64_image || '' }}"
70+
CIBW_PLATFORM: "${{ matrix.cibw.platform || 'auto' }}"
7071

7172
strategy:
7273
fail-fast: false
@@ -116,6 +117,12 @@ jobs:
116117
cibw:
117118
build: "*musllinux*"
118119

120+
- name: android
121+
os: ubuntu-24.04
122+
cibw:
123+
platform: android
124+
arch: all
125+
119126
- name: win32
120127
os: windows-2022
121128
architecture: x86
@@ -140,10 +147,10 @@ jobs:
140147
cibw:
141148
arch: ARM64
142149
# FIXME:
143-
# 313t fails with:
150+
# 313t and 314t fail with:
144151
# Could NOT find Python (missing: Interpreter Development.Module) (found version "3.13.4")
145152
# unclear why
146-
skip: "cp313t*"
153+
skip: "cp31{3,4}t*"
147154

148155
steps:
149156
- uses: actions/checkout@v4

CMakeLists.txt

Lines changed: 30 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,25 @@
1-
cmake_minimum_required(VERSION 3.14...3.28)
1+
cmake_minimum_required(VERSION 3.14...4.1)
22
project(${SKBUILD_PROJECT_NAME} LANGUAGES C CXX)
33
set(CMAKE_POLICY_DEFAULT_CMP0077 NEW)
44

55
list(PREPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake)
6+
message(STATUS "Building pyzmq for ${CMAKE_SYSTEM_NAME} ${CMAKE_SYSTEM_VERSION}")
7+
8+
if(ANDROID)
9+
# Android seems to need to link libpython,
10+
# which means Development.Embed
11+
set(EXTRA_PYTHON_COMPONENT "Development.Embed")
12+
endif()
13+
614
find_package(
715
Python
8-
COMPONENTS Interpreter Development.Module ${SKBUILD_SABI_COMPONENT}
9-
REQUIRED)
16+
COMPONENTS
17+
Interpreter
18+
Development.Module
19+
${EXTRA_PYTHON_COMPONENT}
20+
${SKBUILD_SABI_COMPONENT}
21+
REQUIRED
22+
)
1023

1124
# Python_SOABI isn't always right when cross-compiling
1225
# SKBUILD_SOABI seems to be
@@ -267,6 +280,15 @@ if (ZMQ_PREFIX STREQUAL "bundled")
267280
--disable-shared
268281
--enable-static
269282
)
283+
284+
# add --host for cross compiling
285+
message(STATUS "Cross: ${CMAKE_CROSSCOMPILING} $ENV{CIBW_HOST_TRIPLET}")
286+
if(CMAKE_CROSSCOMPILING AND DEFINED ENV{CIBW_HOST_TRIPLET})
287+
message(STATUS "Cross compiling libsodium for host: $ENV{CIBW_HOST_TRIPLET}")
288+
list(APPEND libsodium_configure "--host=$ENV{CIBW_HOST_TRIPLET}")
289+
message(STATUS "Cross compiling libsodium for host: $ENV{CIBW_HOST_TRIPLET} ${libsodium_configure}")
290+
endif()
291+
270292
list(APPEND libsodium_configure ${PYZMQ_LIBSODIUM_CONFIGURE_ARGS})
271293
execute_process(
272294
COMMAND ${libsodium_configure}
@@ -456,6 +478,11 @@ else()
456478
message(FATAL_ERROR "should have a libzmq target ${libzmq_target} to link to...")
457479
endif()
458480

481+
if (ANDROID)
482+
message(STATUS "Android: linking libpython ${Python_LIBRARIES}")
483+
target_link_libraries(${ZMQ_EXT_NAME} PRIVATE Python::Python)
484+
endif()
485+
459486
target_include_directories(${ZMQ_EXT_NAME} PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/zmq/utils")
460487
install(TARGETS ${ZMQ_EXT_NAME} DESTINATION "${ZMQ_BACKEND_DEST}" COMPONENT pyzmq)
461488

cmake/Findsodium.cmake

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,11 @@
44
message(CHECK_START "Looking for pyzmq-bundled libsodium")
55
set(SODIUM_FOUND FALSE)
66

7+
# when cross-compiling, paths are ignored by default
8+
# only search given PATHs, never root for libsodium
9+
set(SAVE_ROOT_PATH_MODE "${CMAKE_FIND_ROOT_PATH_MODE_LIBRARY}")
10+
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY "NEVER")
11+
712
set(PKG_CONFIG_USE_CMAKE_PREFIX_PATH ON)
813
find_package(PkgConfig QUIET)
914
if (PkgConfig_FOUND)
@@ -21,18 +26,22 @@ if (NOT SODIUM_FOUND)
2126
find_library(
2227
SODIUM_LIBRARIES
2328
NAMES libsodium.a libsodium.lib
24-
PATH ${BUNDLE_DIR}/lib
29+
PATHS ${BUNDLE_DIR}/lib
30+
NO_DEFAULT_PATH
2531
)
2632
message(STATUS "Found bundled ${SODIUM_LIBRARIES} in ${BUNDLE_DIR}")
2733
if (SODIUM_LIBRARIES)
2834
# pkg-config didn't work, what do we need?
29-
if (NOT MSVC)
35+
if (NOT MSVC AND NOT ANDROID)
3036
list(APPEND SODIUM_LIBRARIES pthread)
3137
endif()
3238
set(SODIUM_FOUND TRUE)
3339
endif()
3440
endif()
3541

42+
# restore CMAKE_FIND_ROOT_PATH_MODE_LIBRARY
43+
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY "${SAVE_ROOT_PATH_MODE}")
44+
3645
if (NOT SODIUM_FOUND)
3746
message(CHECK_FAIL "no")
3847
message(FATAL_ERROR "Failed to find bundled libsodium")

pyproject.toml

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,9 +153,14 @@ search = '__version__: str = "{current_version}"'
153153
build-verbosity = "1"
154154
enable = ["cpython-freethreading", "pypy", "pypy-eol"]
155155
test-requires = ["pytest>=6", "importlib_metadata"]
156-
test-command = "pytest -vsx {package}/tools/test_wheel.py"
156+
test-sources = ["tools/test_wheel.py"]
157+
test-command = "python -m pytest -vsx tools/test_wheel.py"
157158
build-frontend = "build"
158159

160+
# android test env doesn't work on GitHub CI
161+
# "x86_64 emulation currently requires hardware acceleration!"
162+
test-skip = "*-android*"
163+
159164
[tool.cibuildwheel.environment]
160165
NO_CYTHON_COMPILE = "true"
161166

@@ -202,6 +207,10 @@ repair-wheel-command = """\
202207
"cmake.define.ZMQ_HAVE_IPC" = "OFF"
203208
"cmake.define.POLLER" = "select"
204209

210+
[tool.cibuildwheel.android.environment]
211+
# 24 needed for c++
212+
ANDROID_API_LEVEL = "24"
213+
205214
# manylinux2014 for old Python <= 3.9
206215
[[tool.cibuildwheel.overrides]]
207216
select = "cp3{8,9}-* pp3{8,9}-*"

tools/wheel-requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
abi3audit
2-
cibuildwheel==3.0.*
2+
cibuildwheel==3.1.*
33
delvewheel==1.11.*; sys_platform == 'win32'

0 commit comments

Comments
 (0)