This is an automated email from the ASF dual-hosted git repository.
kou pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/arrow.git
The following commit(s) were added to refs/heads/main by this push:
new e8e9d1ac2b GH-43536: [Python] Declare support for free-threading in
Cython (#43606)
e8e9d1ac2b is described below
commit e8e9d1ac2b9761b40eb0e041127285b55655e49c
Author: Lysandros Nikolaou <[email protected]>
AuthorDate: Wed Aug 14 01:46:02 2024 +0200
GH-43536: [Python] Declare support for free-threading in Cython (#43606)
### Rationale for this change
This is done by passing an extra flag when building the Cython extension
modules. It is needed so that the GIL is not dynamically reenabled when
importing `pyarrow.lib`.
### What changes are included in this PR?
Changes to CMake so that the extra flag is passed when building Cython
extension modules.
* GitHub Issue: #43536
Lead-authored-by: Lysandros Nikolaou <[email protected]>
Co-authored-by: Sutou Kouhei <[email protected]>
Signed-off-by: Sutou Kouhei <[email protected]>
---
cpp/cmake_modules/UseCython.cmake | 5 +++++
python/CMakeLists.txt | 5 +++++
2 files changed, 10 insertions(+)
diff --git a/cpp/cmake_modules/UseCython.cmake
b/cpp/cmake_modules/UseCython.cmake
index e15ac59490..7d88daa4fa 100644
--- a/cpp/cmake_modules/UseCython.cmake
+++ b/cpp/cmake_modules/UseCython.cmake
@@ -184,4 +184,9 @@ function(cython_add_module _name pyx_target_name
generated_files)
add_dependencies(${_name} ${pyx_target_name})
endfunction()
+execute_process(COMMAND ${PYTHON_EXECUTABLE} -c "from Cython.Compiler.Version
import version; print(version)"
+ OUTPUT_VARIABLE CYTHON_VERSION_OUTPUT
+ OUTPUT_STRIP_TRAILING_WHITESPACE)
+set(CYTHON_VERSION "${CYTHON_VERSION_OUTPUT}")
+
include(CMakeParseArguments)
diff --git a/python/CMakeLists.txt b/python/CMakeLists.txt
index a90dee7058..5d5eeaf815 100644
--- a/python/CMakeLists.txt
+++ b/python/CMakeLists.txt
@@ -260,6 +260,7 @@ message(STATUS "Found NumPy version:
${Python3_NumPy_VERSION}")
message(STATUS "NumPy include dir: ${NUMPY_INCLUDE_DIRS}")
include(UseCython)
+message(STATUS "Found Cython version: ${CYTHON_VERSION}")
# Arrow C++ and set default PyArrow build options
include(GNUInstallDirs)
@@ -855,6 +856,10 @@ set(CYTHON_FLAGS "${CYTHON_FLAGS}" "--warning-errors")
# undocumented Cython feature.
set(CYTHON_FLAGS "${CYTHON_FLAGS}" "--no-c-in-traceback")
+if(CYTHON_VERSION VERSION_GREATER_EQUAL "3.1.0a0")
+ list(APPEND CYTHON_FLAGS "-Xfreethreading_compatible=True")
+endif()
+
foreach(module ${CYTHON_EXTENSIONS})
string(REPLACE "." ";" directories ${module})
list(GET directories -1 module_name)