
from __future__ import annotations

import subprocess
import sys


def _pip_install(pkg: str) -> None:
    print(f"[bootstrap] pip install {pkg} ...", file=sys.stderr)
    subprocess.check_call(
        [sys.executable, "-m", "pip", "install", "--quiet", pkg]
    )


def _ensure_playwright_pkg() -> None:
    try:
        import playwright.sync_api
        return
    except ImportError:
        pass
    _pip_install("playwright")


def ensure_browser(name: str = "chromium") -> None:





    print(f"[bootstrap] playwright install {name} ...", file=sys.stderr)
    subprocess.check_call(
        [sys.executable, "-m", "playwright", "install", name]
    )


def ensure_runtime() -> None:

    _ensure_playwright_pkg()
