Skip to content

Commit a48565f

Browse files
rwgkcursoragent
andcommitted
Share managed-memory test helper
Move the managed-memory skip logic into cuda_python_test_helpers and point bindings/core tests at the shared module, with path bootstrapping to prefer in-repo helpers. This avoids relying on bindings test helpers that are absent in 12.9.x wheels. Co-authored-by: Cursor <cursoragent@cursor.com>
1 parent 85f76f5 commit a48565f

5 files changed

Lines changed: 19 additions & 11 deletions

File tree

cuda_bindings/tests/conftest.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,14 @@
11
# SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
22
# SPDX-License-Identifier: LicenseRef-NVIDIA-SOFTWARE-LICENSE
33

4+
import pathlib
5+
import sys
6+
7+
helpers_root = pathlib.Path(__file__).resolve().parents[2] / "cuda_python_test_helpers"
8+
if helpers_root.is_dir() and str(helpers_root) not in sys.path:
9+
# Prefer the in-repo helpers over any installed copy.
10+
sys.path.insert(0, str(helpers_root))
11+
412
import cuda.bindings.driver as cuda
513
import pytest
614

cuda_bindings/tests/test_cuda.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
import numpy as np
1111
import pytest
1212
from cuda.bindings import driver
13-
from cuda.bindings._test_helpers.managed_memory import managed_memory_skip_reason
13+
from cuda_python_test_helpers.managed_memory import managed_memory_skip_reason
1414

1515

1616
def driverVersionLessThan(target):

cuda_core/tests/conftest.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
import helpers
88
import pytest
9-
from cuda.bindings._test_helpers.managed_memory import managed_memory_skip_reason
9+
from cuda_python_test_helpers.managed_memory import managed_memory_skip_reason
1010

1111
try:
1212
from cuda.bindings import driver

cuda_core/tests/helpers/__init__.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,12 @@
2222
CCCL_INCLUDE_PATHS = (path,) + CCCL_INCLUDE_PATHS
2323

2424

25-
try:
26-
from cuda_python_test_helpers import * # noqa: F403
27-
except ImportError:
28-
# Import shared platform helpers for tests across repos
29-
sys.path.insert(0, str(pathlib.Path(__file__).resolve().parents[3] / "cuda_python_test_helpers"))
30-
from cuda_python_test_helpers import * # noqa: F403
25+
helpers_root = pathlib.Path(__file__).resolve().parents[3] / "cuda_python_test_helpers"
26+
if helpers_root.is_dir() and str(helpers_root) not in sys.path:
27+
# Prefer the in-repo helpers over any installed copy.
28+
sys.path.insert(0, str(helpers_root))
29+
30+
from cuda_python_test_helpers import * # noqa: E402, F403
3131

3232

3333
@functools.cache

cuda_bindings/cuda/bindings/_test_helpers/managed_memory.py renamed to cuda_python_test_helpers/cuda_python_test_helpers/managed_memory.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
2-
# SPDX-License-Identifier: LicenseRef-NVIDIA-SOFTWARE-LICENSE
2+
# SPDX-License-Identifier: Apache-2.0
33

44
from __future__ import annotations
55

@@ -8,9 +8,9 @@
88
import pytest
99

1010
try:
11-
from cuda.bindings import driver
11+
from cuda.bindings import driver # type: ignore
1212
except Exception:
13-
from cuda import cuda as driver
13+
from cuda import cuda as driver # type: ignore
1414

1515

1616
def _resolve_device_id(device) -> int:

0 commit comments

Comments
 (0)