forked from NVIDIA/cuda-python
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcanary_probe_subprocess.py
More file actions
30 lines (23 loc) · 994 Bytes
/
canary_probe_subprocess.py
File metadata and controls
30 lines (23 loc) · 994 Bytes
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
#!/usr/bin/env python
# SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
# SPDX-License-Identifier: Apache-2.0
import json
from cuda.pathfinder._dynamic_libs.load_dl_common import DynamicLibNotFoundError, LoadedDL
from cuda.pathfinder._utils.platform_aware import IS_WINDOWS
if IS_WINDOWS:
from cuda.pathfinder._dynamic_libs.load_dl_windows import load_with_system_search
else:
from cuda.pathfinder._dynamic_libs.load_dl_linux import load_with_system_search
def _probe_canary_abs_path(libname: str) -> str | None:
try:
loaded: LoadedDL | None = load_with_system_search(libname)
except DynamicLibNotFoundError:
return None
if loaded is None:
return None
abs_path = loaded.abs_path
if not isinstance(abs_path, str):
return None
return abs_path
def probe_canary_abs_path_and_print_json(libname: str) -> None:
print(json.dumps(_probe_canary_abs_path(libname))) # noqa: T201