Get the path to zccache binary. Search order: 1. Project .venv (installed via uv sync / ./install) 2. Sibling zccache repo (../zccache/target/{release,debug}) — dev builds 3. PATH (via shutil.which) If not found, prints a message suggesting the user run ./install.
()
| 19 | |
| 20 | |
| 21 | def get_zccache_wrapper_path() -> str | None: |
| 22 | """Get the path to zccache binary. |
| 23 | |
| 24 | Search order: |
| 25 | 1. Project .venv (installed via uv sync / ./install) |
| 26 | 2. Sibling zccache repo (../zccache/target/{release,debug}) — dev builds |
| 27 | 3. PATH (via shutil.which) |
| 28 | |
| 29 | If not found, prints a message suggesting the user run ./install. |
| 30 | """ |
| 31 | suffix = ".exe" if os.name == "nt" else "" |
| 32 | repo_root = Path(__file__).resolve().parent.parent.parent # ci/util/ -> repo root |
| 33 | |
| 34 | # Check project .venv first (installed release version) |
| 35 | venv_candidate = ( |
| 36 | repo_root |
| 37 | / ".venv" |
| 38 | / ("Scripts" if os.name == "nt" else "bin") |
| 39 | / f"zccache{suffix}" |
| 40 | ) |
| 41 | if venv_candidate.is_file(): |
| 42 | return str(venv_candidate) |
| 43 | |
| 44 | # Check sibling zccache repo (pick most recently built binary) |
| 45 | sibling_zccache = repo_root.parent / "zccache" |
| 46 | best: str | None = None |
| 47 | best_mtime: float = 0 |
| 48 | for profile in ("release", "debug"): |
| 49 | candidate = sibling_zccache / "target" / profile / f"zccache{suffix}" |
| 50 | if candidate.is_file(): |
| 51 | mtime = candidate.stat().st_mtime |
| 52 | if mtime > best_mtime: |
| 53 | best = str(candidate) |
| 54 | best_mtime = mtime |
| 55 | if best is not None: |
| 56 | return best |
| 57 | |
| 58 | # Check PATH |
| 59 | path_result = shutil.which("zccache") |
| 60 | if path_result: |
| 61 | return path_result |
| 62 | |
| 63 | return None |
| 64 | |
| 65 | |
| 66 | def clear_zccache_stats() -> None: |
no test coverage detected