MCPcopy Index your code
hub / github.com/AI45Lab/Code / _bootstrap_a3s_code

Function _bootstrap_a3s_code

examples/ahp_agent_monitors_agent.py:25–43  ·  view source on GitHub ↗

添加 a3s_code 到 sys.path(如果尚未导入)

()

Source from the content-addressed store, hash-verified

23
24
25def _bootstrap_a3s_code():
26 """添加 a3s_code 到 sys.path(如果尚未导入)"""
27 try:
28 import a3s_code # noqa: F401
29 return
30 except ImportError:
31 pass
32 # 从 examples/ 向上找到 sdk/python/.venv
33 examples_dir = Path(__file__).parent
34 sdk_root = examples_dir.parent / "sdk" / "python"
35 for version in ("3.9", "3.10", "3.11", "3.12"):
36 site = sdk_root / ".venv" / "lib" / f"python{version}" / "site-packages"
37 if (site / "a3s_code").exists():
38 sys.path.insert(0, str(site))
39 return
40 raise RuntimeError(
41 "a3s_code 未找到。请先构建:\n"
42 " cd crates/code/sdk/python && maturin develop"
43 )
44
45
46_bootstrap_a3s_code()

Callers 1

Calls 2

existsMethod · 0.45
insertMethod · 0.45

Tested by

no test coverage detected