Files
Medios-Macina/scripts/install_playwright.py

33 lines
897 B
Python
Raw Normal View History

2025-12-17 14:17:46 -08:00
#!/usr/bin/env python3
"""Install Playwright browser binaries after dependencies are installed.
This script will attempt to install the 'playwright' package if it's missing,
then run the Playwright browser installer.
"""
import sys
import subprocess
def run(cmd: list[str]) -> None:
print("Running:", " ".join(cmd))
subprocess.check_call(cmd)
def main() -> None:
# Ensure 'playwright' package is present; if not, install it.
try:
import playwright # type: ignore
except Exception:
print("'playwright' package not found; installing via pip...")
run([sys.executable, "-m", "pip", "install", "playwright"])
print("Installing Playwright browsers (this may download several hundred MB)...")
run([sys.executable, "-m", "playwright", "install"])
print("Playwright browsers installed successfully.")
if __name__ == "__main__":
main()