|
10 | 10 |
|
11 | 11 | from __future__ import annotations |
12 | 12 |
|
13 | | -from cuda.pathfinder._dynamic_libs.descriptor_catalog import DESCRIPTOR_CATALOG |
| 13 | +from cuda.pathfinder._dynamic_libs.descriptor_catalog import DESCRIPTOR_CATALOG, is_supported_on_current_machine |
| 14 | +from cuda.pathfinder._dynamic_libs.lib_descriptor import LibDescriptor |
14 | 15 | from cuda.pathfinder._utils.platform_aware import IS_WINDOWS |
15 | 16 |
|
16 | 17 | _CTK_DESCRIPTORS = tuple(desc for desc in DESCRIPTOR_CATALOG if desc.packaged_with == "ctk") |
17 | 18 | _OTHER_DESCRIPTORS = tuple(desc for desc in DESCRIPTOR_CATALOG if desc.packaged_with == "other") |
18 | 19 | _DRIVER_DESCRIPTORS = tuple(desc for desc in DESCRIPTOR_CATALOG if desc.packaged_with == "driver") |
19 | 20 | _NON_CTK_DESCRIPTORS = _OTHER_DESCRIPTORS + _DRIVER_DESCRIPTORS |
20 | 21 |
|
21 | | -SUPPORTED_LIBNAMES_COMMON = tuple(desc.name for desc in _CTK_DESCRIPTORS if desc.linux_sonames and desc.windows_dlls) |
| 22 | + |
| 23 | +def _has_supported_linux_sonames(desc: LibDescriptor) -> bool: |
| 24 | + return bool(desc.linux_sonames) and is_supported_on_current_machine(desc) |
| 25 | + |
| 26 | + |
| 27 | +def _has_supported_windows_dlls(desc: LibDescriptor) -> bool: |
| 28 | + return bool(desc.windows_dlls) and is_supported_on_current_machine(desc) |
| 29 | + |
| 30 | + |
| 31 | +SUPPORTED_LIBNAMES_COMMON = tuple( |
| 32 | + desc.name for desc in _CTK_DESCRIPTORS if _has_supported_linux_sonames(desc) and _has_supported_windows_dlls(desc) |
| 33 | +) |
22 | 34 | SUPPORTED_LIBNAMES_LINUX_ONLY = tuple( |
23 | | - desc.name for desc in _CTK_DESCRIPTORS if desc.linux_sonames and not desc.windows_dlls |
| 35 | + desc.name |
| 36 | + for desc in _CTK_DESCRIPTORS |
| 37 | + if _has_supported_linux_sonames(desc) and not _has_supported_windows_dlls(desc) |
24 | 38 | ) |
25 | 39 | SUPPORTED_LIBNAMES_WINDOWS_ONLY = tuple( |
26 | | - desc.name for desc in _CTK_DESCRIPTORS if desc.windows_dlls and not desc.linux_sonames |
| 40 | + desc.name |
| 41 | + for desc in _CTK_DESCRIPTORS |
| 42 | + if _has_supported_windows_dlls(desc) and not _has_supported_linux_sonames(desc) |
27 | 43 | ) |
28 | 44 |
|
29 | 45 | SUPPORTED_LIBNAMES_LINUX = SUPPORTED_LIBNAMES_COMMON + SUPPORTED_LIBNAMES_LINUX_ONLY |
|
34 | 50 | DIRECT_DEPENDENCIES_CTK = {desc.name: desc.dependencies for desc in _CTK_DESCRIPTORS if desc.dependencies} |
35 | 51 | DIRECT_DEPENDENCIES = {desc.name: desc.dependencies for desc in DESCRIPTOR_CATALOG if desc.dependencies} |
36 | 52 |
|
37 | | -SUPPORTED_LINUX_SONAMES_CTK = {desc.name: desc.linux_sonames for desc in _CTK_DESCRIPTORS if desc.linux_sonames} |
38 | | -SUPPORTED_LINUX_SONAMES_OTHER = {desc.name: desc.linux_sonames for desc in _OTHER_DESCRIPTORS if desc.linux_sonames} |
39 | | -SUPPORTED_LINUX_SONAMES_DRIVER = {desc.name: desc.linux_sonames for desc in _DRIVER_DESCRIPTORS if desc.linux_sonames} |
| 53 | +SUPPORTED_LINUX_SONAMES_CTK = { |
| 54 | + desc.name: desc.linux_sonames for desc in _CTK_DESCRIPTORS if _has_supported_linux_sonames(desc) |
| 55 | +} |
| 56 | +SUPPORTED_LINUX_SONAMES_OTHER = { |
| 57 | + desc.name: desc.linux_sonames for desc in _OTHER_DESCRIPTORS if _has_supported_linux_sonames(desc) |
| 58 | +} |
| 59 | +SUPPORTED_LINUX_SONAMES_DRIVER = { |
| 60 | + desc.name: desc.linux_sonames for desc in _DRIVER_DESCRIPTORS if _has_supported_linux_sonames(desc) |
| 61 | +} |
40 | 62 | SUPPORTED_LINUX_SONAMES = SUPPORTED_LINUX_SONAMES_CTK | SUPPORTED_LINUX_SONAMES_OTHER | SUPPORTED_LINUX_SONAMES_DRIVER |
41 | 63 |
|
42 | | -SUPPORTED_WINDOWS_DLLS_CTK = {desc.name: desc.windows_dlls for desc in _CTK_DESCRIPTORS if desc.windows_dlls} |
43 | | -SUPPORTED_WINDOWS_DLLS_OTHER = {desc.name: desc.windows_dlls for desc in _OTHER_DESCRIPTORS if desc.windows_dlls} |
44 | | -SUPPORTED_WINDOWS_DLLS_DRIVER = {desc.name: desc.windows_dlls for desc in _DRIVER_DESCRIPTORS if desc.windows_dlls} |
| 64 | +SUPPORTED_WINDOWS_DLLS_CTK = { |
| 65 | + desc.name: desc.windows_dlls for desc in _CTK_DESCRIPTORS if _has_supported_windows_dlls(desc) |
| 66 | +} |
| 67 | +SUPPORTED_WINDOWS_DLLS_OTHER = { |
| 68 | + desc.name: desc.windows_dlls for desc in _OTHER_DESCRIPTORS if _has_supported_windows_dlls(desc) |
| 69 | +} |
| 70 | +SUPPORTED_WINDOWS_DLLS_DRIVER = { |
| 71 | + desc.name: desc.windows_dlls for desc in _DRIVER_DESCRIPTORS if _has_supported_windows_dlls(desc) |
| 72 | +} |
45 | 73 | SUPPORTED_WINDOWS_DLLS = SUPPORTED_WINDOWS_DLLS_CTK | SUPPORTED_WINDOWS_DLLS_OTHER | SUPPORTED_WINDOWS_DLLS_DRIVER |
46 | 74 |
|
47 | 75 | LIBNAMES_REQUIRING_OS_ADD_DLL_DIRECTORY = tuple( |
48 | | - desc.name for desc in DESCRIPTOR_CATALOG if desc.requires_add_dll_directory and desc.windows_dlls |
| 76 | + desc.name for desc in DESCRIPTOR_CATALOG if desc.requires_add_dll_directory and _has_supported_windows_dlls(desc) |
49 | 77 | ) |
50 | 78 | LIBNAMES_REQUIRING_RTLD_DEEPBIND = tuple( |
51 | | - desc.name for desc in DESCRIPTOR_CATALOG if desc.requires_rtld_deepbind and desc.linux_sonames |
| 79 | + desc.name for desc in DESCRIPTOR_CATALOG if desc.requires_rtld_deepbind and _has_supported_linux_sonames(desc) |
52 | 80 | ) |
53 | 81 |
|
54 | 82 | # Based on output of toolshed/make_site_packages_libdirs_linux.py |
55 | 83 | SITE_PACKAGES_LIBDIRS_LINUX_CTK = { |
56 | | - desc.name: desc.site_packages_linux for desc in _CTK_DESCRIPTORS if desc.site_packages_linux |
| 84 | + desc.name: desc.site_packages_linux |
| 85 | + for desc in _CTK_DESCRIPTORS |
| 86 | + if desc.site_packages_linux and _has_supported_linux_sonames(desc) |
57 | 87 | } |
58 | 88 | SITE_PACKAGES_LIBDIRS_LINUX_OTHER = { |
59 | | - desc.name: desc.site_packages_linux for desc in _NON_CTK_DESCRIPTORS if desc.site_packages_linux |
| 89 | + desc.name: desc.site_packages_linux |
| 90 | + for desc in _NON_CTK_DESCRIPTORS |
| 91 | + if desc.site_packages_linux and _has_supported_linux_sonames(desc) |
60 | 92 | } |
61 | 93 | SITE_PACKAGES_LIBDIRS_LINUX = SITE_PACKAGES_LIBDIRS_LINUX_CTK | SITE_PACKAGES_LIBDIRS_LINUX_OTHER |
62 | 94 |
|
63 | 95 | SITE_PACKAGES_LIBDIRS_WINDOWS_CTK = { |
64 | | - desc.name: desc.site_packages_windows for desc in _CTK_DESCRIPTORS if desc.site_packages_windows |
| 96 | + desc.name: desc.site_packages_windows |
| 97 | + for desc in _CTK_DESCRIPTORS |
| 98 | + if desc.site_packages_windows and _has_supported_windows_dlls(desc) |
65 | 99 | } |
66 | 100 | SITE_PACKAGES_LIBDIRS_WINDOWS_OTHER = { |
67 | | - desc.name: desc.site_packages_windows for desc in _NON_CTK_DESCRIPTORS if desc.site_packages_windows |
| 101 | + desc.name: desc.site_packages_windows |
| 102 | + for desc in _NON_CTK_DESCRIPTORS |
| 103 | + if desc.site_packages_windows and _has_supported_windows_dlls(desc) |
68 | 104 | } |
69 | 105 | SITE_PACKAGES_LIBDIRS_WINDOWS = SITE_PACKAGES_LIBDIRS_WINDOWS_CTK | SITE_PACKAGES_LIBDIRS_WINDOWS_OTHER |
70 | 106 |
|
|
0 commit comments