Resolve meson executable path, preferring venv installation. This ensures consistent meson version usage regardless of invocation method (direct Python vs uv run). The venv meson version is controlled by pyproject.toml. Returns: Path to meson executable (venv version prefe
()
| 10 | |
| 11 | |
| 12 | def get_meson_executable() -> str: |
| 13 | """ |
| 14 | Resolve meson executable path, preferring venv installation. |
| 15 | |
| 16 | This ensures consistent meson version usage regardless of invocation method |
| 17 | (direct Python vs uv run). The venv meson version is controlled by pyproject.toml. |
| 18 | |
| 19 | Returns: |
| 20 | Path to meson executable (venv version preferred, falls back to PATH) |
| 21 | """ |
| 22 | # Try to find venv meson first |
| 23 | script_dir = Path(__file__).resolve().parent |
| 24 | project_root = script_dir.parent.parent |
| 25 | |
| 26 | # Platform-specific meson executable name |
| 27 | is_windows = sys.platform.startswith("win") or os.name == "nt" |
| 28 | meson_exe_name = "meson.exe" if is_windows else "meson" |
| 29 | venv_meson = project_root / ".venv" / "Scripts" / meson_exe_name |
| 30 | |
| 31 | if venv_meson.exists(): |
| 32 | return str(venv_meson) |
| 33 | |
| 34 | # Fallback to PATH resolution (will use system meson) |
| 35 | return "meson" |
| 36 | |
| 37 | |
| 38 | def check_meson_installed() -> bool: |