-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #19 from isuruf/freethreading
Freethreading support
- Loading branch information
Showing
6 changed files
with
112 additions
and
34 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
recipe/0001-cython-3.1-fixes.patch → recipe/patches/0001-cython-3.1-fixes.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
From 845168d3683f28781b32577abf4f38ed93f0bc79 Mon Sep 17 00:00:00 2001 | ||
From: Isuru Fernando <isuruf@gmail.com> | ||
Date: Mon, 30 Sep 2024 11:38:54 -0500 | ||
Subject: [PATCH 2/3] Another cython 3.1 fix | ||
|
||
--- | ||
cmake/cython_test.pyx | 4 ++-- | ||
1 file changed, 2 insertions(+), 2 deletions(-) | ||
|
||
diff --git a/cmake/cython_test.pyx b/cmake/cython_test.pyx | ||
index cb803c6..47f9847 100644 | ||
--- a/cmake/cython_test.pyx | ||
+++ b/cmake/cython_test.pyx | ||
@@ -75,8 +75,8 @@ cdef extern from "<symengine/symbol.h>" namespace "SymEngine": | ||
string get_name() nogil | ||
|
||
cdef extern from "<symengine/add.h>" namespace "SymEngine": | ||
- cdef RCP[Basic] add(RCP[Basic] &a, RCP[Basic] &b) nogil except+ | ||
- cdef RCP[Basic] sub(RCP[Basic] &a, RCP[Basic] &b) nogil except+ | ||
+ cdef RCP[Basic] add(RCP[Basic] &a, RCP[Basic] &b) except+ nogil | ||
+ cdef RCP[Basic] sub(RCP[Basic] &a, RCP[Basic] &b) except+ nogil | ||
|
||
cdef cppclass Add(Basic): | ||
void as_two_terms(const Ptr[RCP[Basic]] &a, const Ptr[RCP[Basic]] &b) | ||
-- | ||
2.44.0 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
From 170e7ded46b60ee43ec1e6ee997fd95205cad2f4 Mon Sep 17 00:00:00 2001 | ||
From: Isuru Fernando <isuruf@gmail.com> | ||
Date: Mon, 30 Sep 2024 11:39:06 -0500 | ||
Subject: [PATCH 3/3] freethreading support | ||
|
||
--- | ||
cmake/FindPython.cmake | 32 +++++++++++++++++++++++--------- | ||
1 file changed, 23 insertions(+), 9 deletions(-) | ||
|
||
diff --git a/cmake/FindPython.cmake b/cmake/FindPython.cmake | ||
index f338132..2f54f50 100644 | ||
--- a/cmake/FindPython.cmake | ||
+++ b/cmake/FindPython.cmake | ||
@@ -22,26 +22,36 @@ execute_process( | ||
string(STRIP ${PYTHON_LIB_PATH} PYTHON_LIB_PATH) | ||
|
||
execute_process( | ||
- COMMAND ${PYTHON_BIN} -c "import sys; print(sys.prefix)" | ||
- OUTPUT_VARIABLE PYTHON_PREFIX_PATH | ||
- ) | ||
+ COMMAND ${PYTHON_BIN} -c "import sys; print(sys.prefix)" | ||
+ OUTPUT_VARIABLE PYTHON_PREFIX_PATH | ||
+) | ||
|
||
string(STRIP ${PYTHON_PREFIX_PATH} PYTHON_PREFIX_PATH) | ||
|
||
execute_process( | ||
- COMMAND ${PYTHON_BIN} -c "import sys; print('%s.%s' % sys.version_info[:2])" | ||
+ COMMAND ${PYTHON_BIN} -c "import sys; print('%s.%s' % sys.version_info[:2])" | ||
OUTPUT_VARIABLE PYTHON_VERSION | ||
- ) | ||
+) | ||
string(STRIP ${PYTHON_VERSION} PYTHON_VERSION) | ||
message(STATUS "Python version: ${PYTHON_VERSION}") | ||
|
||
string(REPLACE "." "" PYTHON_VERSION_WITHOUT_DOTS ${PYTHON_VERSION}) | ||
|
||
+execute_process( | ||
+ COMMAND ${PYTHON_BIN} -c "import sysconfig;print(bool(sysconfig.get_config_var('Py_GIL_DISABLED')))" | ||
+ OUTPUT_VARIABLE PY_GIL_DISABLED | ||
+) | ||
+string(STRIP ${PY_GIL_DISABLED} PY_GIL_DISABLED) | ||
+ | ||
+if ("${PY_GIL_DISABLED}" STREQUAL "True") | ||
+ set (PY_THREAD "t") | ||
+endif() | ||
+ | ||
if (${CMAKE_SYSTEM_NAME} STREQUAL "Windows") | ||
FIND_LIBRARY(PYTHON_LIBRARY NAMES | ||
- python${PYTHON_VERSION} | ||
+ python${PYTHON_VERSION}${PY_THREAD} | ||
python${PYTHON_VERSION}m | ||
- python${PYTHON_VERSION_WITHOUT_DOTS} | ||
+ python${PYTHON_VERSION_WITHOUT_DOTS}${PY_THREAD} | ||
PATHS ${PYTHON_LIB_PATH} ${PYTHON_PREFIX_PATH}/lib ${PYTHON_PREFIX_PATH}/libs | ||
PATH_SUFFIXES ${CMAKE_LIBRARY_ARCHITECTURE} | ||
NO_DEFAULT_PATH | ||
@@ -51,8 +61,8 @@ endif() | ||
|
||
execute_process( | ||
COMMAND ${PYTHON_BIN} -c "from sysconfig import get_paths; print(get_paths()['purelib'])" | ||
- OUTPUT_VARIABLE PYTHON_INSTALL_PATH_tmp | ||
- ) | ||
+ OUTPUT_VARIABLE PYTHON_INSTALL_PATH_tmp | ||
+) | ||
string(STRIP ${PYTHON_INSTALL_PATH_tmp} PYTHON_INSTALL_PATH_tmp) | ||
set(PYTHON_INSTALL_PATH ${PYTHON_INSTALL_PATH_tmp} | ||
CACHE BOOL "Python install path") | ||
@@ -129,5 +139,9 @@ macro(ADD_PYTHON_LIBRARY name) | ||
IF(${CMAKE_SYSTEM_NAME} STREQUAL "Windows") | ||
target_link_libraries(${name} ${PYTHON_LIBRARY}) | ||
set_target_properties(${name} PROPERTIES SUFFIX ".pyd") | ||
+ IF("${PY_GIL_DISABLED}" STREQUAL "True") | ||
+ target_compile_definitions(${name} PRIVATE Py_GIL_DISABLED=1) | ||
+ ENDIF() | ||
ENDIF() | ||
+ | ||
endmacro(ADD_PYTHON_LIBRARY) | ||
-- | ||
2.44.0 | ||
|