diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index c6f21168..7e5d2a0a 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -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 diff --git a/bin/bump_version.py b/bin/bump_version.py index a7b095f0..366baffa 100755 --- a/bin/bump_version.py +++ b/bin/bump_version.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python3 +#!/usr/bin/env -S uv run --script # /// script # dependencies = ["click", "packaging", "prek"] diff --git a/bin/generate_pyodide_constraints.py b/bin/generate_pyodide_constraints.py index e378dd8e..aad425c6 100755 --- a/bin/generate_pyodide_constraints.py +++ b/bin/generate_pyodide_constraints.py @@ -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 diff --git a/bin/generate_schema.py b/bin/generate_schema.py index b2f63118..022ffe35 100755 --- a/bin/generate_schema.py +++ b/bin/generate_schema.py @@ -1,4 +1,4 @@ -#!/usr/bin/env -S uv run -q +#!/usr/bin/env -S uv run --script # /// script # dependencies = ["pyyaml"] diff --git a/bin/inspect_all_known_projects.py b/bin/inspect_all_known_projects.py index 60688c4b..03964796 100755 --- a/bin/inspect_all_known_projects.py +++ b/bin/inspect_all_known_projects.py @@ -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. diff --git a/bin/make_dependency_update_pr.py b/bin/make_dependency_update_pr.py index 0d46aada..2240a629 100755 --- a/bin/make_dependency_update_pr.py +++ b/bin/make_dependency_update_pr.py @@ -1,4 +1,10 @@ -#!/usr/bin/env python3 +#!/usr/bin/env -S uv run --script + +# /// script +# dependencies = [ +# "click", +# ] +# /// import os diff --git a/bin/projects.py b/bin/projects.py index 8caa7535..f58d1bdc 100755 --- a/bin/projects.py +++ b/bin/projects.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python3 +#!/usr/bin/env -S uv run --script # /// script # dependencies = [ diff --git a/bin/readme_changelog.py b/bin/readme_changelog.py index 29c30293..30d7ffe6 100755 --- a/bin/readme_changelog.py +++ b/bin/readme_changelog.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python3 +#!/usr/bin/env -S uv run --script import re from pathlib import Path diff --git a/bin/readme_options_table.py b/bin/readme_options_table.py index 203d6bf5..d15c040b 100755 --- a/bin/readme_options_table.py +++ b/bin/readme_options_table.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python3 +#!/usr/bin/env -S uv run --script import dataclasses import re diff --git a/bin/run_example_ci_configs.py b/bin/run_example_ci_configs.py index 71bbd338..fbc392f8 100755 --- a/bin/run_example_ci_configs.py +++ b/bin/run_example_ci_configs.py @@ -1,4 +1,10 @@ -#!/usr/bin/env python3 +#!/usr/bin/env -S uv run --script + +# /// script +# dependencies = [ +# "click", +# ] +# /// import os diff --git a/bin/run_tests.py b/bin/run_tests.py index ed315042..e636e2b2 100755 --- a/bin/run_tests.py +++ b/bin/run_tests.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python3 +#!/usr/bin/env -S uv run --script import argparse diff --git a/bin/sample_build.py b/bin/sample_build.py index b86f9724..21550afb 100755 --- a/bin/sample_build.py +++ b/bin/sample_build.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python3 +#!/usr/bin/env -S uv run --script import argparse diff --git a/bin/update_docker.py b/bin/update_docker.py index 1e358b29..8eccde3a 100755 --- a/bin/update_docker.py +++ b/bin/update_docker.py @@ -1,4 +1,11 @@ -#!/usr/bin/env python3 +#!/usr/bin/env -S uv run --script + +# /// script +# dependencies = [ +# "packaging", +# "requests", +# ] +# /// import configparser import dataclasses diff --git a/bin/update_how_it_works_image.py b/bin/update_how_it_works_image.py index 54350ace..b8cf9c9d 100755 --- a/bin/update_how_it_works_image.py +++ b/bin/update_how_it_works_image.py @@ -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 = """ + + +""" def main() -> None: + subprocess.run([sys.executable, "-m", "playwright", "install", "chromium"], check=True) + + html_str = Path("docs/diagram.html").read_text() + html_str = f"{CSS}{html_str}" + 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""" - - - - - """ - html_str = f"{css_tags}{html_str}" - - 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") diff --git a/bin/update_nodejs.py b/bin/update_nodejs.py index a564fad0..f45bb413 100755 --- a/bin/update_nodejs.py +++ b/bin/update_nodejs.py @@ -1,4 +1,13 @@ -#!/usr/bin/env python3 +#!/usr/bin/env -S uv run --script + +# /// script +# dependencies = [ +# "click", +# "packaging", +# "requests", +# "rich", +# ] +# /// import dataclasses diff --git a/bin/update_python_build_standalone.py b/bin/update_python_build_standalone.py index b9ac3726..15b425df 100755 --- a/bin/update_python_build_standalone.py +++ b/bin/update_python_build_standalone.py @@ -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 diff --git a/bin/update_pythons.py b/bin/update_pythons.py index f998a617..b99a079e 100755 --- a/bin/update_pythons.py +++ b/bin/update_pythons.py @@ -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 diff --git a/bin/update_virtualenv.py b/bin/update_virtualenv.py index ce5ceca2..c51c8725 100755 --- a/bin/update_virtualenv.py +++ b/bin/update_virtualenv.py @@ -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 diff --git a/noxfile.py b/noxfile.py index 53530de4..5644369b 100755 --- a/noxfile.py +++ b/noxfile.py @@ -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) diff --git a/pyproject.toml b/pyproject.toml index 896c037c..d5c92213 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -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"}, ]