fix(sdk): gracefully handle missing proto stubs in __init__.py

Wrap the sandbox import in try/except so subpackages like
openshell.prover can be imported without a full Rust build.
Removes the conftest.py namespace hack that was working around this.

Signed-off-by: Alexander Watson <zredlined@gmail.com>
This commit is contained in:
Alexander Watson
2026-03-31 08:58:08 -07:00
parent 68715f9033
commit 560365cc3b
2 changed files with 17 additions and 32 deletions
-20
View File
@@ -1,20 +0,0 @@
# SPDX-FileCopyrightText: Copyright (c) 2025-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
# SPDX-License-Identifier: Apache-2.0
"""Root conftest for Python tests.
Pre-register openshell as a namespace package so subpackage tests (e.g.,
the prover) can run without the full Rust build that generates proto stubs.
"""
from __future__ import annotations
import sys
import types
from pathlib import Path
if "openshell" not in sys.modules:
_pkg = types.ModuleType("openshell")
_pkg.__path__ = [str(Path(__file__).resolve().parent / "openshell")]
_pkg.__package__ = "openshell"
sys.modules["openshell"] = _pkg
+17 -12
View File
@@ -5,18 +5,23 @@
from __future__ import annotations
from .sandbox import (
ClusterInferenceConfig,
ExecChunk,
ExecResult,
InferenceRouteClient,
Sandbox,
SandboxClient,
SandboxError,
SandboxRef,
SandboxSession,
TlsConfig,
)
try:
from .sandbox import (
ClusterInferenceConfig,
ExecChunk,
ExecResult,
InferenceRouteClient,
Sandbox,
SandboxClient,
SandboxError,
SandboxRef,
SandboxSession,
TlsConfig,
)
except ImportError:
# Proto stubs not yet generated (requires Rust build).
# Subpackages like openshell.prover can still be imported.
pass
try:
from importlib.metadata import version