Skip to content

Commit 1746a9f

Browse files
committed
Adopt PEP 723 script metadata, uv build, and a .python-version file
1 parent d4a5c41 commit 1746a9f

6 files changed

Lines changed: 32 additions & 10 deletions

File tree

‎.python-version‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
3.10

‎MANIFEST.in‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
include Makefile
33
include .coveragerc
44
include .editorconfig
5+
include .python-version
56
include *.cfg
67
include *.ini
78
include *.md

‎cicd_utils/cicd/scripts/extract_latest_release_notes.py‎

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,18 @@
1-
#!/usr/bin/env python
1+
#!/usr/bin/env -S uv run --script
2+
# /// script
3+
# requires-python = ">=3.10"
4+
# dependencies = [
5+
# "markdown-it-py",
6+
# "mdit-py-plugins",
7+
# "mdformat",
8+
# "mdformat-footnote",
9+
# ]
10+
# ///
11+
# NOTE: The PEP 723 inline metadata above is used when running this
12+
# script standalone (e.g. via `uv run` or the `release-notes`
13+
# tox env). The same dependencies are also declared in the
14+
# `cicd_utils` dependency group in pyproject.toml, which is
15+
# needed for the unit tests that import this module.
216
"""Extract the latest release notes
317
418
Execution steps:

‎pyproject.toml‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,10 @@ cicd_utils = [
6464
# manylinux2014_armv7l wheel, which breaks universal
6565
# (multi-platform) resolution with `uv sync`/`uv lock`
6666
"kaleido<0.4,!=0.2.1.post1",
67-
# ./cicd_utils/cicd/scripts/extract_latest_release_notes.py
67+
# Deps for ./cicd_utils/cicd/scripts/extract_latest_release_notes.py
68+
# NOTE: these are also declared in the script's PEP 723 inline
69+
# metadata (used by `uv run`); they are duplicated here so
70+
# that the unit tests can import the script's module
6871
"markdown-it-py",
6972
"mdit-py-plugins",
7073
"mdformat",

‎tests/cicd_utils/test_scripts/test_scripts_are_executable.py‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,4 +26,6 @@ def test_py_scripts_are_executable(script_path: Path) -> None:
2626
def test_py_scripts_have_py_shebang(script_path: Path) -> None:
2727
with script_path.open("r") as f:
2828
first_line = f.readline()
29-
assert first_line.startswith("#!/usr/bin/env python")
29+
# Scripts are either run directly with python or, when they declare
30+
# PEP 723 inline metadata, through `uv run --script`
31+
assert first_line.startswith(("#!/usr/bin/env python", "#!/usr/bin/env -S uv run --script"))

‎tox.ini‎

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -103,16 +103,17 @@ commands =
103103
[testenv:release-notes]
104104
description = extract release notes from docs/reference/changelog.md
105105
skip_install = true
106-
dependency_groups = cicd_utils
107-
commands = python cicd_utils/cicd/scripts/extract_latest_release_notes.py
106+
allowlist_externals = uv
107+
# The script's dependencies are declared as PEP 723 inline metadata,
108+
# which `uv run` resolves into an isolated (cached) script environment
109+
commands = uv run --no-project --script cicd_utils/cicd/scripts/extract_latest_release_notes.py
108110

109111
[testenv:build-dists]
110112
description = build source (sdist) and binary (wheel) distributions
111-
deps =
112-
build
113-
twine
114-
allowlist_externals = rm
113+
skip_install = true
114+
deps = twine
115+
allowlist_externals = rm, uv
115116
commands =
116117
rm -rf dist/
117-
python -m build
118+
uv build
118119
twine check --strict dist/*

0 commit comments

Comments
 (0)