-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsitecustomize.py
More file actions
32 lines (25 loc) · 923 Bytes
/
sitecustomize.py
File metadata and controls
32 lines (25 loc) · 923 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# SPDX-License-Identifier: Apache-2.0
# Copyright (c) 2025 OrchIntel Systems Ltd.
"""Ensure local `src/` packages are importable in subprocess `python -m` calls."""
from __future__ import annotations
import importlib.util
import sys
from pathlib import Path
_ROOT = Path(__file__).resolve().parent
_SRC = _ROOT / "src"
if _SRC.is_dir():
src_path = str(_SRC)
if src_path not in sys.path:
sys.path.insert(0, src_path)
# Force legacy `cli.*` imports to resolve to local src/cli package.
cli_init = _SRC / "cli" / "__init__.py"
if cli_init.exists():
spec = importlib.util.spec_from_file_location(
"cli",
cli_init,
submodule_search_locations=[str(_SRC / "cli")],
)
if spec and spec.loader:
module = importlib.util.module_from_spec(spec)
sys.modules["cli"] = module
spec.loader.exec_module(module)