From 1746a9f49ef48d3745d07a85697fe4feb7839748 Mon Sep 17 00:00:00 2001 From: Tomas Pereira de Vasconcelos Date: Sat, 25 Jul 2026 06:05:24 +0200 Subject: [PATCH 1/2] Adopt PEP 723 script metadata, uv build, and a .python-version file --- .python-version | 1 + MANIFEST.in | 1 + .../cicd/scripts/extract_latest_release_notes.py | 16 +++++++++++++++- pyproject.toml | 5 ++++- .../test_scripts/test_scripts_are_executable.py | 4 +++- tox.ini | 15 ++++++++------- 6 files changed, 32 insertions(+), 10 deletions(-) create mode 100644 .python-version diff --git a/.python-version b/.python-version new file mode 100644 index 00000000..c8cfe395 --- /dev/null +++ b/.python-version @@ -0,0 +1 @@ +3.10 diff --git a/MANIFEST.in b/MANIFEST.in index 619e566f..55d7cc1b 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -2,6 +2,7 @@ include Makefile include .coveragerc include .editorconfig +include .python-version include *.cfg include *.ini include *.md diff --git a/cicd_utils/cicd/scripts/extract_latest_release_notes.py b/cicd_utils/cicd/scripts/extract_latest_release_notes.py index e024e0e7..17bb785e 100755 --- a/cicd_utils/cicd/scripts/extract_latest_release_notes.py +++ b/cicd_utils/cicd/scripts/extract_latest_release_notes.py @@ -1,4 +1,18 @@ -#!/usr/bin/env python +#!/usr/bin/env -S uv run --script +# /// script +# requires-python = ">=3.10" +# dependencies = [ +# "markdown-it-py", +# "mdit-py-plugins", +# "mdformat", +# "mdformat-footnote", +# ] +# /// +# NOTE: The PEP 723 inline metadata above is used when running this +# script standalone (e.g. via `uv run` or the `release-notes` +# tox env). The same dependencies are also declared in the +# `cicd_utils` dependency group in pyproject.toml, which is +# needed for the unit tests that import this module. """Extract the latest release notes Execution steps: diff --git a/pyproject.toml b/pyproject.toml index a093455c..3f95ff12 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -64,7 +64,10 @@ cicd_utils = [ # manylinux2014_armv7l wheel, which breaks universal # (multi-platform) resolution with `uv sync`/`uv lock` "kaleido<0.4,!=0.2.1.post1", - # ./cicd_utils/cicd/scripts/extract_latest_release_notes.py + # Deps for ./cicd_utils/cicd/scripts/extract_latest_release_notes.py + # NOTE: these are also declared in the script's PEP 723 inline + # metadata (used by `uv run`); they are duplicated here so + # that the unit tests can import the script's module "markdown-it-py", "mdit-py-plugins", "mdformat", diff --git a/tests/cicd_utils/test_scripts/test_scripts_are_executable.py b/tests/cicd_utils/test_scripts/test_scripts_are_executable.py index c92169b3..2ff77201 100644 --- a/tests/cicd_utils/test_scripts/test_scripts_are_executable.py +++ b/tests/cicd_utils/test_scripts/test_scripts_are_executable.py @@ -26,4 +26,6 @@ def test_py_scripts_are_executable(script_path: Path) -> None: def test_py_scripts_have_py_shebang(script_path: Path) -> None: with script_path.open("r") as f: first_line = f.readline() - assert first_line.startswith("#!/usr/bin/env python") + # Scripts are either run directly with python or, when they declare + # PEP 723 inline metadata, through `uv run --script` + assert first_line.startswith(("#!/usr/bin/env python", "#!/usr/bin/env -S uv run --script")) diff --git a/tox.ini b/tox.ini index b9e3e6c4..fa5ecd9c 100644 --- a/tox.ini +++ b/tox.ini @@ -103,16 +103,17 @@ commands = [testenv:release-notes] description = extract release notes from docs/reference/changelog.md skip_install = true -dependency_groups = cicd_utils -commands = python cicd_utils/cicd/scripts/extract_latest_release_notes.py +allowlist_externals = uv +# The script's dependencies are declared as PEP 723 inline metadata, +# which `uv run` resolves into an isolated (cached) script environment +commands = uv run --no-project --script cicd_utils/cicd/scripts/extract_latest_release_notes.py [testenv:build-dists] description = build source (sdist) and binary (wheel) distributions -deps = - build - twine -allowlist_externals = rm +skip_install = true +deps = twine +allowlist_externals = rm, uv commands = rm -rf dist/ - python -m build + uv build twine check --strict dist/* From 4785c4783456cd833a67bca398c20ce652a8a2d7 Mon Sep 17 00:00:00 2001 From: Tomas Pereira de Vasconcelos Date: Sat, 25 Jul 2026 06:06:12 +0200 Subject: [PATCH 2/2] Add changelog entries for PR 392 --- docs/reference/changelog.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/docs/reference/changelog.md b/docs/reference/changelog.md index c57405cf..a3687d51 100644 --- a/docs/reference/changelog.md +++ b/docs/reference/changelog.md @@ -8,6 +8,9 @@ Unreleased changes ### Developer Experience - Migrate all development dependencies from `requirements/*.txt` files to PEP 735 dependency groups in `pyproject.toml` ({gh-pr}`388`) +- Declare the release notes script's dependencies as PEP 723 inline metadata and run it with `uv run` ({gh-pr}`392`) +- Use `uv build` to build the source and binary distributions ({gh-pr}`392`) +- Add a `.python-version` file pinning the default development interpreter to Python 3.10 ({gh-pr}`392`) ### CI/CD