Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Transition build system of cuda_cccl and cuda_parallel to scikit-build-core #3597

Merged
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Rewrite of cuda_cccl build system
Transition from using setuptools to using scikit-build-core, so
that CMakeLists.txt is used to ensure that include is the same
as in the cuda toolkit.

Added test folder to test that the package works correctly.
oleksandr-pavlyk committed Jan 29, 2025
commit f3fbf3a6b1ad034aefc6847151880fde5525ad8e
4 changes: 4 additions & 0 deletions python/new_cuda_cccl/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
build
dist
*egg-info
*~
31 changes: 31 additions & 0 deletions python/new_cuda_cccl/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
cmake_minimum_required(VERSION 3.21...3.31 FATAL_ERROR)

# include_guard(GLOBAL)

project(
CCCL_HEADERS
VERSION ${SKBUILD_PROJECT_VERSION}
LANGUAGES C CXX
DESCRIPTION "Headers of NVIDIA CUDA Core Compute Libraries"
)

add_subdirectory(../.. _parent_cccl)

find_package(CUB REQUIRED)
find_package(Thrust REQUIRED)
find_package(libcudacxx REQUIRED)

set(_dest_incl_dir cuda/cccl/include)

install(
DIRECTORY ${CUB_SOURCE_DIR}/cub
DESTINATION ${_dest_incl_dir}
)
install(
DIRECTORY ${Thrust_SOURCE_DIR}/thrust
DESTINATION ${_dest_incl_dir}
)
install(
DIRECTORY ${libcudacxx_SOURCE_DIR}/include
DESTINATION ${_dest_incl_dir}
)
1 change: 1 addition & 0 deletions python/new_cuda_cccl/LICENSE
3 changes: 3 additions & 0 deletions python/new_cuda_cccl/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
## Note

This package is currently FOR INTERNAL USE ONLY and not meant to be used/installed explicitly.
Empty file.
8 changes: 8 additions & 0 deletions python/new_cuda_cccl/cuda/cccl/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Copyright (c) 2025, NVIDIA CORPORATION & AFFILIATES. ALL RIGHTS RESERVED.
#
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception

from cuda.cccl._version import __version__
from cuda.cccl.include_paths import get_include_paths

__all__ = ["__version__", "get_include_paths"]
7 changes: 7 additions & 0 deletions python/new_cuda_cccl/cuda/cccl/_version.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Copyright (c) 2025, NVIDIA CORPORATION & AFFILIATES. ALL RIGHTS RESERVED.
#
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception

# This file is generated by ci/update_version.sh
# Do not edit this file manually.
__version__ = "2.8.0"
1 change: 1 addition & 0 deletions python/new_cuda_cccl/cuda/cccl/include/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# Intentionally empty
63 changes: 63 additions & 0 deletions python/new_cuda_cccl/cuda/cccl/include_paths.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
# Copyright (c) 2025, NVIDIA CORPORATION & AFFILIATES. ALL RIGHTS RESERVED.
#
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception

import os
import shutil
from dataclasses import dataclass
from functools import lru_cache
from pathlib import Path
from typing import Optional


def _get_cuda_path() -> Optional[Path]:
cuda_path = os.environ.get("CUDA_PATH")
if cuda_path:
cuda_path = Path(cuda_path)
if cuda_path.exists():
return cuda_path

nvcc_path = shutil.which("nvcc")
if nvcc_path:
return Path(nvcc_path).parent.parent

default_path = Path("/usr/local/cuda")
if default_path.exists():
return default_path

return None


@dataclass
class IncludePaths:
cuda: Optional[Path]
libcudacxx: Optional[Path]
cub: Optional[Path]
thrust: Optional[Path]

def as_tuple(self):
# Note: higher-level ... lower-level order:
return (self.thrust, self.cub, self.libcudacxx, self.cuda)


@lru_cache()
def get_include_paths() -> IncludePaths:
# TODO: once docs env supports Python >= 3.9, we
# can move this to a module-level import.
from importlib.resources import as_file, files

cuda_incl = None
cuda_path = _get_cuda_path()
if cuda_path is not None:
cuda_incl = cuda_path / "include"

with as_file(files("cuda.cccl.include")) as f:
cccl_incl = Path(f)
assert cccl_incl.exists()

return IncludePaths(
cuda=cuda_incl,
libcudacxx=cccl_incl,
cub=cccl_incl,
thrust=cccl_incl,
)
46 changes: 46 additions & 0 deletions python/new_cuda_cccl/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# Copyright (c) 2025, NVIDIA CORPORATION & AFFILIATES. ALL RIGHTS RESERVED.
#
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception

[build-system]
requires = ["scikit-build-core>=0.10", "setuptools"]
build-backend = "scikit_build_core.build"

[project]
name = "cuda-cccl"
description = "Experimental Package with CCCL headers to support JIT compilation"
authors = [{ name = "NVIDIA Corporation" }]
classifiers = [
"Programming Language :: Python :: 3 :: Only",
"Environment :: GPU :: NVIDIA CUDA",
"License :: OSI Approved :: Apache Software License",
]
license-files = ["LICENSE"]
requires-python = ">=3.9"
version = "3.0.0"
# dynamic = ["version", "readme"]

[project.urls]
Homepage = "https://github.com/NVIDIA/cccl"

[tool.scikit-build]
minimum-version = "build-system.requires"
build-dir = "build/{wheel_tag}"

[tool.scikit-build.cmake]
version = ">=3.21"
args = []
build-type = "Release"
source-dir = "."

[tool.scikit-build.ninja]
version = ">=1.11"
make-fallback = true

[tool.scikit-build.wheel]
py-api = "py3"
platlib = ""

[tool.scikit-build.wheel.packages]
"cuda" = "cuda"
"cuda/cccl" = "cuda/cccl"
21 changes: 21 additions & 0 deletions python/new_cuda_cccl/test/test_cuda_cccl.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import cuda.cccl as c4l


def test_headers():
inc_paths = c4l.get_include_paths()
assert hasattr(inc_paths, "cuda")
assert hasattr(inc_paths, "cub")
assert hasattr(inc_paths, "libcudacxx")
assert hasattr(inc_paths, "thrust")
tpl = inc_paths.as_tuple()
assert len(tpl) == 4
thrust_, cub_, cudacxx_, cuda_ = tpl
assert cuda_ == inc_paths.cuda
assert cub_ == inc_paths.cub
assert cudacxx_ == inc_paths.libcudacxx
assert thrust_ == inc_paths.thrust


def test_version():
v = c4l.__version__
assert isinstance(v, str)