CoolFace
Modelpublic

TechnoBaptist/SheetSage2

sourceHugging Facecc-by-nc-4.0updated 12d agoView on Hugging Face
0likes15downloads
setup_render.py38 linesDownload Raw Back to root
1"""Install the optional renderer and its matching headless browser."""2from pathlib import Path3import argparse4import subprocess5import sys6 7SCRIPT_DIR = Path(__file__).absolute().parent8sys.path.insert(0, str(SCRIPT_DIR))9 10 11def main():12    parser = argparse.ArgumentParser(description=__doc__)13    parser.add_argument("--with-deps", action="store_true", help="Also install Chromium OS libraries (may require sudo).")14    args = parser.parse_args()15    subprocess.run([sys.executable, "-m", "pip", "install", "-r", str(SCRIPT_DIR / "requirements-render.txt")], check=True)16    command = [sys.executable, "-m", "playwright", "install", "--only-shell", "chromium"]17    if args.with_deps:18        command.append("--with-deps")19    subprocess.run(command, check=True)20    check = """from playwright.sync_api import sync_playwright21with sync_playwright() as p:22    browser = p.chromium.launch(headless=True, args=['--disable-gpu'])23    context = browser.new_context(offline=True)24    page = context.new_page()25    assert page.evaluate('typeof OfflineAudioContext') == 'function'26    browser.close()27"""28    result = subprocess.run([sys.executable, "-c", check], capture_output=True, text=True)29    if result.returncode:30        print("Chromium could not start. On Linux, run python setup_render.py --with-deps to install its system libraries.", file=sys.stderr)31        return 132    print("Rendering is ready. Example: python render.py --input output --audio --score pdf")33    return 034 35 36if __name__ == "__main__":37    raise SystemExit(main())38