kou commented on code in PR #43606:
URL: https://github.com/apache/arrow/pull/43606#discussion_r1708730276
##########
cpp/cmake_modules/UseCython.cmake:
##########
@@ -184,4 +184,24 @@ function(cython_add_module _name pyx_target_name
generated_files)
add_dependencies(${_name} ${pyx_target_name})
endfunction()
+execute_process(COMMAND ${PYTHON_EXECUTABLE} -m cython --version
+ OUTPUT_VARIABLE CYTHON_version_output
+ ERROR_VARIABLE CYTHON_version_error
+ RESULT_VARIABLE CYTHON_version_result
+ OUTPUT_STRIP_TRAILING_WHITESPACE
+ ERROR_STRIP_TRAILING_WHITESPACE)
+if(NOT ${CYTHON_version_result} EQUAL 0)
+ set(_error_msg "Command \"${PYTHON_EXECUTABLE} -m cython --version\" failed
with")
+ set(_error_msg "${_error_msg} output:\n${CYTHON_version_error}")
+ message(SEND_ERROR "${_error_msg}")
+else()
+ if("${CYTHON_version_output}" MATCHES "^[Cc]ython version ([^,]+)")
+ set(CYTHON_VERSION "${CMAKE_MATCH_1}")
+ else()
+ if("${CYTHON_version_error}" MATCHES "^[Cc]ython version ([^,]+)")
+ set(CYTHON_VERSION "${CMAKE_MATCH_1}")
+ endif()
Review Comment:
`cython --version` may output to stderr!?
We require Cython 0.29.31 or later:
https://github.com/apache/arrow/blob/e54ad41ee5e3689130cfd5cd7518a9e2ab4b1957/python/pyproject.toml#L20
Can we remove this?
##########
python/CMakeLists.txt:
##########
@@ -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")
+ set(CYTHON_FLAGS "${CYTHON_FLAGS}" "-Xfreethreading_compatible=True")
Review Comment:
```suggestion
list(APPEND CYTHON_FLAGS "-Xfreethreading_compatible=True")
```
##########
cpp/cmake_modules/UseCython.cmake:
##########
@@ -184,4 +184,24 @@ function(cython_add_module _name pyx_target_name
generated_files)
add_dependencies(${_name} ${pyx_target_name})
endfunction()
+execute_process(COMMAND ${PYTHON_EXECUTABLE} -m cython --version
+ OUTPUT_VARIABLE CYTHON_version_output
+ ERROR_VARIABLE CYTHON_version_error
+ RESULT_VARIABLE CYTHON_version_result
Review Comment:
Could you use `CYTHON_XXX` naming such as `CYTHON_VERSION_OUTPUT` in this
file?
##########
cpp/cmake_modules/UseCython.cmake:
##########
@@ -184,4 +184,24 @@ function(cython_add_module _name pyx_target_name
generated_files)
add_dependencies(${_name} ${pyx_target_name})
endfunction()
+execute_process(COMMAND ${PYTHON_EXECUTABLE} -m cython --version
+ OUTPUT_VARIABLE CYTHON_version_output
+ ERROR_VARIABLE CYTHON_version_error
+ RESULT_VARIABLE CYTHON_version_result
+ OUTPUT_STRIP_TRAILING_WHITESPACE
+ ERROR_STRIP_TRAILING_WHITESPACE)
+if(NOT ${CYTHON_version_result} EQUAL 0)
+ set(_error_msg "Command \"${PYTHON_EXECUTABLE} -m cython --version\" failed
with")
+ set(_error_msg "${_error_msg} output:\n${CYTHON_version_error}")
+ message(SEND_ERROR "${_error_msg}")
+else()
+ if("${CYTHON_version_output}" MATCHES "^[Cc]ython version ([^,]+)")
+ set(CYTHON_VERSION "${CMAKE_MATCH_1}")
+ else()
+ if("${CYTHON_version_error}" MATCHES "^[Cc]ython version ([^,]+)")
+ set(CYTHON_VERSION "${CMAKE_MATCH_1}")
+ endif()
+ endif()
+endif()
Review Comment:
Can we simplify this like the following for Cython 0.29.31 or later?
```suggestion
execute_process(COMMAND ${PYTHON_EXECUTABLE} -m cython --version
OUTPUT_VARIABLE CYTHON_VERSION_OUTPUT
OUTPUT_STRIP_TRAILING_WHITESPACE)
if(CYTHON_VERSION_OUTPUT MATCHES "^Cython version (.+)")
set(CYTHON_VERSION "${CMAKE_MATCH_1}")
else()
set(CYTHON_VERSION "")
endif()
```
##########
cpp/cmake_modules/UseCython.cmake:
##########
@@ -184,4 +184,24 @@ function(cython_add_module _name pyx_target_name
generated_files)
add_dependencies(${_name} ${pyx_target_name})
endfunction()
+execute_process(COMMAND ${PYTHON_EXECUTABLE} -m cython --version
Review Comment:
It'll work.
If we take a code to our project, we need to mention its license to
`LICENSE.txt`.
I think that both of our `UseCython.cmake` and scikit-build's
`FindCython.cmake` are based on DyND's one:
https://github.com/libdynd/dynd-python/tree/master/cmake
We have a section for DyND in our `LICENSE.txt`:
https://github.com/apache/arrow/blob/e54ad41ee5e3689130cfd5cd7518a9e2ab4b1957/LICENSE.txt#L1845-L1884
Could you also add scikit-build's license information to `LICENSE.txt`?
BTW, can we use `check_cxx_compiler_flag()` like approach (try building with
the flag to check availability) instead of version check approach? (Is it too
complicated?)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]