chore: add PEP 723 metadata for various bin/ scripts, drop bin dependency group (#2819)
* Add PEP 723 metadata for various `bin` scripts * Use a subprocess to install chromium * Regenerate image * Update shebangs Co-Authored-By: Henry Schreiner <HenrySchreinerIII@gmail.com> * Add cibuildwheel local dependency for some scripts Co-Authored-By: Henry Schreiner <HenrySchreinerIII@gmail.com> * Remove `bin` dependency group fully * Add CSS for styling the diagram Co-Authored-By: Joe Rickerby <1244307+joerick@users.noreply.github.com> * Restore image to original * Install `uv` for PyLint to find it * Drop setup-python too in favour of setup-uv * Revert "Drop setup-python too in favour of setup-uv" This reverts commit 663db5c253f18bd09229ea5dbf92f7f6aa8ebf1c. * Make `uv` venv backend for nox optional again --------- Co-authored-by: Henry Schreiner <HenrySchreinerIII@gmail.com> Co-authored-by: Joe Rickerby <1244307+joerick@users.noreply.github.com>
This commit is contained in:
co-authored by
Henry Schreiner
Joe Rickerby
parent
46558a4e24
commit
f86700db67
@@ -1,42 +1,45 @@
|
||||
#!/usr/bin/env python3
|
||||
#!/usr/bin/env -S uv run --script
|
||||
|
||||
# /// script
|
||||
# dependencies = [
|
||||
# "playwright",
|
||||
# ]
|
||||
# ///
|
||||
|
||||
import subprocess
|
||||
import sys
|
||||
import tempfile
|
||||
from pathlib import Path
|
||||
|
||||
try:
|
||||
from playwright.sync_api import sync_playwright # type: ignore[import-not-found]
|
||||
except ImportError:
|
||||
msg = """
|
||||
playwright not found. Install it with:
|
||||
pip install playwright
|
||||
playwright install chromium
|
||||
from playwright.sync_api import sync_playwright # type: ignore[import-not-found]
|
||||
|
||||
Or, run this script with:
|
||||
nox -s update_how_it_works_image
|
||||
"""
|
||||
raise SystemExit(msg) from None
|
||||
CSS = """
|
||||
<link href="https://fonts.googleapis.com/css2?family=Lato&display=swap" rel="stylesheet">
|
||||
<style>
|
||||
html, body {
|
||||
font-family: Lato, "Helvetica Neue", Helvetica, Arial, sans-serif;
|
||||
font-weight: 400;
|
||||
font-size: 16px;
|
||||
color: #404040;
|
||||
background: white;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
}
|
||||
* {
|
||||
box-sizing: border-box;
|
||||
}
|
||||
</style>
|
||||
"""
|
||||
|
||||
|
||||
def main() -> None:
|
||||
subprocess.run([sys.executable, "-m", "playwright", "install", "chromium"], check=True)
|
||||
|
||||
html_str = Path("docs/diagram.html").read_text()
|
||||
html_str = f"<html><head>{CSS}</head><body>{html_str}</body></html>"
|
||||
|
||||
with tempfile.TemporaryDirectory() as tmp_dir_str:
|
||||
tmp_dir = Path(tmp_dir_str)
|
||||
subprocess.run(["mkdocs", "build", "--site-dir", tmp_dir], check=True)
|
||||
|
||||
html_str = Path("docs/diagram.html").read_text()
|
||||
css_tags = f"""
|
||||
<style>{(tmp_dir / "css/theme.css").read_text()}</style>
|
||||
<style>{(tmp_dir / "css/theme_extra.css").read_text()}</style>
|
||||
<style>{(tmp_dir / "extra.css").read_text()}</style>
|
||||
<style>
|
||||
body {{
|
||||
background: white;
|
||||
}}
|
||||
</style>
|
||||
"""
|
||||
html_str = f"<html><head>{css_tags}</head><body>{html_str}</body></html>"
|
||||
|
||||
html_path = Path(tmp_dir) / "diagram_screenshot.html"
|
||||
html_path = Path(tmp_dir_str) / "diagram_screenshot.html"
|
||||
html_path.write_text(html_str)
|
||||
|
||||
dest_path = Path("docs/data/how-it-works.png")
|
||||
|
||||
Reference in New Issue
Block a user