arraybridge 0.3.2__tar.gz → 0.3.3__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {arraybridge-0.3.2 → arraybridge-0.3.3}/.github/workflows/publish.yml +1 -1
- {arraybridge-0.3.2 → arraybridge-0.3.3}/PKG-INFO +1 -1
- {arraybridge-0.3.2 → arraybridge-0.3.3}/docs/source/conf.py +3 -1
- {arraybridge-0.3.2 → arraybridge-0.3.3}/docs/source/gpu_features.rst +5 -0
- {arraybridge-0.3.2 → arraybridge-0.3.3}/pyproject.toml +4 -1
- arraybridge-0.3.3/scripts/update_version.py +60 -0
- {arraybridge-0.3.2 → arraybridge-0.3.3}/scripts/verify_release_ready.py +2 -17
- {arraybridge-0.3.2 → arraybridge-0.3.3}/src/arraybridge/__init__.py +1 -1
- {arraybridge-0.3.2 → arraybridge-0.3.3}/src/arraybridge/types.py +66 -0
- {arraybridge-0.3.2 → arraybridge-0.3.3}/tests/test_types.py +52 -0
- arraybridge-0.3.2/scripts/update_version.py +0 -79
- {arraybridge-0.3.2 → arraybridge-0.3.3}/.github/workflows/ci.yml +0 -0
- {arraybridge-0.3.2 → arraybridge-0.3.3}/.github/workflows/coverage-pages.yml +0 -0
- {arraybridge-0.3.2 → arraybridge-0.3.3}/.github/workflows/gpu-tests.yml +0 -0
- {arraybridge-0.3.2 → arraybridge-0.3.3}/.gitignore +0 -0
- {arraybridge-0.3.2 → arraybridge-0.3.3}/.readthedocs.yml +0 -0
- {arraybridge-0.3.2 → arraybridge-0.3.3}/ADDING_NEW_FRAMEWORKS.md +0 -0
- {arraybridge-0.3.2 → arraybridge-0.3.3}/CONTRIBUTING.md +0 -0
- {arraybridge-0.3.2 → arraybridge-0.3.3}/LICENSE +0 -0
- {arraybridge-0.3.2 → arraybridge-0.3.3}/README.md +0 -0
- {arraybridge-0.3.2 → arraybridge-0.3.3}/TESTING.md +0 -0
- {arraybridge-0.3.2 → arraybridge-0.3.3}/docs/Makefile +0 -0
- {arraybridge-0.3.2 → arraybridge-0.3.3}/docs/archive/CI_ARTIFACT_UPDATE.md +0 -0
- {arraybridge-0.3.2 → arraybridge-0.3.3}/docs/archive/CI_CUPY_FIX.md +0 -0
- {arraybridge-0.3.2 → arraybridge-0.3.3}/docs/archive/CI_IMPROVEMENTS.md +0 -0
- {arraybridge-0.3.2 → arraybridge-0.3.3}/docs/archive/CONFLICT_VISUALIZATION.md +0 -0
- {arraybridge-0.3.2 → arraybridge-0.3.3}/docs/archive/COVERAGE_AUDIT_PLAN.md +0 -0
- {arraybridge-0.3.2 → arraybridge-0.3.3}/docs/archive/DEPLOYMENT_SUMMARY.md +0 -0
- {arraybridge-0.3.2 → arraybridge-0.3.3}/docs/archive/GPU_TESTING_SETUP.md +0 -0
- {arraybridge-0.3.2 → arraybridge-0.3.3}/docs/archive/MERGE_CONFLICT_RESOLUTION.md +0 -0
- {arraybridge-0.3.2 → arraybridge-0.3.3}/docs/archive/MIGRATION_SUMMARY.md +0 -0
- {arraybridge-0.3.2 → arraybridge-0.3.3}/docs/archive/QUICK_FIX_GUIDE.txt +0 -0
- {arraybridge-0.3.2 → arraybridge-0.3.3}/docs/archive/README.md +0 -0
- {arraybridge-0.3.2 → arraybridge-0.3.3}/docs/archive/RESOLVED_FILES.md +0 -0
- {arraybridge-0.3.2 → arraybridge-0.3.3}/docs/ci-cd.md +0 -0
- {arraybridge-0.3.2 → arraybridge-0.3.3}/docs/source/.gitignore +0 -0
- {arraybridge-0.3.2 → arraybridge-0.3.3}/docs/source/Makefile +0 -0
- {arraybridge-0.3.2 → arraybridge-0.3.3}/docs/source/README.md +0 -0
- {arraybridge-0.3.2 → arraybridge-0.3.3}/docs/source/advanced_topics.rst +0 -0
- {arraybridge-0.3.2 → arraybridge-0.3.3}/docs/source/api_reference.rst +0 -0
- {arraybridge-0.3.2 → arraybridge-0.3.3}/docs/source/ci-cd.rst +0 -0
- {arraybridge-0.3.2 → arraybridge-0.3.3}/docs/source/contributing.rst +0 -0
- {arraybridge-0.3.2 → arraybridge-0.3.3}/docs/source/converters.rst +0 -0
- {arraybridge-0.3.2 → arraybridge-0.3.3}/docs/source/decorators.rst +0 -0
- {arraybridge-0.3.2 → arraybridge-0.3.3}/docs/source/examples/basic_conversion.rst +0 -0
- {arraybridge-0.3.2 → arraybridge-0.3.3}/docs/source/examples/decorators.rst +0 -0
- {arraybridge-0.3.2 → arraybridge-0.3.3}/docs/source/examples/index.rst +0 -0
- {arraybridge-0.3.2 → arraybridge-0.3.3}/docs/source/examples/multi_framework.rst +0 -0
- {arraybridge-0.3.2 → arraybridge-0.3.3}/docs/source/index.rst +0 -0
- {arraybridge-0.3.2 → arraybridge-0.3.3}/docs/source/installation.rst +0 -0
- {arraybridge-0.3.2 → arraybridge-0.3.3}/docs/source/quickstart.rst +0 -0
- {arraybridge-0.3.2 → arraybridge-0.3.3}/docs/source/stack_utils.rst +0 -0
- {arraybridge-0.3.2 → arraybridge-0.3.3}/docs/source/user_guide.rst +0 -0
- {arraybridge-0.3.2 → arraybridge-0.3.3}/paper.bib +0 -0
- {arraybridge-0.3.2 → arraybridge-0.3.3}/paper.md +0 -0
- {arraybridge-0.3.2 → arraybridge-0.3.3}/scripts/release.py +0 -0
- {arraybridge-0.3.2 → arraybridge-0.3.3}/src/arraybridge/array_geometry.py +0 -0
- {arraybridge-0.3.2 → arraybridge-0.3.3}/src/arraybridge/array_operations.py +0 -0
- {arraybridge-0.3.2 → arraybridge-0.3.3}/src/arraybridge/array_payload.py +0 -0
- {arraybridge-0.3.2 → arraybridge-0.3.3}/src/arraybridge/converters.py +0 -0
- {arraybridge-0.3.2 → arraybridge-0.3.3}/src/arraybridge/converters_registry.py +0 -0
- {arraybridge-0.3.2 → arraybridge-0.3.3}/src/arraybridge/decorators.py +0 -0
- {arraybridge-0.3.2 → arraybridge-0.3.3}/src/arraybridge/dtype_scaling.py +0 -0
- {arraybridge-0.3.2 → arraybridge-0.3.3}/src/arraybridge/exceptions.py +0 -0
- {arraybridge-0.3.2 → arraybridge-0.3.3}/src/arraybridge/framework_config.py +0 -0
- {arraybridge-0.3.2 → arraybridge-0.3.3}/src/arraybridge/framework_ops.py +0 -0
- {arraybridge-0.3.2 → arraybridge-0.3.3}/src/arraybridge/gpu_cleanup.py +0 -0
- {arraybridge-0.3.2 → arraybridge-0.3.3}/src/arraybridge/oom_recovery.py +0 -0
- {arraybridge-0.3.2 → arraybridge-0.3.3}/src/arraybridge/slice_processing.py +0 -0
- {arraybridge-0.3.2 → arraybridge-0.3.3}/src/arraybridge/stack_utils.py +0 -0
- {arraybridge-0.3.2 → arraybridge-0.3.3}/src/arraybridge/utils.py +0 -0
- {arraybridge-0.3.2 → arraybridge-0.3.3}/tests/__init__.py +0 -0
- {arraybridge-0.3.2 → arraybridge-0.3.3}/tests/conftest.py +0 -0
- {arraybridge-0.3.2 → arraybridge-0.3.3}/tests/test_array_geometry.py +0 -0
- {arraybridge-0.3.2 → arraybridge-0.3.3}/tests/test_converters.py +0 -0
- {arraybridge-0.3.2 → arraybridge-0.3.3}/tests/test_converters_registry.py +0 -0
- {arraybridge-0.3.2 → arraybridge-0.3.3}/tests/test_decorators.py +0 -0
- {arraybridge-0.3.2 → arraybridge-0.3.3}/tests/test_dtype_scaling.py +0 -0
- {arraybridge-0.3.2 → arraybridge-0.3.3}/tests/test_exceptions.py +0 -0
- {arraybridge-0.3.2 → arraybridge-0.3.3}/tests/test_framework_config.py +0 -0
- {arraybridge-0.3.2 → arraybridge-0.3.3}/tests/test_gpu_cleanup.py +0 -0
- {arraybridge-0.3.2 → arraybridge-0.3.3}/tests/test_integration.py +0 -0
- {arraybridge-0.3.2 → arraybridge-0.3.3}/tests/test_oom_recovery.py +0 -0
- {arraybridge-0.3.2 → arraybridge-0.3.3}/tests/test_registry_integration.py +0 -0
- {arraybridge-0.3.2 → arraybridge-0.3.3}/tests/test_slice_processing.py +0 -0
- {arraybridge-0.3.2 → arraybridge-0.3.3}/tests/test_stack_utils.py +0 -0
- {arraybridge-0.3.2 → arraybridge-0.3.3}/tests/test_utils.py +0 -0
|
@@ -42,7 +42,7 @@ jobs:
|
|
|
42
42
|
|
|
43
43
|
- name: Verify release tag and main ancestry
|
|
44
44
|
run: |
|
|
45
|
-
declared_version=$(python -c 'import
|
|
45
|
+
declared_version=$(python -c 'import arraybridge; print(arraybridge.__version__)')
|
|
46
46
|
test "$GITHUB_REF_NAME" = "v$declared_version"
|
|
47
47
|
git fetch origin main
|
|
48
48
|
git merge-base --is-ancestor "$GITHUB_SHA" origin/main
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: arraybridge
|
|
3
|
-
Version: 0.3.
|
|
3
|
+
Version: 0.3.3
|
|
4
4
|
Summary: Unified API for NumPy, CuPy, PyTorch, TensorFlow, JAX, and pyclesperanto with automatic memory type conversion
|
|
5
5
|
Project-URL: Homepage, https://github.com/OpenHCSDev/arraybridge
|
|
6
6
|
Project-URL: Documentation, https://arraybridge.readthedocs.io
|
|
@@ -16,13 +16,15 @@ EXTERNAL_ROOT = PACKAGE_ROOT.parent
|
|
|
16
16
|
sys.path.insert(0, str(EXTERNAL_ROOT / "metaclass-registry" / "src"))
|
|
17
17
|
sys.path.insert(0, str(PACKAGE_ROOT / "src"))
|
|
18
18
|
|
|
19
|
+
from arraybridge import __version__
|
|
20
|
+
|
|
19
21
|
# -- Project information -----------------------------------------------------
|
|
20
22
|
# https://www.sphinx-doc.org/en/master/usage/configuration.html#project-information
|
|
21
23
|
|
|
22
24
|
project = 'arraybridge'
|
|
23
25
|
copyright = '2025, Tristan Simas'
|
|
24
26
|
author = 'Tristan Simas'
|
|
25
|
-
release =
|
|
27
|
+
release = __version__
|
|
26
28
|
|
|
27
29
|
# -- General configuration ---------------------------------------------------
|
|
28
30
|
# https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration
|
|
@@ -15,6 +15,11 @@ overwritten. Hosts that import optional frameworks themselves should call
|
|
|
15
15
|
``MemoryType.prepare_import()`` first. ArrayBridge warns when it encounters an
|
|
16
16
|
already-loaded framework whose import-time defaults were absent.
|
|
17
17
|
|
|
18
|
+
``MemoryType.subprocess_environment()`` projects the same member-owned import
|
|
19
|
+
defaults into a child-process environment. The CuPy member also derives native
|
|
20
|
+
library search paths from installed NVIDIA wheels, so a fresh child interpreter
|
|
21
|
+
does not depend on another framework having loaded CUDA libraries first.
|
|
22
|
+
|
|
18
23
|
JAX float64 output requires x64 mode to be enabled before import. ArrayBridge
|
|
19
24
|
raises instead of silently returning float32 when a caller requests float64
|
|
20
25
|
while that capability is disabled.
|
|
@@ -5,7 +5,7 @@ build-backend = "hatchling.build"
|
|
|
5
5
|
|
|
6
6
|
[project]
|
|
7
7
|
name = "arraybridge"
|
|
8
|
-
|
|
8
|
+
dynamic = ["version"]
|
|
9
9
|
description = "Unified API for NumPy, CuPy, PyTorch, TensorFlow, JAX, and pyclesperanto with automatic memory type conversion"
|
|
10
10
|
authors = [{name = "Tristan Simas", email = "tristan.simas@mail.mcgill.ca"}]
|
|
11
11
|
license = {text = "MIT"}
|
|
@@ -98,6 +98,9 @@ Issues = "https://github.com/OpenHCSDev/arraybridge/issues"
|
|
|
98
98
|
[tool.hatch.build.targets.wheel]
|
|
99
99
|
packages = ["src/arraybridge"]
|
|
100
100
|
|
|
101
|
+
[tool.hatch.version]
|
|
102
|
+
path = "src/arraybridge/__init__.py"
|
|
103
|
+
|
|
101
104
|
[tool.pytest.ini_options]
|
|
102
105
|
testpaths = ["tests"]
|
|
103
106
|
python_files = ["test_*.py"]
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
"""Update ArrayBridge's canonical package version without Git side effects."""
|
|
3
|
+
|
|
4
|
+
import argparse
|
|
5
|
+
import re
|
|
6
|
+
from pathlib import Path
|
|
7
|
+
|
|
8
|
+
from packaging.version import InvalidVersion, Version
|
|
9
|
+
|
|
10
|
+
PROJECT_ROOT = Path(__file__).resolve().parents[1]
|
|
11
|
+
VERSION_FILE = PROJECT_ROOT / "src/arraybridge/__init__.py"
|
|
12
|
+
VERSION_PATTERN = r"(__version__\s*=\s*['\"])([^'\"]+)(['\"])"
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
def current_version() -> Version:
|
|
16
|
+
"""Return the package-owned canonical version."""
|
|
17
|
+
|
|
18
|
+
match = re.search(
|
|
19
|
+
VERSION_PATTERN,
|
|
20
|
+
VERSION_FILE.read_text(encoding="utf-8"),
|
|
21
|
+
flags=re.MULTILINE,
|
|
22
|
+
)
|
|
23
|
+
if match is None:
|
|
24
|
+
raise RuntimeError(f"Version declaration is missing from {VERSION_FILE}")
|
|
25
|
+
return Version(match.group(2))
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
def update_version(version_text: str) -> None:
|
|
29
|
+
try:
|
|
30
|
+
requested = Version(version_text)
|
|
31
|
+
except InvalidVersion as error:
|
|
32
|
+
raise ValueError(f"Invalid version: {version_text}") from error
|
|
33
|
+
current = current_version()
|
|
34
|
+
if requested <= current:
|
|
35
|
+
raise ValueError(f"New version {requested} must be greater than {current}")
|
|
36
|
+
|
|
37
|
+
content = VERSION_FILE.read_text(encoding="utf-8")
|
|
38
|
+
updated, count = re.subn(
|
|
39
|
+
VERSION_PATTERN,
|
|
40
|
+
rf"\g<1>{requested}\g<3>",
|
|
41
|
+
content,
|
|
42
|
+
flags=re.MULTILINE,
|
|
43
|
+
)
|
|
44
|
+
if count != 1:
|
|
45
|
+
raise RuntimeError(f"Expected one version declaration in {VERSION_FILE}, found {count}")
|
|
46
|
+
VERSION_FILE.write_text(updated, encoding="utf-8")
|
|
47
|
+
|
|
48
|
+
print(f"Updated ArrayBridge version to {requested}")
|
|
49
|
+
print("Run scripts/verify_release_ready.py --allow-dirty, then review and commit.")
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
def main() -> None:
|
|
53
|
+
parser = argparse.ArgumentParser(description=__doc__)
|
|
54
|
+
parser.add_argument("version", help="New release version, for example 0.3.0")
|
|
55
|
+
args = parser.parse_args()
|
|
56
|
+
update_version(args.version)
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
if __name__ == "__main__":
|
|
60
|
+
main()
|
|
@@ -16,8 +16,6 @@ import sys
|
|
|
16
16
|
import tempfile
|
|
17
17
|
from pathlib import Path
|
|
18
18
|
|
|
19
|
-
import tomllib
|
|
20
|
-
|
|
21
19
|
PROJECT_ROOT = Path(__file__).resolve().parents[1]
|
|
22
20
|
|
|
23
21
|
|
|
@@ -41,20 +39,6 @@ def check_version():
|
|
|
41
39
|
print(f" ❌ Version '{version}' doesn't follow semantic versioning (MAJOR.MINOR.PATCH)")
|
|
42
40
|
return False
|
|
43
41
|
|
|
44
|
-
pyproject_version = tomllib.loads(
|
|
45
|
-
(PROJECT_ROOT / "pyproject.toml").read_text(encoding="utf-8")
|
|
46
|
-
)["project"]["version"]
|
|
47
|
-
docs_match = re.search(
|
|
48
|
-
r"release\s*=\s*['\"]([^'\"]+)",
|
|
49
|
-
(PROJECT_ROOT / "docs/source/conf.py").read_text(encoding="utf-8"),
|
|
50
|
-
)
|
|
51
|
-
docs_version = docs_match.group(1) if docs_match else None
|
|
52
|
-
if len({version, pyproject_version, docs_version}) != 1:
|
|
53
|
-
print(
|
|
54
|
-
" ❌ Version authorities disagree: "
|
|
55
|
-
f"package={version}, pyproject={pyproject_version}, docs={docs_version}"
|
|
56
|
-
)
|
|
57
|
-
return False
|
|
58
42
|
print(f" ✅ Version: {version}")
|
|
59
43
|
return True
|
|
60
44
|
|
|
@@ -70,7 +54,8 @@ def check_pyproject_toml():
|
|
|
70
54
|
content = pyproject_file.read_text(encoding="utf-8")
|
|
71
55
|
required_fields = {
|
|
72
56
|
"name": r'name\s*=\s*["\']arraybridge["\']',
|
|
73
|
-
"version": r"version\
|
|
57
|
+
"dynamic version": r'dynamic\s*=\s*\[["\']version["\']\]',
|
|
58
|
+
"version authority": r'path\s*=\s*["\']src/arraybridge/__init__\.py["\']',
|
|
74
59
|
"description": r"description\s*=",
|
|
75
60
|
"authors": r"authors\s*=",
|
|
76
61
|
"build-backend": r'build-backend\s*=\s*["\']hatchling\.build["\']',
|
|
@@ -5,7 +5,7 @@ This package provides automatic memory type conversion, declarative decorators,
|
|
|
5
5
|
and unified utilities for working with multiple array/tensor frameworks.
|
|
6
6
|
"""
|
|
7
7
|
|
|
8
|
-
__version__ = "0.3.
|
|
8
|
+
__version__ = "0.3.3"
|
|
9
9
|
|
|
10
10
|
from . import decorators as _decorators
|
|
11
11
|
from .array_geometry import ArrayGeometry
|
|
@@ -14,6 +14,7 @@ from collections.abc import Callable, Iterator, Mapping, MutableMapping
|
|
|
14
14
|
from contextlib import AbstractContextManager, contextmanager, nullcontext
|
|
15
15
|
from dataclasses import dataclass
|
|
16
16
|
from enum import Enum
|
|
17
|
+
from pathlib import Path
|
|
17
18
|
from typing import Any, TypeVar, cast
|
|
18
19
|
|
|
19
20
|
from arraybridge.array_operations import (
|
|
@@ -41,6 +42,55 @@ StreamScopeFactory = Callable[[Any, Any], AbstractContextManager[None]]
|
|
|
41
42
|
DLPackExporter = Callable[[Any, Any], Any | None]
|
|
42
43
|
DLPackValidator = Callable[[Any, Any], bool]
|
|
43
44
|
OOMMatcher = Callable[[BaseException, Any | None], bool]
|
|
45
|
+
SubprocessEnvironmentResolver = Callable[[Mapping[str, str]], dict[str, str]]
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
def _identity_subprocess_environment(
|
|
49
|
+
environment: Mapping[str, str],
|
|
50
|
+
) -> dict[str, str]:
|
|
51
|
+
return dict(environment)
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
def _nvidia_wheel_library_paths() -> tuple[str, ...]:
|
|
55
|
+
"""Return native-library directories declared by installed NVIDIA wheels."""
|
|
56
|
+
|
|
57
|
+
try:
|
|
58
|
+
spec = importlib.util.find_spec("nvidia")
|
|
59
|
+
except (ImportError, ModuleNotFoundError, ValueError):
|
|
60
|
+
return ()
|
|
61
|
+
if spec is None or spec.submodule_search_locations is None:
|
|
62
|
+
return ()
|
|
63
|
+
|
|
64
|
+
paths: set[str] = set()
|
|
65
|
+
for package_root in map(Path, spec.submodule_search_locations):
|
|
66
|
+
try:
|
|
67
|
+
components = tuple(package_root.iterdir())
|
|
68
|
+
except OSError:
|
|
69
|
+
continue
|
|
70
|
+
for component in components:
|
|
71
|
+
for library_directory_name in ("lib", "bin"):
|
|
72
|
+
candidate = component / library_directory_name
|
|
73
|
+
if candidate.is_dir():
|
|
74
|
+
paths.add(str(candidate))
|
|
75
|
+
return tuple(sorted(paths))
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
def _nvidia_wheel_subprocess_environment(
|
|
79
|
+
environment: Mapping[str, str],
|
|
80
|
+
) -> dict[str, str]:
|
|
81
|
+
"""Prepend installed NVIDIA wheel libraries to a child environment."""
|
|
82
|
+
|
|
83
|
+
prepared = dict(environment)
|
|
84
|
+
library_paths = _nvidia_wheel_library_paths()
|
|
85
|
+
if not library_paths:
|
|
86
|
+
return prepared
|
|
87
|
+
|
|
88
|
+
search_variable = "PATH" if os.name == "nt" else "LD_LIBRARY_PATH"
|
|
89
|
+
existing_paths = tuple(
|
|
90
|
+
path for path in prepared.get(search_variable, "").split(os.pathsep) if path
|
|
91
|
+
)
|
|
92
|
+
prepared[search_variable] = os.pathsep.join(dict.fromkeys((*library_paths, *existing_paths)))
|
|
93
|
+
return prepared
|
|
44
94
|
|
|
45
95
|
|
|
46
96
|
class MemoryContractAttribute(str, Enum):
|
|
@@ -501,6 +551,7 @@ class FrameworkRuntime:
|
|
|
501
551
|
dlpack_exporter: DLPackExporter | None = None
|
|
502
552
|
dlpack_validator: DLPackValidator = _protocol_dlpack
|
|
503
553
|
oom_matcher: OOMMatcher = _never_oom
|
|
554
|
+
subprocess_environment: SubprocessEnvironmentResolver = _identity_subprocess_environment
|
|
504
555
|
|
|
505
556
|
|
|
506
557
|
class _MemoryTypeFields:
|
|
@@ -571,6 +622,7 @@ class MemoryType(_MemoryTypeFields, Enum):
|
|
|
571
622
|
dlpack_importer=_cupy_from_dlpack,
|
|
572
623
|
dlpack_exporter=_protocol_dlpack_export,
|
|
573
624
|
oom_matcher=_cupy_oom,
|
|
625
|
+
subprocess_environment=_nvidia_wheel_subprocess_environment,
|
|
574
626
|
),
|
|
575
627
|
CUPY_OPERATIONS,
|
|
576
628
|
)
|
|
@@ -682,6 +734,20 @@ class MemoryType(_MemoryTypeFields, Enum):
|
|
|
682
734
|
for name, value in self.import_environment:
|
|
683
735
|
os.environ.setdefault(name, value)
|
|
684
736
|
|
|
737
|
+
@classmethod
|
|
738
|
+
def subprocess_environment(
|
|
739
|
+
cls,
|
|
740
|
+
environment: Mapping[str, str] | None = None,
|
|
741
|
+
) -> dict[str, str]:
|
|
742
|
+
"""Project framework import requirements into a child environment."""
|
|
743
|
+
|
|
744
|
+
prepared = dict(os.environ if environment is None else environment)
|
|
745
|
+
for memory_type in cls:
|
|
746
|
+
for name, value in memory_type.import_environment:
|
|
747
|
+
prepared.setdefault(name, value)
|
|
748
|
+
prepared = memory_type._runtime.subprocess_environment(prepared)
|
|
749
|
+
return prepared
|
|
750
|
+
|
|
685
751
|
def loaded_module(self) -> Any | None:
|
|
686
752
|
"""Return an already-loaded framework without causing an import."""
|
|
687
753
|
|
|
@@ -145,6 +145,58 @@ class TestMemoryTypeOwnership:
|
|
|
145
145
|
assert os.environ["TF_FORCE_GPU_ALLOW_GROWTH"] == "true"
|
|
146
146
|
assert os.environ["XLA_PYTHON_CLIENT_PREALLOCATE"] == "custom"
|
|
147
147
|
|
|
148
|
+
def test_subprocess_environment_derives_nvidia_wheel_paths_from_cupy_owner(
|
|
149
|
+
self,
|
|
150
|
+
monkeypatch,
|
|
151
|
+
tmp_path,
|
|
152
|
+
):
|
|
153
|
+
from arraybridge import types
|
|
154
|
+
|
|
155
|
+
nvidia_root = tmp_path / "nvidia"
|
|
156
|
+
cublas_lib = nvidia_root / "cublas" / "lib"
|
|
157
|
+
runtime_bin = nvidia_root / "cuda_runtime" / "bin"
|
|
158
|
+
cublas_lib.mkdir(parents=True)
|
|
159
|
+
runtime_bin.mkdir(parents=True)
|
|
160
|
+
monkeypatch.setattr(
|
|
161
|
+
types.importlib.util,
|
|
162
|
+
"find_spec",
|
|
163
|
+
lambda name: (
|
|
164
|
+
SimpleNamespace(submodule_search_locations=(str(nvidia_root),))
|
|
165
|
+
if name == "nvidia"
|
|
166
|
+
else None
|
|
167
|
+
),
|
|
168
|
+
)
|
|
169
|
+
search_variable = "PATH" if os.name == "nt" else "LD_LIBRARY_PATH"
|
|
170
|
+
original = {search_variable: "/existing", "CUSTOM": "value"}
|
|
171
|
+
|
|
172
|
+
prepared = MemoryType.subprocess_environment(original)
|
|
173
|
+
|
|
174
|
+
assert original == {search_variable: "/existing", "CUSTOM": "value"}
|
|
175
|
+
assert prepared[search_variable].split(os.pathsep) == [
|
|
176
|
+
*sorted((str(cublas_lib), str(runtime_bin))),
|
|
177
|
+
"/existing",
|
|
178
|
+
]
|
|
179
|
+
assert prepared["CUSTOM"] == "value"
|
|
180
|
+
assert prepared["TF_FORCE_GPU_ALLOW_GROWTH"] == "true"
|
|
181
|
+
assert prepared["XLA_PYTHON_CLIENT_PREALLOCATE"] == "false"
|
|
182
|
+
|
|
183
|
+
def test_subprocess_environment_preserves_host_values_without_nvidia_wheels(
|
|
184
|
+
self,
|
|
185
|
+
monkeypatch,
|
|
186
|
+
):
|
|
187
|
+
from arraybridge import types
|
|
188
|
+
|
|
189
|
+
monkeypatch.setattr(types.importlib.util, "find_spec", lambda name: None)
|
|
190
|
+
original = {
|
|
191
|
+
"TF_FORCE_GPU_ALLOW_GROWTH": "host",
|
|
192
|
+
"XLA_PYTHON_CLIENT_PREALLOCATE": "host",
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
prepared = MemoryType.subprocess_environment(original)
|
|
196
|
+
|
|
197
|
+
assert prepared == original
|
|
198
|
+
assert prepared is not original
|
|
199
|
+
|
|
148
200
|
def test_preloaded_framework_reports_late_import_preparation(
|
|
149
201
|
self,
|
|
150
202
|
monkeypatch,
|
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env python3
|
|
2
|
-
"""Update ArrayBridge's three version projections without Git side effects."""
|
|
3
|
-
|
|
4
|
-
import argparse
|
|
5
|
-
import re
|
|
6
|
-
from pathlib import Path
|
|
7
|
-
|
|
8
|
-
from packaging.version import InvalidVersion, Version
|
|
9
|
-
|
|
10
|
-
PROJECT_ROOT = Path(__file__).resolve().parents[1]
|
|
11
|
-
VERSION_FILES = {
|
|
12
|
-
PROJECT_ROOT
|
|
13
|
-
/ "src/arraybridge/__init__.py": (
|
|
14
|
-
r"(__version__\s*=\s*['\"])([^'\"]+)(['\"])",
|
|
15
|
-
"package",
|
|
16
|
-
),
|
|
17
|
-
PROJECT_ROOT
|
|
18
|
-
/ "pyproject.toml": (
|
|
19
|
-
r"(^version\s*=\s*['\"])([^'\"]+)(['\"])",
|
|
20
|
-
"project",
|
|
21
|
-
),
|
|
22
|
-
PROJECT_ROOT
|
|
23
|
-
/ "docs/source/conf.py": (
|
|
24
|
-
r"(^release\s*=\s*['\"])([^'\"]+)(['\"])",
|
|
25
|
-
"documentation",
|
|
26
|
-
),
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
def current_version() -> Version:
|
|
31
|
-
"""Return the agreed version, failing when a projection has drifted."""
|
|
32
|
-
declared_versions: dict[str, Version] = {}
|
|
33
|
-
for path, (pattern, projection_name) in VERSION_FILES.items():
|
|
34
|
-
match = re.search(pattern, path.read_text(encoding="utf-8"), flags=re.MULTILINE)
|
|
35
|
-
if match is None:
|
|
36
|
-
raise RuntimeError(f"Version declaration is missing from {path}")
|
|
37
|
-
declared_versions[projection_name] = Version(match.group(2))
|
|
38
|
-
|
|
39
|
-
unique_versions = set(declared_versions.values())
|
|
40
|
-
if len(unique_versions) != 1:
|
|
41
|
-
declarations = ", ".join(f"{name}={version}" for name, version in declared_versions.items())
|
|
42
|
-
raise RuntimeError(f"Version projections have drifted: {declarations}")
|
|
43
|
-
return unique_versions.pop()
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
def update_version(version_text: str) -> None:
|
|
47
|
-
try:
|
|
48
|
-
requested = Version(version_text)
|
|
49
|
-
except InvalidVersion as error:
|
|
50
|
-
raise ValueError(f"Invalid version: {version_text}") from error
|
|
51
|
-
current = current_version()
|
|
52
|
-
if requested <= current:
|
|
53
|
-
raise ValueError(f"New version {requested} must be greater than {current}")
|
|
54
|
-
|
|
55
|
-
for path, (pattern, _projection_name) in VERSION_FILES.items():
|
|
56
|
-
content = path.read_text(encoding="utf-8")
|
|
57
|
-
updated, count = re.subn(
|
|
58
|
-
pattern,
|
|
59
|
-
rf"\g<1>{requested}\g<3>",
|
|
60
|
-
content,
|
|
61
|
-
flags=re.MULTILINE,
|
|
62
|
-
)
|
|
63
|
-
if count != 1:
|
|
64
|
-
raise RuntimeError(f"Expected one version declaration in {path}, found {count}")
|
|
65
|
-
path.write_text(updated, encoding="utf-8")
|
|
66
|
-
|
|
67
|
-
print(f"Updated ArrayBridge version projections to {requested}")
|
|
68
|
-
print("Run scripts/verify_release_ready.py --allow-dirty, then review and commit.")
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
def main() -> None:
|
|
72
|
-
parser = argparse.ArgumentParser(description=__doc__)
|
|
73
|
-
parser.add_argument("version", help="New release version, for example 0.3.0")
|
|
74
|
-
args = parser.parse_args()
|
|
75
|
-
update_version(args.version)
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
if __name__ == "__main__":
|
|
79
|
-
main()
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|