MCPcopy Create free account
hub / github.com/cactus-compute/cactus / _resolve_project_root

Function _resolve_project_root

python/src/cli.py:23–43  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

21
22
23def _resolve_project_root() -> Path:
24 # Optional explicit override for environments running from installed packages.
25 env_root = os.getenv("CACTUS_PROJECT_ROOT", "").strip()
26 if env_root:
27 candidate = Path(env_root).expanduser().resolve()
28 if _looks_like_project_root(candidate):
29 return candidate
30
31 # Prefer the repo containing this CLI module.
32 module_root = SCRIPT_DIR.parent.parent
33 if _looks_like_project_root(module_root):
34 return module_root
35
36 # Fallback: repo containing current working directory.
37 cwd = Path.cwd().resolve()
38 for candidate in [cwd, *cwd.parents]:
39 if _looks_like_project_root(candidate):
40 return candidate
41
42 # Final fallback for unusual layouts.
43 return module_root
44
45
46PROJECT_ROOT = _resolve_project_root()

Callers 1

cli.pyFile · 0.85

Calls 1

_looks_like_project_rootFunction · 0.85

Tested by

no test coverage detected