Skip to content

Commit c8cf765

Browse files
committed
Require python>=3.11 and cython>=3.1 for limited api support
1 parent 1cfa52d commit c8cf765

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

cmake/FindCython.cmake

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,31 @@ IF (CYTHON_BIN)
2424
else (CYTHON_RESULT EQUAL 0)
2525
SET(Cython_Compilation_Failed TRUE)
2626
endif (CYTHON_RESULT EQUAL 0)
27+
execute_process(
28+
COMMAND ${CYTHON_BIN} --version
29+
RESULT_VARIABLE CYTHON_VERSION_RESULT
30+
OUTPUT_VARIABLE CYTHON_VERSION_OUTPUT
31+
ERROR_VARIABLE CYTHON_VERSION_ERROR
32+
)
33+
if (CYTHON_VERSION_RESULT EQUAL 0)
34+
string(STRIP ${CYTHON_VERSION_OUTPUT} CYTHON_VERSION_OUTPUT)
35+
if ("${CYTHON_VERSION_OUTPUT}" MATCHES "Cython version")
36+
string(SUBSTRING "${CYTHON_VERSION_OUTPUT}" 15 -1 CYTHON_VERSION)
37+
endif ()
38+
endif ()
39+
message(STATUS "Cython version: ${CYTHON_VERSION}")
2740
ENDIF (CYTHON_BIN)
2841

2942

3043
IF (Cython_FOUND)
3144
IF (NOT Cython_FIND_QUIETLY)
3245
MESSAGE(STATUS "Found CYTHON: ${CYTHON_BIN}")
3346
ENDIF (NOT Cython_FIND_QUIETLY)
47+
IF (WITH_PY_LIMITED_API AND "${CYTHON_VERSION}" VERSION_LESS "3.1")
48+
MESSAGE(FATAL_ERROR
49+
"Your Cython version (${CYTHON_VERSION}) is too old. Please upgrade Cython to 3.1 or newer."
50+
)
51+
ENDIF ()
3452
ELSE (Cython_FOUND)
3553
IF (Cython_FIND_REQUIRED)
3654
if(Cython_Compilation_Failed)

setup.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,8 @@ def cmake_build(self):
128128
if self.py_limited_api:
129129
assert self.py_limited_api.startswith("cp3")
130130
py_ver_minor = int(self.py_limited_api[3:])
131+
if py_ver_minor < 11:
132+
raise ValueError(f"symengine needs at least cp311 limited API support. Got {self.py_limited_api}")
131133
h = 3 * 16**6 + py_ver_minor * 16**4
132134
cmake_cmd.append(f"-DWITH_PY_LIMITED_API={h}")
133135

0 commit comments

Comments
 (0)