Use cuda-pathfinder instead of cuda-bindings for Pathfinder

Removed use of __all__ per PR feedback. Emit warnings.warn if
version information could not be retrieved from the package metadata,
e.g., package has been renamed by source code was not updated.
This commit is contained in:
Oleksandr Pavlyk
2025-07-22 16:33:48 -05:00
parent 51fa07fab8
commit 361c0337be
2 changed files with 28 additions and 19 deletions

View File

@@ -1,31 +1,40 @@
import importlib.metadata
import warnings
from cuda.bindings.path_finder import ( # type: ignore[import-not-found]
_load_nvidia_dynamic_library,
from cuda.pathfinder import ( # type: ignore[import-not-found]
load_nvidia_dynamic_lib,
)
try:
__version__ = importlib.metadata.version("pynvbench")
except Exception:
except Exception as e:
__version__ = "0.0.0dev"
warnings.warn(
"Could not retrieve version of pynvbench package dynamically from its metadata. "
f"Exception {e} was raised. "
f"Version is set to fall-back value '{__version__}' instead."
)
for libname in ("cupti", "nvperf_target", "nvperf_host"):
_load_nvidia_dynamic_library(libname)
load_nvidia_dynamic_lib(libname)
from ._nvbench import ( # noqa: E402
Benchmark,
CudaStream,
Launch,
State,
register,
run_all_benchmarks,
Benchmark as Benchmark,
)
from ._nvbench import ( # noqa: E402
CudaStream as CudaStream,
)
from ._nvbench import ( # noqa: E402
Launch as Launch,
)
from ._nvbench import ( # noqa: E402
State as State,
)
from ._nvbench import ( # noqa: E402
register as register,
)
from ._nvbench import ( # noqa: E402
run_all_benchmarks as run_all_benchmarks,
)
__all__ = [
"register",
"run_all_benchmarks",
"CudaStream",
"Launch",
"State",
"Benchmark",
]
del load_nvidia_dynamic_lib

View File

@@ -14,7 +14,7 @@ classifiers = [
requires-python = ">=3.9"
dependencies = [
# pathfinder
"cuda-bindings",
"cuda-pathfinder",
# Library expects to find shared libraries
# libcupti, libnvperf_target, libnvperf_host