Repository navigation
Expand file tree
/
Copy pathconftest.py
More file actions
51 lines (40 loc) · 1.75 KB
/
Copy pathconftest.py
File metadata and controls
51 lines (40 loc) · 1.75 KB
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
"""Root pytest hook — keep in sync with ``tests/conftest.py`` path logic."""
from __future__ import annotations
import importlib.util
import os
import sys
from pathlib import Path
# Allow ``import probing`` from the checkout during ``make develop`` runs.
# Skip when a complete wheel is installed so we do not shadow site-packages.
_repo_python = Path(__file__).parent / "python"
def _missing_probing_modules() -> list[str]:
try:
import importlib.util
required = (
"probing._core",
"probing.skills.loader",
"probing.ext",
"probing.handlers",
)
return [name for name in required if importlib.util.find_spec(name) is None]
except (ImportError, ModuleNotFoundError, ValueError):
return ["probing (import system error)"]
def _installed_probing_is_complete() -> bool:
return not _missing_probing_modules()
if _repo_python.is_dir():
_prepend_repo = not _installed_probing_is_complete()
if os.environ.get("PROBING_WHEEL_TEST") == "1" and not _installed_probing_is_complete():
missing = ", ".join(_missing_probing_modules())
raise RuntimeError(
"installed wheel is incomplete "
f"(missing: {missing}); "
"run: make frontend && make wheel && make install-wheel "
"(install with PROBING=0 — do not set PROBING=1 during pip install)"
)
if _prepend_repo:
_repo_python_str = str(_repo_python)
if _repo_python_str not in sys.path:
sys.path.insert(0, _repo_python_str)
# The Rust extension (probing._core) must exist — run once: ``make develop``
# (builds _core into python/probing/ and installs the ``probing`` CLI).
# Release/CI wheel path: ``make wheel && make install-wheel``.