-
Notifications
You must be signed in to change notification settings - Fork 293
Expand file tree
/
Copy pathload_dl_common.py
More file actions
36 lines (26 loc) · 1.09 KB
/
load_dl_common.py
File metadata and controls
36 lines (26 loc) · 1.09 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
# SPDX-License-Identifier: LicenseRef-NVIDIA-SOFTWARE-LICENSE
from dataclasses import dataclass
from typing import Callable, Optional
from cuda.bindings._path_finder.supported_libs import DIRECT_DEPENDENCIES, IS_WINDOWS
if IS_WINDOWS:
import pywintypes
HandleType = pywintypes.HANDLE
else:
HandleType = int
@dataclass
class LoadedDL:
handle: HandleType
abs_path: Optional[str]
was_already_loaded_from_elsewhere: bool
def load_dependencies(libname: str, load_func: Callable[[str], LoadedDL]) -> None:
"""Load all dependencies for a given library.
Args:
libname: The name of the library whose dependencies should be loaded
load_func: The function to use for loading libraries (e.g. load_nvidia_dynamic_library)
Example:
>>> load_dependencies("cudart", load_nvidia_dynamic_library)
# This will load all dependencies of cudart using the provided loading function
"""
for dep in DIRECT_DEPENDENCIES.get(libname, ()):
load_func(dep)