34 lines
1.1 KiB
Python
34 lines
1.1 KiB
Python
from __future__ import annotations
|
|
|
|
import sys
|
|
from pathlib import Path
|
|
import os
|
|
|
|
|
|
# Ensure local vendored toolchain modules are importable in tests.
|
|
repo_root = Path(__file__).resolve().parents[1]
|
|
sys.path.insert(0, str(repo_root))
|
|
vendor_path = repo_root / "vendor"
|
|
if vendor_path.is_dir():
|
|
sys.path.insert(0, str(vendor_path))
|
|
|
|
# Ensure local libs (e.g., kneronnxopt) are importable in tests.
|
|
libs_path = repo_root / "libs"
|
|
if libs_path.is_dir():
|
|
sys.path.insert(0, str(libs_path))
|
|
|
|
# Ensure kneronnxopt package resolves to its inner module directory.
|
|
kneronnxopt_path = repo_root / "libs" / "kneronnxopt"
|
|
if kneronnxopt_path.is_dir():
|
|
sys.path.insert(0, str(kneronnxopt_path))
|
|
|
|
# Ensure E2E python_flow (kneron_inference) is importable in tests.
|
|
e2e_flow_path = repo_root / "E2E_Simulator" / "python_flow"
|
|
if e2e_flow_path.is_dir():
|
|
sys.path.insert(0, str(e2e_flow_path))
|
|
|
|
# Prefer local prebuild binaries to avoid docker-only toolchain checks in sys_flow.
|
|
prebuild_path = repo_root / "toolchain" / "prebuild"
|
|
if prebuild_path.is_dir():
|
|
os.environ.setdefault("USE_PREBUILD", str(prebuild_path))
|