Skip to content

Commit 36e7bee

Browse files
authored
Merge branch 'main' into squash_merge_into_public_main_preview_2026-03-06+1617
2 parents 59d9e2e + 730a3e2 commit 36e7bee

File tree

6 files changed

+100
-1
lines changed

6 files changed

+100
-1
lines changed

cuda_bindings/docs/source/conf.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
"enum_tools.autoenum",
4141
"sphinx_copybutton",
4242
"release_toc",
43+
"release_date",
4344
]
4445

4546
nb_execution_mode = "off"

cuda_core/docs/source/conf.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
"sphinx_copybutton",
4242
"sphinx_toolbox.more_autodoc.autoprotocol",
4343
"release_toc",
44+
"release_date",
4445
]
4546

4647
# Add any paths that contain templates here, relative to this directory.

cuda_core/pyproject.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,8 @@ classifiers = [
4747
"Environment :: GPU :: NVIDIA CUDA :: 13",
4848
]
4949
dependencies = [
50-
"cuda-pathfinder >=1.4.2",
50+
# TODO: bump to >=1.4.2 once cuda-pathfinder 1.4.2 is released.
51+
"cuda-pathfinder >=1.4.1",
5152
"numpy",
5253
]
5354

cuda_pathfinder/docs/source/conf.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
"enum_tools.autoenum",
4141
"sphinx_copybutton",
4242
"release_toc",
43+
"release_date",
4344
]
4445

4546
nb_execution_mode = "off"
Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
# SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
2+
# SPDX-License-Identifier: LicenseRef-NVIDIA-SOFTWARE-LICENSE
3+
4+
"""Sphinx extension to auto-inject release dates from git tags.
5+
6+
For every release-notes page (``release/<version>-notes``), this
7+
extension looks up the corresponding git tag and injects a
8+
``Released on <date>`` line after the RST title. Pages that already
9+
contain such a line, or whose version has no tag yet, are left
10+
untouched.
11+
"""
12+
13+
from __future__ import annotations
14+
15+
import re
16+
import subprocess
17+
from datetime import UTC, datetime
18+
19+
from sphinx.application import Sphinx
20+
21+
_RELEASED_ON_RE = re.compile(r"Released on ", re.IGNORECASE)
22+
_RELEASE_NOTE_RE = re.compile(r"^release/(.+)-notes$")
23+
_UNDERLINE_RE = re.compile(r"^={3,}[ \t]*$", re.MULTILINE)
24+
25+
# project name (from conf.py) -> git tag prefix
26+
_TAG_PREFIXES: dict[str, str] = {
27+
"cuda.core": "cuda-core-v",
28+
"cuda.pathfinder": "cuda-pathfinder-v",
29+
"cuda.bindings": "v",
30+
"CUDA Python": "v",
31+
}
32+
33+
34+
def _format_date(iso_date: str) -> str:
35+
"""``2026-03-06`` -> ``Mar 6, 2026``."""
36+
dt = datetime.strptime(iso_date, "%Y-%m-%d").replace(tzinfo=UTC)
37+
return f"{dt.strftime('%b')} {dt.day}, {dt.year}"
38+
39+
40+
def _git_tag_date(tag: str) -> str | None:
41+
"""Return the creator date (YYYY-MM-DD) for *tag*, or None."""
42+
try:
43+
result = subprocess.run( # noqa: S603
44+
[ # noqa: S607
45+
"git",
46+
"for-each-ref",
47+
"--format=%(creatordate:short)",
48+
f"refs/tags/{tag}",
49+
],
50+
capture_output=True,
51+
text=True,
52+
timeout=5,
53+
)
54+
date_str = result.stdout.strip()
55+
except (subprocess.TimeoutExpired, FileNotFoundError):
56+
date_str = ""
57+
return date_str or None
58+
59+
60+
def _on_source_read(app: Sphinx, docname: str, source: list[str]) -> None:
61+
m = _RELEASE_NOTE_RE.match(docname)
62+
if not m:
63+
return
64+
65+
text = source[0]
66+
if _RELEASED_ON_RE.search(text):
67+
return
68+
69+
version = m.group(1)
70+
prefix = _TAG_PREFIXES.get(app.config.project)
71+
if prefix is None:
72+
return
73+
74+
tag = prefix + version
75+
iso_date = _git_tag_date(tag)
76+
if not iso_date:
77+
return
78+
79+
underline = _UNDERLINE_RE.search(text)
80+
if not underline:
81+
return
82+
83+
date_line = f"Released on {_format_date(iso_date)}"
84+
85+
# Insert after the title underline: skip any blank lines, then place
86+
# the date line surrounded by single blank lines before the content.
87+
after = text[underline.end() :]
88+
stripped = after.lstrip("\n")
89+
source[0] = text[: underline.end()] + f"\n\n{date_line}\n\n" + stripped
90+
91+
92+
def setup(app: Sphinx) -> dict:
93+
app.connect("source-read", _on_source_read)
94+
return {"version": "1.0", "parallel_read_safe": True}

cuda_python/docs/source/conf.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
"myst_nb",
3838
"enum_tools.autoenum",
3939
"release_toc",
40+
"release_date",
4041
]
4142

4243
# Add any paths that contain templates here, relative to this directory.

0 commit comments

Comments
 (0)