File tree Expand file tree Collapse file tree 2 files changed +32
-16
lines changed
Expand file tree Collapse file tree 2 files changed +32
-16
lines changed Original file line number Diff line number Diff line change @@ -34,25 +34,42 @@ FetchContent_Declare(
3434
3535FetchContent_MakeAvailable (nanobind)
3636
37- if (Python_VERSION VERSION_GREATER_EQUAL "3.12" )
37+ if (Python_VERSION VERSION_GREATER_EQUAL "3.12" AND Python_SABIModule_FOUND)
38+ message (STATUS "Building with Python stable ABI (abi3)" )
3839 nanobind_add_module (pylibremidi STABLE_ABI NB_STATIC pylibremidi.cpp )
3940else ()
41+ message (STATUS "Building with Python version-specific ABI" )
4042 nanobind_add_module (pylibremidi NB_STATIC pylibremidi.cpp )
4143endif ()
4244target_link_libraries (pylibremidi PUBLIC libremidi readerwriterqueue Boost::headers Boost::variant2 Boost::container )
4345
44- nanobind_add_stub (
45- pylibremidi_stub
46- MODULE pylibremidi
47- OUTPUT pylibremidi.pyi
48- PYTHON_PATH $<TARGET_FILE_DIR :pylibremidi >
49- DEPENDS pylibremidi
50- )
51-
5246install (TARGETS pylibremidi LIBRARY DESTINATION .)
5347
54- install (
55- FILES ${CMAKE_CURRENT_BINARY_DIR} /pylibremidi.pyi
56- DESTINATION .
57- OPTIONAL
58- )
48+ set (CAN_RUN_STUB_GENERATOR TRUE )
49+ if (APPLE )
50+ execute_process (COMMAND uname -m OUTPUT_VARIABLE HOST_ARCH OUTPUT_STRIP_TRAILING_WHITESPACE )
51+ if (CMAKE_OSX_ARCHITECTURES)
52+ set (TARGET_ARCH "${CMAKE_OSX_ARCHITECTURES} " )
53+ else ()
54+ set (TARGET_ARCH "${CMAKE_SYSTEM_PROCESSOR} " )
55+ endif ()
56+ if (NOT HOST_ARCH STREQUAL TARGET_ARCH)
57+ set (CAN_RUN_STUB_GENERATOR FALSE )
58+ endif ()
59+ endif ()
60+
61+ if (CAN_RUN_STUB_GENERATOR)
62+ nanobind_add_stub (
63+ pylibremidi_stub
64+ MODULE pylibremidi
65+ OUTPUT pylibremidi.pyi
66+ PYTHON_PATH $<TARGET_FILE_DIR :pylibremidi >
67+ DEPENDS pylibremidi
68+ )
69+
70+ install (
71+ FILES ${CMAKE_CURRENT_BINARY_DIR} /pylibremidi.pyi
72+ DESTINATION .
73+ OPTIONAL
74+ )
75+ endif ()
Original file line number Diff line number Diff line change @@ -136,9 +136,8 @@ environment = { MACOSX_DEPLOYMENT_TARGET = "10.14" }
136136[tool .cibuildwheel .windows ]
137137archs = [" AMD64" , " ARM64" ]
138138
139- # For Python 3.12+, use stable ABI
140139[[tool .cibuildwheel .overrides ]]
141- select = " cp312-*"
140+ select = " cp312-macosx_* cp312-manylinux_ *"
142141config-settings = " cmake.build-type=Release"
143142inherit.environment = " append"
144143environment = { SKBUILD_WHEEL_PY_API = " cp312" }
You can’t perform that action at this time.
0 commit comments