Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 0 additions & 30 deletions src/winml/modelkit/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,36 +43,6 @@

logging.getLogger(__name__).addHandler(logging.NullHandler())

def _preload_bundled_onnxruntime_dll() -> None:
# Windows ships C:\Windows\System32\onnxruntime.dll (older API version)
# as part of the system WindowsML component. When WinML EP plugin DLLs
# are loaded (via EpCatalog), they import "onnxruntime.dll" by base name
# and the loader binds them to the system copy, producing
# "The requested API version [N] is not available" errors.
# Loading the wheel-bundled DLL by full path first makes later base-name
# imports resolve to the already-loaded module.
if sys.platform != "win32":
return
try:
import ctypes
import os
from importlib.util import find_spec
from pathlib import Path

spec = find_spec("onnxruntime")
if spec is None or spec.origin is None:
return
dll = Path(spec.origin).parent / "capi" / "onnxruntime.dll"
if not dll.is_file():
return
os.add_dll_directory(str(dll.parent))
ctypes.WinDLL(str(dll))
except Exception as _e: # pragma: no cover - best-effort preload
print(f"Warning: failed to preload bundled onnxruntime.dll: {_e}", file=sys.stderr)


_preload_bundled_onnxruntime_dll()

# _warnings configures filters before any subpackage imports.
from . import _warnings

Expand Down
128 changes: 0 additions & 128 deletions tests/unit/test_modelkit_init.py

This file was deleted.

Loading