Skip to content

Commit 6122901

Browse files
authored
Merge pull request #19 from isuruf/freethreading
Freethreading support
2 parents e177a58 + cdda4dc commit 6122901

File tree

6 files changed

+112
-34
lines changed

6 files changed

+112
-34
lines changed

.github/workflows/automerge.yml

Lines changed: 0 additions & 19 deletions
This file was deleted.

.github/workflows/webservices.yml

Lines changed: 0 additions & 13 deletions
This file was deleted.

recipe/meta.yaml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,9 @@ source:
1010
sha256: fa48beb9b8d4574482edf19dc8671d4cb78f53c2511047a0e52bb88fbdeb6d0c
1111
folder: python
1212
patches:
13-
- 0001-cython-3.1-fixes.patch
13+
- patches/0001-cython-3.1-fixes.patch
14+
- patches/0002-Another-cython-3.1-fix.patch
15+
- patches/0003-freethreading-support.patch
1416

1517
- url: https://github.com/symengine/symengine/releases/download/v{{ cxx_version }}/symengine-{{ cxx_version }}.tar.gz
1618
sha256: f46bcf037529cd1a422369327bf360ad4c7d2b02d0f607a62a5b09c74a55bb59

recipe/0001-cython-3.1-fixes.patch renamed to recipe/patches/0001-cython-3.1-fixes.patch

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
From 1e47d959c4edd9c15e1f893a570e4b0082a39501 Mon Sep 17 00:00:00 2001
22
From: Isuru Fernando <[email protected]>
33
Date: Sun, 29 Sep 2024 16:25:26 -0500
4-
Subject: [PATCH] cython 3.1 fixes
4+
Subject: [PATCH 1/3] cython 3.1 fixes
55

66
---
77
cmake/cython_test.pyx | 3 ---
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
From 845168d3683f28781b32577abf4f38ed93f0bc79 Mon Sep 17 00:00:00 2001
2+
From: Isuru Fernando <[email protected]>
3+
Date: Mon, 30 Sep 2024 11:38:54 -0500
4+
Subject: [PATCH 2/3] Another cython 3.1 fix
5+
6+
---
7+
cmake/cython_test.pyx | 4 ++--
8+
1 file changed, 2 insertions(+), 2 deletions(-)
9+
10+
diff --git a/cmake/cython_test.pyx b/cmake/cython_test.pyx
11+
index cb803c6..47f9847 100644
12+
--- a/cmake/cython_test.pyx
13+
+++ b/cmake/cython_test.pyx
14+
@@ -75,8 +75,8 @@ cdef extern from "<symengine/symbol.h>" namespace "SymEngine":
15+
string get_name() nogil
16+
17+
cdef extern from "<symengine/add.h>" namespace "SymEngine":
18+
- cdef RCP[Basic] add(RCP[Basic] &a, RCP[Basic] &b) nogil except+
19+
- cdef RCP[Basic] sub(RCP[Basic] &a, RCP[Basic] &b) nogil except+
20+
+ cdef RCP[Basic] add(RCP[Basic] &a, RCP[Basic] &b) except+ nogil
21+
+ cdef RCP[Basic] sub(RCP[Basic] &a, RCP[Basic] &b) except+ nogil
22+
23+
cdef cppclass Add(Basic):
24+
void as_two_terms(const Ptr[RCP[Basic]] &a, const Ptr[RCP[Basic]] &b)
25+
--
26+
2.44.0
27+
Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
From 170e7ded46b60ee43ec1e6ee997fd95205cad2f4 Mon Sep 17 00:00:00 2001
2+
From: Isuru Fernando <[email protected]>
3+
Date: Mon, 30 Sep 2024 11:39:06 -0500
4+
Subject: [PATCH 3/3] freethreading support
5+
6+
---
7+
cmake/FindPython.cmake | 32 +++++++++++++++++++++++---------
8+
1 file changed, 23 insertions(+), 9 deletions(-)
9+
10+
diff --git a/cmake/FindPython.cmake b/cmake/FindPython.cmake
11+
index f338132..2f54f50 100644
12+
--- a/cmake/FindPython.cmake
13+
+++ b/cmake/FindPython.cmake
14+
@@ -22,26 +22,36 @@ execute_process(
15+
string(STRIP ${PYTHON_LIB_PATH} PYTHON_LIB_PATH)
16+
17+
execute_process(
18+
- COMMAND ${PYTHON_BIN} -c "import sys; print(sys.prefix)"
19+
- OUTPUT_VARIABLE PYTHON_PREFIX_PATH
20+
- )
21+
+ COMMAND ${PYTHON_BIN} -c "import sys; print(sys.prefix)"
22+
+ OUTPUT_VARIABLE PYTHON_PREFIX_PATH
23+
+)
24+
25+
string(STRIP ${PYTHON_PREFIX_PATH} PYTHON_PREFIX_PATH)
26+
27+
execute_process(
28+
- COMMAND ${PYTHON_BIN} -c "import sys; print('%s.%s' % sys.version_info[:2])"
29+
+ COMMAND ${PYTHON_BIN} -c "import sys; print('%s.%s' % sys.version_info[:2])"
30+
OUTPUT_VARIABLE PYTHON_VERSION
31+
- )
32+
+)
33+
string(STRIP ${PYTHON_VERSION} PYTHON_VERSION)
34+
message(STATUS "Python version: ${PYTHON_VERSION}")
35+
36+
string(REPLACE "." "" PYTHON_VERSION_WITHOUT_DOTS ${PYTHON_VERSION})
37+
38+
+execute_process(
39+
+ COMMAND ${PYTHON_BIN} -c "import sysconfig;print(bool(sysconfig.get_config_var('Py_GIL_DISABLED')))"
40+
+ OUTPUT_VARIABLE PY_GIL_DISABLED
41+
+)
42+
+string(STRIP ${PY_GIL_DISABLED} PY_GIL_DISABLED)
43+
+
44+
+if ("${PY_GIL_DISABLED}" STREQUAL "True")
45+
+ set (PY_THREAD "t")
46+
+endif()
47+
+
48+
if (${CMAKE_SYSTEM_NAME} STREQUAL "Windows")
49+
FIND_LIBRARY(PYTHON_LIBRARY NAMES
50+
- python${PYTHON_VERSION}
51+
+ python${PYTHON_VERSION}${PY_THREAD}
52+
python${PYTHON_VERSION}m
53+
- python${PYTHON_VERSION_WITHOUT_DOTS}
54+
+ python${PYTHON_VERSION_WITHOUT_DOTS}${PY_THREAD}
55+
PATHS ${PYTHON_LIB_PATH} ${PYTHON_PREFIX_PATH}/lib ${PYTHON_PREFIX_PATH}/libs
56+
PATH_SUFFIXES ${CMAKE_LIBRARY_ARCHITECTURE}
57+
NO_DEFAULT_PATH
58+
@@ -51,8 +61,8 @@ endif()
59+
60+
execute_process(
61+
COMMAND ${PYTHON_BIN} -c "from sysconfig import get_paths; print(get_paths()['purelib'])"
62+
- OUTPUT_VARIABLE PYTHON_INSTALL_PATH_tmp
63+
- )
64+
+ OUTPUT_VARIABLE PYTHON_INSTALL_PATH_tmp
65+
+)
66+
string(STRIP ${PYTHON_INSTALL_PATH_tmp} PYTHON_INSTALL_PATH_tmp)
67+
set(PYTHON_INSTALL_PATH ${PYTHON_INSTALL_PATH_tmp}
68+
CACHE BOOL "Python install path")
69+
@@ -129,5 +139,9 @@ macro(ADD_PYTHON_LIBRARY name)
70+
IF(${CMAKE_SYSTEM_NAME} STREQUAL "Windows")
71+
target_link_libraries(${name} ${PYTHON_LIBRARY})
72+
set_target_properties(${name} PROPERTIES SUFFIX ".pyd")
73+
+ IF("${PY_GIL_DISABLED}" STREQUAL "True")
74+
+ target_compile_definitions(${name} PRIVATE Py_GIL_DISABLED=1)
75+
+ ENDIF()
76+
ENDIF()
77+
+
78+
endmacro(ADD_PYTHON_LIBRARY)
79+
--
80+
2.44.0
81+

0 commit comments

Comments
 (0)