gemini-code-assist[bot] commented on code in PR #98:
URL: https://github.com/apache/tvm-ffi/pull/98#discussion_r2418377690
##########
CMakeLists.txt:
##########
@@ -192,17 +192,18 @@ if (TVM_FFI_BUILD_PYTHON_MODULE)
${CMAKE_CURRENT_SOURCE_DIR}/python/tvm_ffi/cython/object.pxi
${CMAKE_CURRENT_SOURCE_DIR}/python/tvm_ffi/cython/string.pxi
)
- # set working directory to source so we can see the exact file name in
backtrace relatived to the
- # project source root
- add_custom_command(
- OUTPUT ${_core_cpp}
- COMMAND ${Python_EXECUTABLE} -m cython --cplus ${_core_pyx} -o ${_core_cpp}
- WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
- COMMENT "Transpiling ${_core_pyx} to ${_core_cpp}"
- DEPENDS ${_cython_sources}
- VERBATIM
+ # Run a Python script to check for free-threaded build
+ execute_process(
+ COMMAND ${Python_EXECUTABLE} -c
+ "import sysconfig;
print(sysconfig.get_config_var('Py_GIL_DISABLED') == 1)"
+ OUTPUT_VARIABLE PYTHON_IS_FREE_THREADED
+ OUTPUT_STRIP_TRAILING_WHITESPACE
)
- if (Python_VERSION VERSION_GREATER_EQUAL "3.12")
+ if (PYTHON_IS_FREE_THREADED)
+ message(STATUS "Free-threaded Python detected.")
+ endif ()
Review Comment:

The `add_custom_command` for Cython transpilation seems to have been
accidentally removed. This command is necessary to generate `${_core_cpp}` from
`${_core_pyx}`, which is then used by `python_add_library`. Without it, the
build will fail.
The new `execute_process` block to detect free-threaded Python is correct,
but it should be added alongside the `add_custom_command`, not as a replacement.
```
# set working directory to source so we can see the exact file name in
backtrace relatived to the
# project source root
add_custom_command(
OUTPUT ${_core_cpp}
COMMAND ${Python_EXECUTABLE} -m cython --cplus ${_core_pyx} -o
${_core_cpp}
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
COMMENT "Transpiling ${_core_pyx} to ${_core_cpp}"
DEPENDS ${_cython_sources}
VERBATIM
)
# Run a Python script to check for free-threaded build
execute_process(
COMMAND ${Python_EXECUTABLE} -c
"import sysconfig;
print(sysconfig.get_config_var('Py_GIL_DISABLED') == 1)"
OUTPUT_VARIABLE PYTHON_IS_FREE_THREADED
OUTPUT_STRIP_TRAILING_WHITESPACE
)
if (PYTHON_IS_FREE_THREADED)
message(STATUS "Free-threaded Python detected.")
endif ()
```
--
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]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]