The CMake side
Find the Stable ABI library component:
find_package(Python REQUIRED COMPONENTS
Interpreter Development.Module ${SKBUILD_SABI_COMPONENT})
SKBUILD_SABI_COMPONENT expands to Development.SABIModule when targeting
the Stable ABI, and to nothing when not (PyPy, 3.14t, ...).
if(NOT "${SKBUILD_SABI_VERSION}" STREQUAL "")
set(USE_SABI USE_SABI ${SKBUILD_SABI_VERSION})
endif()
python_add_library(some_ext MODULE WITH_SOABI ${USE_SABI} ...)
With USE_SABI 3.12, CMake defines Py_LIMITED_API to match.