Skip to content

Commit

Permalink
Python Stable ABI: Use Stable ABI, by default on CMake 3.26 (needs Py…
Browse files Browse the repository at this point in the history
…thon 3.7+)

This setting allows only API that is binary-compatible
with multiple Python versions: from 3.7+ until the next major version
is introduced.
  • Loading branch information
encukou committed Sep 21, 2023
1 parent 87ec463 commit 1da65d2
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
11 changes: 10 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,14 @@ project(rpm
)

# user configurable stuff
include(CMakeDependentOption)
option(ENABLE_CUTF8 "Enable C.UTF-8 as default locale" ON)
option(ENABLE_NLS "Enable native language support" ON)
option(ENABLE_OPENMP "Enable OpenMP threading support" ON)
option(ENABLE_PYTHON "Enable Python bindings" ON)
cmake_dependent_option(
ENABLE_PYTHON_SABI "Build Python bindings with the Stable ABI" ON
"ENABLE_PYTHON; CMAKE_VERSION VERSION_GREATER_EQUAL 3.26" OFF)
option(ENABLE_PLUGINS "Enable plugin support" ON)
option(ENABLE_WERROR "Stop build on warnings" OFF)
option(ENABLE_SQLITE "Enable sqlite rpmdb support" ON)
Expand Down Expand Up @@ -234,7 +238,11 @@ endif()
list(APPEND db_backends dummy)

if (ENABLE_PYTHON)
find_package(Python3 3.2 COMPONENTS Interpreter Development REQUIRED)
if (ENABLE_PYTHON_SABI)
find_package(Python3 3.7 COMPONENTS Interpreter Development.SABIModule REQUIRED)
else ()
find_package(Python3 3.2 COMPONENTS Interpreter Development REQUIRED)
endif ()
endif()

if (WITH_CAP)
Expand Down Expand Up @@ -344,6 +352,7 @@ if (LIBDW_FOUND)
set(HAVE_LIBDW 1)
endif()

include(CheckSymbolExists)
check_symbol_exists(major "sys/sysmacros.h" MAJOR_IN_SYSMACROS)
if (NOT MAJOR_IN_SYSMACROS)
check_symbol_exists(major "sys/mkdev.h" MAJOR_IN_MKDEV)
Expand Down
8 changes: 7 additions & 1 deletion python/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Python3_add_library(_rpm
set (sources
rpmmodule.c rpmsystem-py.h
header-py.c header-py.h
rpmarchive-py.c rpmarchive-py.h
Expand All @@ -17,6 +17,12 @@ Python3_add_library(_rpm
rpmver-py.c rpmver-py.h
spec-py.c spec-py.h
)

if (ENABLE_PYTHON_SABI)
Python3_add_library(_rpm USE_SABI 3.7 ${sources})
else ()
Python3_add_library(_rpm ${sources})
endif ()

target_link_libraries(_rpm PRIVATE librpmio librpm librpmbuild librpmsign)

Expand Down

0 comments on commit 1da65d2

Please sign in to comment.