Skip to content

Commit 9eb4a8f

Browse files
committed
Fix _tensor_bridge exclusion for versioned subpackages
In CI, _tensor_bridge lives under a versioned subpackage (cuda.core.cu12._tensor_bridge), but the exclusion set only matched the unversioned name. Switch to suffix matching so that all versioned variants are excluded.
1 parent 6b3a3cb commit 9eb4a8f

1 file changed

Lines changed: 9 additions & 2 deletions

File tree

cuda_core/tests/test_cython_property_descriptors.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,11 @@
1818
pytestmark = pytest.mark.no_cuda
1919

2020

21-
_NOT_ALLOWED_TO_IMPORT = {"cuda.core._tensor_bridge"}
21+
# Suffixes of module names that must not be imported (e.g. _tensor_bridge
22+
# depends on PyTorch symbols that are unavailable in most test environments).
23+
# Matched against the end of each discovered module name so that versioned
24+
# subpackages like cuda.core.cu12._tensor_bridge are also excluded.
25+
_NOT_ALLOWED_TO_IMPORT_SUFFIXES = {"._tensor_bridge"}
2226

2327
_GETSET_FIELD_ALLOWLIST = {
2428
("cuda.core._kernel_arg_handler", "ParamHolder", "ptr"),
@@ -41,7 +45,10 @@ def _iter_cuda_core_modules():
4145
for info in pkgutil.walk_packages(root.__path__, root.__name__ + "."):
4246
module_names.add(info.name)
4347

44-
module_names -= _NOT_ALLOWED_TO_IMPORT
48+
module_names = {
49+
n for n in module_names
50+
if not any(n.endswith(s) for s in _NOT_ALLOWED_TO_IMPORT_SUFFIXES)
51+
}
4552
for module_name in sorted(module_names):
4653
yield importlib.import_module(module_name)
4754

0 commit comments

Comments
 (0)