Skip to content

Commit

Permalink
style
Browse files Browse the repository at this point in the history
  • Loading branch information
vyasr committed Dec 1, 2023
1 parent 69f78f5 commit 6ecb9b0
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 18 deletions.
17 changes: 14 additions & 3 deletions rapids-cmake/cython-core/create_modules.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,17 @@ function(rapids_cython_create_modules)
endif()

foreach(cython_filename IN LISTS _RAPIDS_CYTHON_SOURCE_FILES)
# TODO: Adding --embed-positions for testing
rapids_cython_compile(SOURCE_FILES ${cython_filename} LANGUAGE_LEVEL 3 TARGET_LANGUAGE ${target_language} CYTHON_ARGS --directive binding=True,embedsignature=True,always_allow_keywords=True --embed-positions)
# TODO: Adding --embed-positions for testing
rapids_cython_compile(SOURCE_FILES
${cython_filename}
LANGUAGE_LEVEL
3
TARGET_LANGUAGE
${target_language}
CYTHON_ARGS
--directive
binding=True,embedsignature=True,always_allow_keywords=True
--embed-positions)

# Generate a reasonable module name.
cmake_path(GET cython_filename FILENAME extension_module)
Expand All @@ -113,7 +122,9 @@ function(rapids_cython_create_modules)
python_add_library(${extension_module} MODULE WITH_SOABI ${transpiled_file})

# The final library name must match the original filename and must ignore the prefix.
set_target_properties(${extension_module} PROPERTIES LIBRARY_OUTPUT_NAME ${extension_module_filename})
# cmake-lint: disable=C0307
set_target_properties(${extension_module} PROPERTIES LIBRARY_OUTPUT_NAME
${extension_module_filename})

# Link the module to the requested libraries
if(DEFINED _RAPIDS_CYTHON_LINKED_LIBRARIES)
Expand Down
20 changes: 11 additions & 9 deletions rapids-cmake/cython-core/cython.cmake
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# =============================================================================
# Copyright (c) 2023 CORPORATION.
# Copyright (c) 2023 NVIDIA CORPORATION.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
# in compliance with the License. You may obtain a copy of the License at
Expand Down Expand Up @@ -74,14 +74,16 @@ function(rapids_cython_compile)
cmake_path(REPLACE_FILENAME cython_filename ${cpp_filename} OUTPUT_VARIABLE cpp_filename)
cmake_path(REMOVE_EXTENSION cython_module)

add_custom_command(
OUTPUT ${cpp_filename}
DEPENDS ${cython_filename}
VERBATIM
# TODO: Is setting the input and output paths this way a robust solution,
# or are there cases where it might be problematic?
COMMAND "${CYTHON}" ${target_language} ${language_level} ${_RAPIDS_COMPILE_CYTHON_ARGS} "${CMAKE_CURRENT_SOURCE_DIR}/${cython_filename}" --output-file
"${CMAKE_CURRENT_BINARY_DIR}/${cpp_filename}")
add_custom_command(OUTPUT ${cpp_filename}
DEPENDS ${cython_filename}
VERBATIM
COMMENT "Transpiling ${CMAKE_CURRENT_SOURCE_DIR}/${cython_filename} to ${CMAKE_CURRENT_SOURCE_DIR}/${cpp_filename}"
# TODO: Is setting the input and output paths this way a robust solution, or
# are there cases where it might be problematic?
COMMAND "${CYTHON}" ${target_language} ${language_level}
${_RAPIDS_COMPILE_CYTHON_ARGS}
"${CMAKE_CURRENT_SOURCE_DIR}/${cython_filename}" --output-file
"${CMAKE_CURRENT_BINARY_DIR}/${cpp_filename}")

list(APPEND CREATED_FILES "${CMAKE_CURRENT_BINARY_DIR}/${cpp_filename}")
endforeach()
Expand Down
2 changes: 1 addition & 1 deletion rapids-cmake/cython-core/detail/verify_init.cmake
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# =============================================================================
# Copyright (c) 2022, NVIDIA CORPORATION.
# Copyright (c) 2022-2023, NVIDIA CORPORATION.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
# in compliance with the License. You may obtain a copy of the License at
Expand Down
5 changes: 1 addition & 4 deletions rapids-cmake/cython-core/init.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,7 @@ macro(rapids_cython_init)
message(TRACE "Accessing SKBUILD variable ${SKBUILD}")
endif()

find_package(
Python
COMPONENTS Interpreter Development.Module
REQUIRED)
find_package(Python COMPONENTS Interpreter Development.Module REQUIRED)

find_program(CYTHON "cython")

Expand Down
2 changes: 1 addition & 1 deletion rapids-cmake/rapids-cython-core.cmake
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#=============================================================================
# Copyright (c) 2022, NVIDIA CORPORATION.
# Copyright (c) 2022-2023, NVIDIA CORPORATION.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down

0 comments on commit 6ecb9b0

Please sign in to comment.