Locate the Playwright-bundled Chromium executable.
()
| 52 | |
| 53 | |
| 54 | def _chromium_executable() -> str: |
| 55 | """Locate the Playwright-bundled Chromium executable.""" |
| 56 | try: |
| 57 | from playwright.sync_api import sync_playwright |
| 58 | except ImportError as exc: # pragma: no cover - import guard |
| 59 | raise SystemExit(f"error: playwright is not installed: {exc}") |
| 60 | with sync_playwright() as p: |
| 61 | path = p.chromium.executable_path |
| 62 | if not path or not Path(path).exists(): |
| 63 | raise SystemExit( |
| 64 | "error: Playwright chromium binary not found. Run `playwright install chromium`." |
| 65 | ) |
| 66 | return path |
| 67 | |
| 68 | |
| 69 | def _pid_alive(pid: int) -> bool: |