Check if Meson is installed and accessible.
()
| 36 | |
| 37 | |
| 38 | def check_meson_installed() -> bool: |
| 39 | """Check if Meson is installed and accessible.""" |
| 40 | meson_exe = get_meson_executable() |
| 41 | # Fast path: if get_meson_executable() returned an absolute venv path, it |
| 42 | # already confirmed the file exists - no need for a subprocess round-trip. |
| 43 | meson_path = Path(meson_exe) |
| 44 | if meson_path.is_absolute() and meson_path.exists(): |
| 45 | return True |
| 46 | # Slow path: venv meson not found; verify the system-PATH "meson" works. |
| 47 | try: |
| 48 | result = subprocess.run( |
| 49 | [meson_exe, "--version"], |
| 50 | capture_output=True, |
| 51 | text=True, |
| 52 | encoding="utf-8", |
| 53 | errors="replace", |
| 54 | timeout=5, |
| 55 | ) |
| 56 | return result.returncode == 0 |
| 57 | except (subprocess.SubprocessError, FileNotFoundError): |
| 58 | return False |
| 59 | |
| 60 | |
| 61 | def get_meson_version() -> str: |
no test coverage detected