diff --git a/ci/release/update-version.sh b/ci/release/update-version.sh index fcc52922f..01450d8bf 100755 --- a/ci/release/update-version.sh +++ b/ci/release/update-version.sh @@ -32,6 +32,7 @@ function sed_runner() { sed_runner 's/'" VERSION .*"'/'" VERSION ${NEXT_FULL_TAG}"'/g' CMakeLists.txt sed_runner 's/'"rmm_version .*)"'/'"rmm_version ${NEXT_FULL_TAG})"'/g' python/CMakeLists.txt sed_runner 's/'"branch-.*\/RAPIDS.cmake"'/'"branch-${NEXT_SHORT_TAG}\/RAPIDS.cmake"'/g' CMakeLists.txt +sed_runner 's/'"branch-.*\/RAPIDS.cmake"'/'"branch-${NEXT_SHORT_TAG}\/RAPIDS.cmake"'/g' python/CMakeLists.txt sed_runner 's/'"PROJECT_NUMBER = .*"'/'"PROJECT_NUMBER = ${NEXT_SHORT_TAG}"'/g' doxygen/Doxyfile diff --git a/python/CMakeLists.txt b/python/CMakeLists.txt index cb12813f9..8caafd917 100644 --- a/python/CMakeLists.txt +++ b/python/CMakeLists.txt @@ -16,9 +16,9 @@ cmake_minimum_required(VERSION 3.20.1 FATAL_ERROR) set(rmm_version 22.06.00) -set(CYTHON_FLAGS - "--directive binding=True,embedsignature=True,always_allow_keywords=True" - CACHE STRING "The directives for Cython compilation.") +file(DOWNLOAD https://raw.githubusercontent.com/rapidsai/rapids-cmake/branch-22.06/RAPIDS.cmake + ${CMAKE_BINARY_DIR}/RAPIDS.cmake) +include(${CMAKE_BINARY_DIR}/RAPIDS.cmake) project( rmm-python @@ -27,38 +27,29 @@ project( # language to be enabled here. The test project that is built in scikit-build to verify # various linking options for the python library is hardcoded to build with C, so until # that is fixed we need to keep C. - C - CXX - # TODO: The C++ RMM CMake configuration targets cuda_std_17 features, which prior to - # CMake 3.22 will also pull in the corresponding required languages even if this project - # does not actually require those languages. As a result, we need to include CUDA here. - # We can remove CUDA once we upgrade the minimum required CMake version to 3.22. - CUDA) + C CXX) option(FIND_RMM_CPP "Search for existing RMM C++ installations before defaulting to local files" OFF) -find_package(PythonExtensions REQUIRED) -find_package(Cython REQUIRED) - -# Ignore unused variable warning. -set(ignored_variable "${SKBUILD}") - -# If the user requested it we attempt to find RMM. TODO: Should we allow the user to specify a path -# instead of just searching? This version assumes that the installation has been appropriately -# configured for CMake discovery. +# If the user requested it we attempt to find RMM. if(FIND_RMM_CPP) - find_package(RMM ${rmm_version}) + find_package(rmm ${rmm_version}) else() - set(RMM_FOUND OFF) + set(rmm_FOUND OFF) endif() -if(NOT RMM_FOUND) +if(NOT rmm_FOUND) + # TODO: This will not be necessary once we upgrade to CMake 3.22, which will pull in the required + # languages for the C++ project even if this project does not require those languges. + enable_language(CUDA) set(BUILD_TESTS OFF) set(BUILD_BENCHMARKS OFF) add_subdirectory(../ rmm-cpp) endif() -add_subdirectory(cmake) +include(rapids-cython) +rapids_cython_init() + add_subdirectory(rmm/_cuda) add_subdirectory(rmm/_lib) diff --git a/python/cmake/CMakeLists.txt b/python/cmake/CMakeLists.txt deleted file mode 100644 index 9469891ae..000000000 --- a/python/cmake/CMakeLists.txt +++ /dev/null @@ -1,16 +0,0 @@ -# ============================================================================= -# Copyright (c) 2022, 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 -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software distributed under the License -# is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express -# or implied. See the License for the specific language governing permissions and limitations under -# the License. -# ============================================================================= - -include(rmm_python_helpers.cmake) -include(skbuild_patches.cmake) diff --git a/python/cmake/rmm_python_helpers.cmake b/python/cmake/rmm_python_helpers.cmake deleted file mode 100644 index 91f0a5a17..000000000 --- a/python/cmake/rmm_python_helpers.cmake +++ /dev/null @@ -1,48 +0,0 @@ -# ============================================================================= -# Copyright (c) 2022, 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 -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software distributed under the License -# is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express -# or implied. See the License for the specific language governing permissions and limitations under -# the License. -# ============================================================================= - -#[=======================================================================[.rst: -add_cython_modules ------------------- - -Generate C(++) from Cython and create Python modules. - -.. code-block:: cmake - - add_cython_modules() - -Creates a Cython target for a module, then adds a corresponding Python -extension module. - -``ModuleName`` - The list of modules to build. - -#]=======================================================================] -function(add_cython_modules cython_modules) - foreach(cython_module ${cython_modules}) - add_cython_target(${cython_module} CXX PY3) - add_library(${cython_module} MODULE ${cython_module}) - python_extension_module(${cython_module}) - - # To avoid libraries being prefixed with "lib". - set_target_properties(${cython_module} PROPERTIES PREFIX "") - target_link_libraries(${cython_module} rmm::rmm) - - # Compute the install directory relative to the source and rely on installs being relative to - # the CMAKE_PREFIX_PATH for e.g. editable installs. - cmake_path(RELATIVE_PATH CMAKE_CURRENT_SOURCE_DIR BASE_DIRECTORY ${rmm-python_SOURCE_DIR} - OUTPUT_VARIABLE install_dst) - install(TARGETS ${cython_module} DESTINATION ${install_dst}) - endforeach(cython_module ${cython_sources}) -endfunction() diff --git a/python/cmake/skbuild_patches.cmake b/python/cmake/skbuild_patches.cmake deleted file mode 100644 index 6302e9e2f..000000000 --- a/python/cmake/skbuild_patches.cmake +++ /dev/null @@ -1,48 +0,0 @@ -# ============================================================================= -# Copyright (c) 2022, 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 -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software distributed under the License -# is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express -# or implied. See the License for the specific language governing permissions and limitations under -# the License. -# ============================================================================= - -#[=======================================================================[.rst: -_set_python_extension_symbol_visibility ---------------------------------------- - -The original version of this function in scikit-build runs a linker script to -modify the visibility of symbols. This version is a patch to avoid overwriting -the visibility of symbols because RMM specifically overrides some symbol -visibility in order to share certain functional-local static variables. - -#]=======================================================================] -# TODO: Should we guard this based on a scikit-build version? Override this function to avoid -# scikit-build clobbering symbol visibility. -function(_set_python_extension_symbol_visibility _target) - if(PYTHON_VERSION_MAJOR VERSION_GREATER 2) - set(_modinit_prefix "PyInit_") - else() - set(_modinit_prefix "init") - endif() - message("_modinit_prefix:${_modinit_prefix}") - if("${CMAKE_C_COMPILER_ID}" STREQUAL "MSVC") - set_target_properties(${_target} PROPERTIES LINK_FLAGS "/EXPORT:${_modinit_prefix}${_target}") - elseif("${CMAKE_C_COMPILER_ID}" STREQUAL "GNU" AND NOT ${CMAKE_SYSTEM_NAME} MATCHES "Darwin") - set(_script_path ${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/${_target}-version-script.map) - file( - WRITE ${_script_path} - # Note: The change is to this script, which does not indiscriminately mark all non PyInit - # symbols as local. - "{global: ${_modinit_prefix}${_target}; };") - set_property( - TARGET ${_target} - APPEND_STRING - PROPERTY LINK_FLAGS " -Wl,--version-script=\"${_script_path}\"") - endif() -endfunction() diff --git a/python/rmm/_cuda/CMakeLists.txt b/python/rmm/_cuda/CMakeLists.txt index 16489dde5..1f17b0d2c 100644 --- a/python/rmm/_cuda/CMakeLists.txt +++ b/python/rmm/_cuda/CMakeLists.txt @@ -12,8 +12,8 @@ # the License. # ============================================================================= -# Set the list of Cython files to build -set(cython_modules stream) +set(cython_sources stream.pyx) +set(linked_libraries rmm::rmm) -# Build all of the Cython targets -add_cython_modules("${cython_modules}") +rapids_cython_create_modules(SOURCE_FILES "${cython_sources}" LINKED_LIBRARIES "${linked_libraries}" + CXX) diff --git a/python/rmm/_lib/CMakeLists.txt b/python/rmm/_lib/CMakeLists.txt index 954af9331..44f4513b2 100644 --- a/python/rmm/_lib/CMakeLists.txt +++ b/python/rmm/_lib/CMakeLists.txt @@ -12,8 +12,9 @@ # the License. # ============================================================================= -# Set the list of Cython files to build -set(cython_modules device_buffer lib memory_resource cuda_stream) +set(cython_sources device_buffer.pyx lib.pyx memory_resource.pyx cuda_stream.pyx) +set(linked_libraries rmm::rmm) # Build all of the Cython targets -add_cython_modules("${cython_modules}") +rapids_cython_create_modules(SOURCE_FILES "${cython_sources}" LINKED_LIBRARIES "${linked_libraries}" + CXX) diff --git a/python/setup.py b/python/setup.py index 106a22f90..7cbc92638 100644 --- a/python/setup.py +++ b/python/setup.py @@ -34,6 +34,6 @@ ) }, cmdclass=versioneer.get_cmdclass(), - install_requires=["numba", "cython", "cuda-python"], + install_requires=["numba", "cuda-python"], zip_safe=False, )