Skip to content

Commit 1562a4c

Browse files
committed
Fixes for PyPy support
1 parent 9c5c632 commit 1562a4c

File tree

3 files changed

+25
-22
lines changed

3 files changed

+25
-22
lines changed

cmake/FindCython.cmake

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44

55
# This finds the "cython" executable in your PATH, and then in some standard
66
# paths:
7-
SET(CYTHON_BIN cython CACHE STRING "Cython executable name")
7+
8+
find_program(CYTHON_BIN NAMES cython cython3 cython2)
89
SET(CYTHON_FLAGS --cplus --fast-fail)
910

1011
SET(Cython_FOUND FALSE)
@@ -27,21 +28,22 @@ ENDIF (CYTHON_BIN)
2728

2829

2930
IF (Cython_FOUND)
30-
IF (NOT Cython_FIND_QUIETLY)
31-
MESSAGE(STATUS "Found CYTHON: ${CYTHON_BIN}")
32-
ENDIF (NOT Cython_FIND_QUIETLY)
31+
IF (NOT Cython_FIND_QUIETLY)
32+
MESSAGE(STATUS "Found CYTHON: ${CYTHON_BIN}")
33+
ENDIF (NOT Cython_FIND_QUIETLY)
3334
ELSE (Cython_FOUND)
34-
IF (Cython_FIND_REQUIRED)
35+
IF (Cython_FIND_REQUIRED)
3536
if(Cython_Compilation_Failed)
3637
MESSAGE(STATUS "Found CYTHON: ${CYTHON_BIN}")
37-
# On Win the testing of Cython does not return any accessible value, so the test is not carried out. Fresh Cython install was tested and works.
38-
IF(NOT MSVC)
39-
MESSAGE(FATAL_ERROR "Your Cython version is too old. Please upgrade Cython.")
40-
ENDIF(NOT MSVC)
38+
# On Win the testing of Cython does not return any accessible value, so the test is not carried out.
39+
# Fresh Cython install was tested and works.
40+
IF(NOT MSVC)
41+
MESSAGE(FATAL_ERROR "Your Cython version is too old. Please upgrade Cython.")
42+
ENDIF(NOT MSVC)
4143
else(Cython_Compilation_Failed)
4244
MESSAGE(FATAL_ERROR "Could not find Cython. Please install Cython.")
4345
endif(Cython_Compilation_Failed)
44-
ENDIF (Cython_FIND_REQUIRED)
46+
ENDIF (Cython_FIND_REQUIRED)
4547
ENDIF (Cython_FOUND)
4648

4749

cmake/FindPython.cmake

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -56,18 +56,12 @@ set(PYTHON_INSTALL_PATH ${PYTHON_INSTALL_PATH_tmp}
5656
CACHE BOOL "Python install path")
5757
message(STATUS "Python install path: ${PYTHON_INSTALL_PATH}")
5858

59-
if (NOT WIN32)
60-
execute_process(
61-
COMMAND ${PYTHON_BIN} -c "from distutils.sysconfig import get_config_var; print(get_config_var('SOABI'))"
62-
OUTPUT_VARIABLE PYTHON_EXTENSION_SOABI_tmp
63-
)
64-
string(STRIP ${PYTHON_EXTENSION_SOABI_tmp} PYTHON_EXTENSION_SOABI_tmp)
65-
if (NOT "${PYTHON_EXTENSION_SOABI_tmp}" STREQUAL "None")
66-
set(PYTHON_EXTENSION_SOABI_tmp ".${PYTHON_EXTENSION_SOABI_tmp}")
67-
else()
68-
set(PYTHON_EXTENSION_SOABI_tmp "")
69-
endif()
70-
endif()
59+
execute_process(
60+
COMMAND ${PYTHON_BIN} ${CMAKE_CURRENT_SOURCE_DIR}/cmake/get_suffix.py
61+
OUTPUT_VARIABLE PYTHON_EXTENSION_SOABI_tmp
62+
)
63+
string(STRIP ${PYTHON_EXTENSION_SOABI_tmp} PYTHON_EXTENSION_SOABI_tmp)
64+
7165
set(PYTHON_EXTENSION_SOABI ${PYTHON_EXTENSION_SOABI_tmp}
7266
CACHE STRING "Suffix for python extensions")
7367

cmake/get_suffix.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
from __future__ import print_function
2+
from distutils.sysconfig import get_config_var
3+
extsuffix = get_config_var('EXT_SUFFIX')
4+
if extsuffix is None:
5+
print("")
6+
else:
7+
print(extsuffix[0:].rsplit(".", 1)[0])

0 commit comments

Comments
 (0)