Coverage for cuda/pathfinder/_dynamic_libs/supported_nvidia_libs.py: 96.43%

56 statements  

« prev     ^ index     » next       coverage.py v7.16.0, created at 2026-09-03 02:41 +0000

1# SPDX-FileCopyrightText: Copyright (c) 2025-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. 

2# SPDX-License-Identifier: Apache-2.0 

3 

4"""Legacy table exports derived from the authored descriptor catalog. 

5 

6The canonical data entry point is :mod:`descriptor_catalog`. This module keeps 

7historical constant names for backward compatibility by deriving them from the 

8catalog. 

9 

10The unsuffixed ``SUPPORTED_LIBNAMES_WINDOWS`` and 

11``SITE_PACKAGES_LIBDIRS_WINDOWS*`` constants retain their historical x64 

12meaning for compatibility, but are not recommended for new code. Use the 

13explicit ``*_X64`` or ``*_ARM64`` projection instead. Never combine the two 

14architecture projections. 

15""" 

16 

17from __future__ import annotations 

18 

19from cuda.pathfinder._dynamic_libs.descriptor_catalog import DESCRIPTOR_CATALOG 

20from cuda.pathfinder._utils.platform_aware import IS_WINDOWS, IS_WINDOWS_ARM64, IS_WINDOWS_X64 

21 

22_CTK_DESCRIPTORS = tuple(desc for desc in DESCRIPTOR_CATALOG if desc.packaged_with == "ctk") 

23_OTHER_DESCRIPTORS = tuple(desc for desc in DESCRIPTOR_CATALOG if desc.packaged_with == "other") 

24_DRIVER_DESCRIPTORS = tuple(desc for desc in DESCRIPTOR_CATALOG if desc.packaged_with == "driver") 

25_NON_CTK_DESCRIPTORS = _OTHER_DESCRIPTORS + _DRIVER_DESCRIPTORS 

26 

27 

28def _legacy_least_preferred_first(names: tuple[str, ...]) -> tuple[str, ...]: 

29 """Preserve the historical ordering of legacy filename projections.""" 

30 return tuple(reversed(names)) 

31 

32 

33SUPPORTED_LIBNAMES_COMMON = tuple(desc.name for desc in _CTK_DESCRIPTORS if desc.linux_sonames and desc.windows_dlls) 

34SUPPORTED_LIBNAMES_LINUX_ONLY = tuple( 

35 desc.name for desc in _CTK_DESCRIPTORS if desc.linux_sonames and not desc.windows_dlls 

36) 

37SUPPORTED_LIBNAMES_WINDOWS_ONLY = tuple( 

38 desc.name for desc in _CTK_DESCRIPTORS if desc.windows_dlls and not desc.linux_sonames 

39) 

40 

41if not IS_WINDOWS: 

42 ALL_AVAILABLE_LIBNAMES = frozenset(desc.name for desc in DESCRIPTOR_CATALOG if desc.linux_sonames) 

43else: 

44 assert IS_WINDOWS_X64 != IS_WINDOWS_ARM64 

45 _current_windows_arch = "x64" if IS_WINDOWS_X64 else "arm64" 

46 ALL_AVAILABLE_LIBNAMES = frozenset( 

47 desc.name for desc in DESCRIPTOR_CATALOG if _current_windows_arch in desc.supported_windows_arch 

48 ) 

49 

50SUPPORTED_LIBNAMES_LINUX = SUPPORTED_LIBNAMES_COMMON + SUPPORTED_LIBNAMES_LINUX_ONLY 

51SUPPORTED_LIBNAMES_WINDOWS_X64 = tuple(desc.name for desc in _CTK_DESCRIPTORS if "x64" in desc.supported_windows_arch) 

52SUPPORTED_LIBNAMES_WINDOWS_ARM64 = tuple( 

53 desc.name for desc in _CTK_DESCRIPTORS if "arm64" in desc.supported_windows_arch 

54) 

55# Backward-compatible alias preserves the historical x64 meaning. 

56SUPPORTED_LIBNAMES_WINDOWS = SUPPORTED_LIBNAMES_WINDOWS_X64 

57SUPPORTED_LIBNAMES_ALL = SUPPORTED_LIBNAMES_COMMON + SUPPORTED_LIBNAMES_LINUX_ONLY + SUPPORTED_LIBNAMES_WINDOWS_ONLY 

58if not IS_WINDOWS: 

59 SUPPORTED_LIBNAMES = SUPPORTED_LIBNAMES_LINUX 

60elif IS_WINDOWS_X64: 

61 SUPPORTED_LIBNAMES = SUPPORTED_LIBNAMES_WINDOWS_X64 

62else: 

63 assert IS_WINDOWS_ARM64 

64 SUPPORTED_LIBNAMES = SUPPORTED_LIBNAMES_WINDOWS_ARM64 

65 

66DIRECT_DEPENDENCIES_CTK = {desc.name: desc.dependencies for desc in _CTK_DESCRIPTORS if desc.dependencies} 

67DIRECT_DEPENDENCIES = {desc.name: desc.dependencies for desc in DESCRIPTOR_CATALOG if desc.dependencies} 

68 

69SUPPORTED_LINUX_SONAMES_CTK = { 

70 desc.name: _legacy_least_preferred_first(desc.linux_sonames) for desc in _CTK_DESCRIPTORS if desc.linux_sonames 

71} 

72SUPPORTED_LINUX_SONAMES_OTHER = { 

73 desc.name: _legacy_least_preferred_first(desc.linux_sonames) for desc in _OTHER_DESCRIPTORS if desc.linux_sonames 

74} 

75SUPPORTED_LINUX_SONAMES_DRIVER = { 

76 desc.name: _legacy_least_preferred_first(desc.linux_sonames) for desc in _DRIVER_DESCRIPTORS if desc.linux_sonames 

77} 

78SUPPORTED_LINUX_SONAMES = SUPPORTED_LINUX_SONAMES_CTK | SUPPORTED_LINUX_SONAMES_OTHER | SUPPORTED_LINUX_SONAMES_DRIVER 

79 

80SUPPORTED_WINDOWS_DLLS_CTK = { 

81 desc.name: _legacy_least_preferred_first(desc.windows_dlls) for desc in _CTK_DESCRIPTORS if desc.windows_dlls 

82} 

83SUPPORTED_WINDOWS_DLLS_OTHER = { 

84 desc.name: _legacy_least_preferred_first(desc.windows_dlls) for desc in _OTHER_DESCRIPTORS if desc.windows_dlls 

85} 

86SUPPORTED_WINDOWS_DLLS_DRIVER = { 

87 desc.name: _legacy_least_preferred_first(desc.windows_dlls) for desc in _DRIVER_DESCRIPTORS if desc.windows_dlls 

88} 

89SUPPORTED_WINDOWS_DLLS = SUPPORTED_WINDOWS_DLLS_CTK | SUPPORTED_WINDOWS_DLLS_OTHER | SUPPORTED_WINDOWS_DLLS_DRIVER 

90 

91LIBNAMES_REQUIRING_OS_ADD_DLL_DIRECTORY = tuple( 

92 desc.name for desc in DESCRIPTOR_CATALOG if desc.requires_add_dll_directory and desc.windows_dlls 

93) 

94LIBNAMES_REQUIRING_RTLD_DEEPBIND = tuple( 

95 desc.name for desc in DESCRIPTOR_CATALOG if desc.requires_rtld_deepbind and desc.linux_sonames 

96) 

97 

98SITE_PACKAGES_LIBDIRS_LINUX_CTK = { 

99 desc.name: desc.site_packages_linux for desc in _CTK_DESCRIPTORS if desc.site_packages_linux 

100} 

101SITE_PACKAGES_LIBDIRS_LINUX_OTHER = { 

102 desc.name: desc.site_packages_linux for desc in _NON_CTK_DESCRIPTORS if desc.site_packages_linux 

103} 

104SITE_PACKAGES_LIBDIRS_LINUX = SITE_PACKAGES_LIBDIRS_LINUX_CTK | SITE_PACKAGES_LIBDIRS_LINUX_OTHER 

105 

106# Architecture-specific Windows projections. Keep these separate: combining 

107# them would make the table unsafe to consume for either process ABI. 

108SITE_PACKAGES_LIBDIRS_WINDOWS_CTK_X64 = { 

109 desc.name: desc.site_packages_windows.x64 for desc in _CTK_DESCRIPTORS if desc.site_packages_windows.x64 

110} 

111SITE_PACKAGES_LIBDIRS_WINDOWS_CTK_ARM64 = { 

112 desc.name: desc.site_packages_windows.arm64 for desc in _CTK_DESCRIPTORS if desc.site_packages_windows.arm64 

113} 

114SITE_PACKAGES_LIBDIRS_WINDOWS_OTHER_X64 = { 

115 desc.name: desc.site_packages_windows.x64 for desc in _NON_CTK_DESCRIPTORS if desc.site_packages_windows.x64 

116} 

117SITE_PACKAGES_LIBDIRS_WINDOWS_OTHER_ARM64 = { 

118 desc.name: desc.site_packages_windows.arm64 for desc in _NON_CTK_DESCRIPTORS if desc.site_packages_windows.arm64 

119} 

120SITE_PACKAGES_LIBDIRS_WINDOWS_X64 = SITE_PACKAGES_LIBDIRS_WINDOWS_CTK_X64 | SITE_PACKAGES_LIBDIRS_WINDOWS_OTHER_X64 

121SITE_PACKAGES_LIBDIRS_WINDOWS_ARM64 = ( 

122 SITE_PACKAGES_LIBDIRS_WINDOWS_CTK_ARM64 | SITE_PACKAGES_LIBDIRS_WINDOWS_OTHER_ARM64 

123) 

124 

125# Backward-compatible aliases preserve the historical x64 meaning. 

126SITE_PACKAGES_LIBDIRS_WINDOWS_CTK = SITE_PACKAGES_LIBDIRS_WINDOWS_CTK_X64 

127SITE_PACKAGES_LIBDIRS_WINDOWS_OTHER = SITE_PACKAGES_LIBDIRS_WINDOWS_OTHER_X64 

128SITE_PACKAGES_LIBDIRS_WINDOWS = SITE_PACKAGES_LIBDIRS_WINDOWS_X64 

129 

130 

131def is_suppressed_dll_file(path_basename: str) -> bool: 

132 if path_basename.startswith("nvrtc"): 1abcdefghijklmnopqrstuv

133 # nvidia_cuda_nvrtc_cu12-12.8.93-py3-none-win_amd64.whl: 

134 # nvidia\cuda_nvrtc\bin\ 

135 # nvrtc-builtins64_128.dll 

136 # nvrtc64_120_0.alt.dll 

137 # nvrtc64_120_0.dll 

138 return path_basename.endswith(".alt.dll") or "-builtins" in path_basename 

139 return path_basename.startswith(("cudart32_", "nvvm32")) 1abcdefghijklmnopqrstuv