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:
Agriya Khetarpal
2026-04-15 07:36:04 -04:00
committed by GitHub
co-authored by Henry Schreiner Joe Rickerby
parent 46558a4e24
commit f86700db67
20 changed files with 143 additions and 76 deletions
+2 -4
View File
@@ -43,14 +43,12 @@ jobs:
with:
persist-credentials: false
- uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0
id: python
with:
python-version: "3.x"
- uses: astral-sh/setup-uv@37802adc94f370d6bfd71619e3f0bf239e1f3b78 # v7.6.0
- uses: j178/prek-action@53276d8b0d10f8b6672aa85b4588c6921d0370cc # v2.0.1
- name: PyLint checks
run: pipx run --python "${STEPS_PYTHON_OUTPUTS_PYTHON_PATH}" nox -s pylint -- --output-format=github
env:
STEPS_PYTHON_OUTPUTS_PYTHON_PATH: ${{ steps.python.outputs.python-path }}
run: uvx nox -s pylint -- --output-format=github
sample:
name: Generate a sample project
+1 -1
View File
@@ -1,4 +1,4 @@
#!/usr/bin/env python3
#!/usr/bin/env -S uv run --script
# /// script
# dependencies = ["click", "packaging", "prek"]
+11 -1
View File
@@ -1,4 +1,14 @@
#!/usr/bin/env python3
#!/usr/bin/env -S uv run --script
# /// script
# dependencies = [
# "click",
# "cibuildwheel",
# ]
#
# [tool.uv.sources]
# cibuildwheel = { path = ".." }
# ///
import sys
import textwrap
+1 -1
View File
@@ -1,4 +1,4 @@
#!/usr/bin/env -S uv run -q
#!/usr/bin/env -S uv run --script
# /// script
# dependencies = ["pyyaml"]
+14 -1
View File
@@ -1,4 +1,17 @@
#!/usr/bin/env python3
#!/usr/bin/env -S uv run --script
# /// script
# dependencies = [
# "click",
# "pygithub",
# "pyyaml",
# "rich",
# "cibuildwheel",
# ]
#
# [tool.uv.sources]
# cibuildwheel = { path = ".." }
# ///
"""
Check known projects for usage of requires-python.
+7 -1
View File
@@ -1,4 +1,10 @@
#!/usr/bin/env python3
#!/usr/bin/env -S uv run --script
# /// script
# dependencies = [
# "click",
# ]
# ///
import os
+1 -1
View File
@@ -1,4 +1,4 @@
#!/usr/bin/env python3
#!/usr/bin/env -S uv run --script
# /// script
# dependencies = [
+1 -1
View File
@@ -1,4 +1,4 @@
#!/usr/bin/env python3
#!/usr/bin/env -S uv run --script
import re
from pathlib import Path
+1 -1
View File
@@ -1,4 +1,4 @@
#!/usr/bin/env python3
#!/usr/bin/env -S uv run --script
import dataclasses
import re
+7 -1
View File
@@ -1,4 +1,10 @@
#!/usr/bin/env python3
#!/usr/bin/env -S uv run --script
# /// script
# dependencies = [
# "click",
# ]
# ///
import os
+1 -1
View File
@@ -1,4 +1,4 @@
#!/usr/bin/env python3
#!/usr/bin/env -S uv run --script
import argparse
+1 -1
View File
@@ -1,4 +1,4 @@
#!/usr/bin/env python3
#!/usr/bin/env -S uv run --script
import argparse
+8 -1
View File
@@ -1,4 +1,11 @@
#!/usr/bin/env python3
#!/usr/bin/env -S uv run --script
# /// script
# dependencies = [
# "packaging",
# "requests",
# ]
# ///
import configparser
import dataclasses
+32 -29
View File
@@ -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")
+10 -1
View File
@@ -1,4 +1,13 @@
#!/usr/bin/env python3
#!/usr/bin/env -S uv run --script
# /// script
# dependencies = [
# "click",
# "packaging",
# "requests",
# "rich",
# ]
# ///
import dataclasses
+10 -1
View File
@@ -1,4 +1,13 @@
#!/usr/bin/env python3
#!/usr/bin/env -S uv run --script
# /// script
# dependencies = [
# "cibuildwheel",
# ]
#
# [tool.uv.sources]
# cibuildwheel = { path = ".." }
# ///
import json
+14 -1
View File
@@ -1,4 +1,17 @@
#!/usr/bin/env python3
#!/usr/bin/env -S uv run --script
# /// script
# dependencies = [
# "click",
# "packaging",
# "requests",
# "rich",
# "cibuildwheel",
# ]
#
# [tool.uv.sources]
# cibuildwheel = { path = ".." }
# ///
import difflib
+13 -1
View File
@@ -1,4 +1,16 @@
#!/usr/bin/env python3
#!/usr/bin/env -S uv run --script
# /// script
# dependencies = [
# "click",
# "packaging",
# "rich",
# "cibuildwheel",
# ]
#
# [tool.uv.sources]
# cibuildwheel = { path = ".." }
# ///
import dataclasses
+8 -17
View File
@@ -69,12 +69,10 @@ def update_constraints(session: nox.Session) -> None:
Update the dependencies inplace.
"""
session.install("-e.", "click")
resources = Path("cibuildwheel/resources")
if session.venv_backend != "uv":
session.install("uv>=0.1.23")
session.install("uv>=0.9")
# CUSTOM_COMPILE_COMMAND is a pip-compile option that tells users how to
# regenerate the constraints files
@@ -108,8 +106,7 @@ def update_constraints(session: nox.Session) -> None:
tmp_file = Path(session.create_tmp()) / "constraints-pyodide.in"
session.run(
"python",
session.install_and_run_script(
"bin/generate_pyodide_constraints.py",
"--output-file",
tmp_file,
@@ -135,13 +132,11 @@ def update_pins(session: nox.Session) -> None:
Update the python, docker, virtualenv, node, and python-build-standalone
version pins inplace.
"""
pyproject = nox.project.load_toml()
session.install("-e.", *nox.project.dependency_groups(pyproject, "bin"))
session.run("python", "bin/update_pythons.py", "--force")
session.run("python", "bin/update_docker.py")
session.run("python", "bin/update_virtualenv.py", "--force")
session.run("python", "bin/update_nodejs.py", "--force")
session.run("python", "bin/update_python_build_standalone.py")
session.install_and_run_script("bin/update_pythons.py", "--force")
session.install_and_run_script("bin/update_docker.py")
session.install_and_run_script("bin/update_virtualenv.py", "--force")
session.install_and_run_script("bin/update_nodejs.py", "--force")
session.install_and_run_script("bin/update_python_build_standalone.py")
@nox.session(default=False, reuse_venv=True, tags=["update"])
@@ -189,11 +184,7 @@ def update_how_it_works_image(session: nox.Session) -> None:
"""
Generate the how it works image.
"""
pyproject = nox.project.load_toml()
session.install("-e.", *nox.project.dependency_groups(pyproject, "docs"))
session.install("playwright")
session.run("playwright", "install", "chromium")
session.run("python", "bin/update_how_it_works_image.py")
session.install_and_run_script("bin/update_how_it_works_image.py")
@nox.session(default=False)
-10
View File
@@ -66,15 +66,6 @@ Documentation = "https://cibuildwheel.pypa.io"
Homepage = "https://github.com/pypa/cibuildwheel"
[dependency-groups]
bin = [
"click",
"packaging>=21.0",
"pip-tools",
"pygithub",
"pyyaml",
"requests",
"rich>=9.6",
]
docs = [
"jinja2>=3.1.2",
"mkdocs-include-markdown-plugin==6.2.2",
@@ -97,7 +88,6 @@ test = [
"xdoctest",
]
dev = [
{include-group = "bin"},
{include-group = "docs"},
{include-group = "test"},
]