Skip to content

Commit

Permalink
Modernize Python build (#257)
Browse files Browse the repository at this point in the history
Switch to using rapids-cmake's rapids-cython modules for the Python build. It also uses rapids-cuda to support NATIVE or RAPIDS as the list of CUDA architectures.

Resolves #186

Authors:
  - Vyas Ramasubramani (https://github.com/vyasr)

Approvers:
  - Bradley Dice (https://github.com/bdice)

URL: #257
  • Loading branch information
vyasr authored Jul 28, 2023
1 parent e51ab88 commit 8789aba
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 71 deletions.
18 changes: 8 additions & 10 deletions python/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,9 @@ cmake_minimum_required(VERSION 3.26.4 FATAL_ERROR)

set(kvikio_version 23.10.00)

set(CYTHON_FLAGS
"--directive binding=True,embedsignature=True,always_allow_keywords=True"
CACHE STRING "The directives for Cython compilation."
)
include(../cpp/cmake/fetch_rapids.cmake)
include(rapids-cuda)
rapids_cuda_init_architectures(kvikio-python)

project(
kvikio-python
Expand All @@ -35,15 +34,9 @@ option(FIND_KVIKIO_CPP
"Search for existing KVIKIO C++ installations before defaulting to local files" OFF
)

find_package(PythonExtensions REQUIRED)
find_package(Cython REQUIRED)

# TODO: Should we symlink FindcuFile.cmake into python/cmake? find cuFile
include(../cpp/cmake/Modules/FindcuFile.cmake)

# Ignore unused variable warning.
set(ignored_variable "${SKBUILD}")

if(FIND_KVIKIO_CPP)
find_package(KvikIO ${kvikio_version})
else()
Expand All @@ -54,7 +47,12 @@ find_package(CUDAToolkit REQUIRED)

if(NOT KVIKIO_FOUND)
add_subdirectory(../cpp kvikio-cpp)
set(cython_lib_dir kvikio)
install(TARGETS kvikio DESTINATION ${cython_lib_dir})
endif()

include(rapids-cython)
rapids_cython_init()

add_subdirectory(cmake)
add_subdirectory(kvikio/_lib)
3 changes: 1 addition & 2 deletions python/cmake/CMakeLists.txt
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 All @@ -13,4 +13,3 @@
# =============================================================================

include(thirdparty/get_nvcomp.cmake)
include(kvikio_python_helpers.cmake)
53 changes: 0 additions & 53 deletions python/cmake/kvikio_python_helpers.cmake

This file was deleted.

12 changes: 6 additions & 6 deletions python/kvikio/_lib/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@
# =============================================================================

# Set the list of Cython files to build
set(cython_modules arr libnvcomp libnvcomp_ll libkvikio)
set(cython_modules arr.pyx libnvcomp.pyx libnvcomp_ll.pyx libkvikio.pyx)

# Build all of the Cython targets
add_cython_modules("${cython_modules}")

target_link_libraries(libnvcomp nvcomp::nvcomp)
target_link_libraries(libnvcomp_ll nvcomp::nvcomp)
rapids_cython_create_modules(
CXX
SOURCE_FILES "${cython_modules}"
LINKED_LIBRARIES nvcomp::nvcomp
)

0 comments on commit 8789aba

Please sign in to comment.