Skip to content

Commit 26ceb55

Browse files
Read main branch version from release cycle
1 parent 3064c16 commit 26ceb55

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

conf.py

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -168,14 +168,17 @@
168168
notfound_urls_prefix = "/"
169169

170170
# Dynamically expose the Python version associated with the "main" branch.
171-
# The release cycle data may not be ordered, so choose the numerically highest
172-
# version key instead of relying on a specific entry's position.
171+
# Exactly one entry in ``release-cycle.json`` should have ``"branch": "main"``.
173172
with open("include/release-cycle.json", encoding="UTF-8") as _f:
174173
_cycle = json.load(_f)
175-
_main_version = max(
176-
_cycle,
177-
key=lambda v: tuple(int(part) for part in v.split(".")),
178-
)
174+
175+
_main_entries = [v for v, d in _cycle.items() if d.get("branch") == "main"]
176+
if len(_main_entries) != 1:
177+
raise RuntimeError(
178+
"release-cycle.json must contain exactly one entry with 'branch': 'main'"
179+
)
180+
181+
_main_version = _main_entries[0]
179182

180183
# prolog and epilogs
181184
rst_prolog = f"""

0 commit comments

Comments
 (0)