From c486aeab551e81851d233548fb158ad63af64f98 Mon Sep 17 00:00:00 2001 From: Ashwin Srinath Date: Thu, 19 Dec 2024 20:17:58 -0500 Subject: [PATCH] Fixes for Python 3.7 docs environment --- docs/cuda_parallel/index.rst | 6 ++++++ .../cuda/parallel/experimental/_bindings.py | 12 ++++++++++-- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/docs/cuda_parallel/index.rst b/docs/cuda_parallel/index.rst index 18f4a139626..e494fb1e323 100644 --- a/docs/cuda_parallel/index.rst +++ b/docs/cuda_parallel/index.rst @@ -7,11 +7,17 @@ CUDA Parallel Python exposure of parallel algorithms is in public beta. The API is subject to change without notice. +Algorithms +---------- + .. automodule:: cuda.parallel.experimental.algorithms :members: :undoc-members: :imported-members: +Iterators +--------- + .. automodule:: cuda.parallel.experimental.iterators :members: :undoc-members: diff --git a/python/cuda_parallel/cuda/parallel/experimental/_bindings.py b/python/cuda_parallel/cuda/parallel/experimental/_bindings.py index a4ad84a2b42..64adea39a2b 100644 --- a/python/cuda_parallel/cuda/parallel/experimental/_bindings.py +++ b/python/cuda_parallel/cuda/parallel/experimental/_bindings.py @@ -5,7 +5,6 @@ import os import shutil -from importlib.resources import files, as_file import ctypes from functools import lru_cache from typing import List, Optional @@ -31,6 +30,10 @@ def _get_cuda_path() -> Optional[str]: @lru_cache() def get_bindings() -> ctypes.CDLL: + # TODO: once docs env supports Python >= 3.9, we + # can move this to a module-level import. + from importlib.resources import as_file, files + with as_file(files("cuda.parallel.experimental")) as f: cccl_c_path = str(f / "cccl" / "libcccl.c.parallel.so") _bindings = ctypes.CDLL(cccl_c_path) @@ -52,13 +55,18 @@ def get_bindings() -> ctypes.CDLL: @lru_cache() def get_paths() -> List[bytes]: + # TODO: once docs env supports Python >= 3.9, we + # can move this to a module-level import. + from importlib.resources import as_file, files + with as_file(files("cuda.parallel")) as f: # Using `.parent` for compatibility with pip install --editable: cub_include_path = str(f.parent / "_include") thrust_include_path = cub_include_path libcudacxx_include_path = str(os.path.join(cub_include_path, "libcudacxx")) cuda_include_path = None - if cuda_path := _get_cuda_path(): + cuda_path = _get_cuda_path() + if cuda_path is not None: cuda_include_path = str(os.path.join(cuda_path, "include")) paths = [ f"-I{path}".encode()