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
@@ -43,14 +43,12 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
persist-credentials: false
|
persist-credentials: false
|
||||||
- uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0
|
- uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0
|
||||||
id: python
|
|
||||||
with:
|
with:
|
||||||
python-version: "3.x"
|
python-version: "3.x"
|
||||||
|
- uses: astral-sh/setup-uv@37802adc94f370d6bfd71619e3f0bf239e1f3b78 # v7.6.0
|
||||||
- uses: j178/prek-action@53276d8b0d10f8b6672aa85b4588c6921d0370cc # v2.0.1
|
- uses: j178/prek-action@53276d8b0d10f8b6672aa85b4588c6921d0370cc # v2.0.1
|
||||||
- name: PyLint checks
|
- name: PyLint checks
|
||||||
run: pipx run --python "${STEPS_PYTHON_OUTPUTS_PYTHON_PATH}" nox -s pylint -- --output-format=github
|
run: uvx nox -s pylint -- --output-format=github
|
||||||
env:
|
|
||||||
STEPS_PYTHON_OUTPUTS_PYTHON_PATH: ${{ steps.python.outputs.python-path }}
|
|
||||||
|
|
||||||
sample:
|
sample:
|
||||||
name: Generate a sample project
|
name: Generate a sample project
|
||||||
|
|||||||
+1
-1
@@ -1,4 +1,4 @@
|
|||||||
#!/usr/bin/env python3
|
#!/usr/bin/env -S uv run --script
|
||||||
|
|
||||||
# /// script
|
# /// script
|
||||||
# dependencies = ["click", "packaging", "prek"]
|
# dependencies = ["click", "packaging", "prek"]
|
||||||
|
|||||||
@@ -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 sys
|
||||||
import textwrap
|
import textwrap
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
#!/usr/bin/env -S uv run -q
|
#!/usr/bin/env -S uv run --script
|
||||||
|
|
||||||
# /// script
|
# /// script
|
||||||
# dependencies = ["pyyaml"]
|
# dependencies = ["pyyaml"]
|
||||||
|
|||||||
@@ -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.
|
Check known projects for usage of requires-python.
|
||||||
|
|||||||
@@ -1,4 +1,10 @@
|
|||||||
#!/usr/bin/env python3
|
#!/usr/bin/env -S uv run --script
|
||||||
|
|
||||||
|
# /// script
|
||||||
|
# dependencies = [
|
||||||
|
# "click",
|
||||||
|
# ]
|
||||||
|
# ///
|
||||||
|
|
||||||
|
|
||||||
import os
|
import os
|
||||||
|
|||||||
+1
-1
@@ -1,4 +1,4 @@
|
|||||||
#!/usr/bin/env python3
|
#!/usr/bin/env -S uv run --script
|
||||||
|
|
||||||
# /// script
|
# /// script
|
||||||
# dependencies = [
|
# dependencies = [
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
#!/usr/bin/env python3
|
#!/usr/bin/env -S uv run --script
|
||||||
|
|
||||||
import re
|
import re
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
#!/usr/bin/env python3
|
#!/usr/bin/env -S uv run --script
|
||||||
|
|
||||||
import dataclasses
|
import dataclasses
|
||||||
import re
|
import re
|
||||||
|
|||||||
@@ -1,4 +1,10 @@
|
|||||||
#!/usr/bin/env python3
|
#!/usr/bin/env -S uv run --script
|
||||||
|
|
||||||
|
# /// script
|
||||||
|
# dependencies = [
|
||||||
|
# "click",
|
||||||
|
# ]
|
||||||
|
# ///
|
||||||
|
|
||||||
|
|
||||||
import os
|
import os
|
||||||
|
|||||||
+1
-1
@@ -1,4 +1,4 @@
|
|||||||
#!/usr/bin/env python3
|
#!/usr/bin/env -S uv run --script
|
||||||
|
|
||||||
|
|
||||||
import argparse
|
import argparse
|
||||||
|
|||||||
+1
-1
@@ -1,4 +1,4 @@
|
|||||||
#!/usr/bin/env python3
|
#!/usr/bin/env -S uv run --script
|
||||||
|
|
||||||
|
|
||||||
import argparse
|
import argparse
|
||||||
|
|||||||
@@ -1,4 +1,11 @@
|
|||||||
#!/usr/bin/env python3
|
#!/usr/bin/env -S uv run --script
|
||||||
|
|
||||||
|
# /// script
|
||||||
|
# dependencies = [
|
||||||
|
# "packaging",
|
||||||
|
# "requests",
|
||||||
|
# ]
|
||||||
|
# ///
|
||||||
|
|
||||||
import configparser
|
import configparser
|
||||||
import dataclasses
|
import dataclasses
|
||||||
|
|||||||
@@ -1,42 +1,45 @@
|
|||||||
#!/usr/bin/env python3
|
#!/usr/bin/env -S uv run --script
|
||||||
|
|
||||||
|
# /// script
|
||||||
|
# dependencies = [
|
||||||
|
# "playwright",
|
||||||
|
# ]
|
||||||
|
# ///
|
||||||
|
|
||||||
import subprocess
|
import subprocess
|
||||||
|
import sys
|
||||||
import tempfile
|
import tempfile
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
||||||
try:
|
from playwright.sync_api import sync_playwright # type: ignore[import-not-found]
|
||||||
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
|
|
||||||
|
|
||||||
Or, run this script with:
|
CSS = """
|
||||||
nox -s update_how_it_works_image
|
<link href="https://fonts.googleapis.com/css2?family=Lato&display=swap" rel="stylesheet">
|
||||||
"""
|
<style>
|
||||||
raise SystemExit(msg) from None
|
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:
|
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:
|
with tempfile.TemporaryDirectory() as tmp_dir_str:
|
||||||
tmp_dir = Path(tmp_dir_str)
|
html_path = Path(tmp_dir_str) / "diagram_screenshot.html"
|
||||||
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.write_text(html_str)
|
html_path.write_text(html_str)
|
||||||
|
|
||||||
dest_path = Path("docs/data/how-it-works.png")
|
dest_path = Path("docs/data/how-it-works.png")
|
||||||
|
|||||||
+10
-1
@@ -1,4 +1,13 @@
|
|||||||
#!/usr/bin/env python3
|
#!/usr/bin/env -S uv run --script
|
||||||
|
|
||||||
|
# /// script
|
||||||
|
# dependencies = [
|
||||||
|
# "click",
|
||||||
|
# "packaging",
|
||||||
|
# "requests",
|
||||||
|
# "rich",
|
||||||
|
# ]
|
||||||
|
# ///
|
||||||
|
|
||||||
|
|
||||||
import dataclasses
|
import dataclasses
|
||||||
|
|||||||
@@ -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
|
import json
|
||||||
|
|
||||||
|
|||||||
+14
-1
@@ -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
|
import difflib
|
||||||
|
|||||||
@@ -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
|
import dataclasses
|
||||||
|
|||||||
+8
-17
@@ -69,12 +69,10 @@ def update_constraints(session: nox.Session) -> None:
|
|||||||
Update the dependencies inplace.
|
Update the dependencies inplace.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
session.install("-e.", "click")
|
|
||||||
|
|
||||||
resources = Path("cibuildwheel/resources")
|
resources = Path("cibuildwheel/resources")
|
||||||
|
|
||||||
if session.venv_backend != "uv":
|
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
|
# CUSTOM_COMPILE_COMMAND is a pip-compile option that tells users how to
|
||||||
# regenerate the constraints files
|
# regenerate the constraints files
|
||||||
@@ -108,8 +106,7 @@ def update_constraints(session: nox.Session) -> None:
|
|||||||
|
|
||||||
tmp_file = Path(session.create_tmp()) / "constraints-pyodide.in"
|
tmp_file = Path(session.create_tmp()) / "constraints-pyodide.in"
|
||||||
|
|
||||||
session.run(
|
session.install_and_run_script(
|
||||||
"python",
|
|
||||||
"bin/generate_pyodide_constraints.py",
|
"bin/generate_pyodide_constraints.py",
|
||||||
"--output-file",
|
"--output-file",
|
||||||
tmp_file,
|
tmp_file,
|
||||||
@@ -135,13 +132,11 @@ def update_pins(session: nox.Session) -> None:
|
|||||||
Update the python, docker, virtualenv, node, and python-build-standalone
|
Update the python, docker, virtualenv, node, and python-build-standalone
|
||||||
version pins inplace.
|
version pins inplace.
|
||||||
"""
|
"""
|
||||||
pyproject = nox.project.load_toml()
|
session.install_and_run_script("bin/update_pythons.py", "--force")
|
||||||
session.install("-e.", *nox.project.dependency_groups(pyproject, "bin"))
|
session.install_and_run_script("bin/update_docker.py")
|
||||||
session.run("python", "bin/update_pythons.py", "--force")
|
session.install_and_run_script("bin/update_virtualenv.py", "--force")
|
||||||
session.run("python", "bin/update_docker.py")
|
session.install_and_run_script("bin/update_nodejs.py", "--force")
|
||||||
session.run("python", "bin/update_virtualenv.py", "--force")
|
session.install_and_run_script("bin/update_python_build_standalone.py")
|
||||||
session.run("python", "bin/update_nodejs.py", "--force")
|
|
||||||
session.run("python", "bin/update_python_build_standalone.py")
|
|
||||||
|
|
||||||
|
|
||||||
@nox.session(default=False, reuse_venv=True, tags=["update"])
|
@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.
|
Generate the how it works image.
|
||||||
"""
|
"""
|
||||||
pyproject = nox.project.load_toml()
|
session.install_and_run_script("bin/update_how_it_works_image.py")
|
||||||
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")
|
|
||||||
|
|
||||||
|
|
||||||
@nox.session(default=False)
|
@nox.session(default=False)
|
||||||
|
|||||||
@@ -66,15 +66,6 @@ Documentation = "https://cibuildwheel.pypa.io"
|
|||||||
Homepage = "https://github.com/pypa/cibuildwheel"
|
Homepage = "https://github.com/pypa/cibuildwheel"
|
||||||
|
|
||||||
[dependency-groups]
|
[dependency-groups]
|
||||||
bin = [
|
|
||||||
"click",
|
|
||||||
"packaging>=21.0",
|
|
||||||
"pip-tools",
|
|
||||||
"pygithub",
|
|
||||||
"pyyaml",
|
|
||||||
"requests",
|
|
||||||
"rich>=9.6",
|
|
||||||
]
|
|
||||||
docs = [
|
docs = [
|
||||||
"jinja2>=3.1.2",
|
"jinja2>=3.1.2",
|
||||||
"mkdocs-include-markdown-plugin==6.2.2",
|
"mkdocs-include-markdown-plugin==6.2.2",
|
||||||
@@ -97,7 +88,6 @@ test = [
|
|||||||
"xdoctest",
|
"xdoctest",
|
||||||
]
|
]
|
||||||
dev = [
|
dev = [
|
||||||
{include-group = "bin"},
|
|
||||||
{include-group = "docs"},
|
{include-group = "docs"},
|
||||||
{include-group = "test"},
|
{include-group = "test"},
|
||||||
]
|
]
|
||||||
|
|||||||
Reference in New Issue
Block a user