From 7fa918484e2d9b0b489c178c623ab05bbf7d67e0 Mon Sep 17 00:00:00 2001 From: Cornelius Roemer Date: Thu, 19 Jun 2025 17:30:24 +0200 Subject: [PATCH 01/10] Use release-cycle data for main branch version --- conf.py | 10 ++++++++++ versions.rst | 2 +- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/conf.py b/conf.py index bedd99c42..68e472664 100644 --- a/conf.py +++ b/conf.py @@ -1,3 +1,5 @@ +import json + extensions = [ 'notfound.extension', 'sphinx.ext.extlinks', @@ -185,6 +187,14 @@ """ +# Dynamically expose the Python version associated with the "main" branch. +with open("include/release-cycle.json", encoding="UTF-8") as _f: + _cycle = json.load(_f) +_main_version = next( + ver for ver, data in _cycle.items() if data.get("branch") == "main" +) +rst_prolog += f"\n.. |mainversion| replace:: {_main_version}\n" + # sphinx.ext.extlinks # This config is a dictionary of external sites, # mapping unique short aliases to a base URL and a prefix. diff --git a/versions.rst b/versions.rst index 8cfd259f8..1e36c197e 100644 --- a/versions.rst +++ b/versions.rst @@ -5,7 +5,7 @@ Status of Python versions ========================= -The ``main`` branch is currently the future Python 3.14, and is the only +The ``main`` branch is currently the future Python |mainversion|, and is the only branch that accepts new features. The latest release for each Python version can be found on the `download page `_. From 8ba784ceab765f0dbb228111ee144da6f1f85ea2 Mon Sep 17 00:00:00 2001 From: Cornelius Roemer Date: Thu, 19 Jun 2025 17:39:38 +0200 Subject: [PATCH 02/10] Derive main branch version from highest release cycle entry --- conf.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/conf.py b/conf.py index 68e472664..fc8f2e475 100644 --- a/conf.py +++ b/conf.py @@ -188,10 +188,13 @@ """ # Dynamically expose the Python version associated with the "main" branch. +# The release cycle data may not be ordered, so choose the numerically highest +# version key instead of relying on a specific entry's position. with open("include/release-cycle.json", encoding="UTF-8") as _f: _cycle = json.load(_f) -_main_version = next( - ver for ver, data in _cycle.items() if data.get("branch") == "main" +_main_version = max( + _cycle, + key=lambda v: tuple(int(part) for part in v.split(".")), ) rst_prolog += f"\n.. |mainversion| replace:: {_main_version}\n" From 3064c16c689c77e4acad4aa4bf989edbe461b9f5 Mon Sep 17 00:00:00 2001 From: Cornelius Roemer Date: Thu, 19 Jun 2025 17:44:30 +0200 Subject: [PATCH 03/10] Define mainversion substitution as part of rst_prolog --- conf.py | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/conf.py b/conf.py index fc8f2e475..60105c51b 100644 --- a/conf.py +++ b/conf.py @@ -167,8 +167,18 @@ # sphinx-notfound-page notfound_urls_prefix = "/" +# Dynamically expose the Python version associated with the "main" branch. +# The release cycle data may not be ordered, so choose the numerically highest +# version key instead of relying on a specific entry's position. +with open("include/release-cycle.json", encoding="UTF-8") as _f: + _cycle = json.load(_f) +_main_version = max( + _cycle, + key=lambda v: tuple(int(part) for part in v.split(".")), +) + # prolog and epilogs -rst_prolog = """ +rst_prolog = f""" .. |draft| replace:: This is part of a **Draft** of the Python Contributor's Guide. Text in square brackets are notes about content to fill in. @@ -185,18 +195,9 @@ .. _Refactoring the DevGuide: https://discuss.python.org/t/refactoring-the-devguide-into-a-contribution-guide/63409 -""" +.. |mainversion| replace:: {_main_version} -# Dynamically expose the Python version associated with the "main" branch. -# The release cycle data may not be ordered, so choose the numerically highest -# version key instead of relying on a specific entry's position. -with open("include/release-cycle.json", encoding="UTF-8") as _f: - _cycle = json.load(_f) -_main_version = max( - _cycle, - key=lambda v: tuple(int(part) for part in v.split(".")), -) -rst_prolog += f"\n.. |mainversion| replace:: {_main_version}\n" +""" # sphinx.ext.extlinks # This config is a dictionary of external sites, From 26ceb555f0419528ba22ca02e419d9f89e76dab5 Mon Sep 17 00:00:00 2001 From: Cornelius Roemer Date: Thu, 19 Jun 2025 17:44:36 +0200 Subject: [PATCH 04/10] Read main branch version from release cycle --- conf.py | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/conf.py b/conf.py index 60105c51b..3b758b4ae 100644 --- a/conf.py +++ b/conf.py @@ -168,14 +168,17 @@ notfound_urls_prefix = "/" # Dynamically expose the Python version associated with the "main" branch. -# The release cycle data may not be ordered, so choose the numerically highest -# version key instead of relying on a specific entry's position. +# Exactly one entry in ``release-cycle.json`` should have ``"branch": "main"``. with open("include/release-cycle.json", encoding="UTF-8") as _f: _cycle = json.load(_f) -_main_version = max( - _cycle, - key=lambda v: tuple(int(part) for part in v.split(".")), -) + +_main_entries = [v for v, d in _cycle.items() if d.get("branch") == "main"] +if len(_main_entries) != 1: + raise RuntimeError( + "release-cycle.json must contain exactly one entry with 'branch': 'main'" + ) + +_main_version = _main_entries[0] # prolog and epilogs rst_prolog = f""" From 68e60a46d5c1cf5b89fc9fed8ff30635d4da9589 Mon Sep 17 00:00:00 2001 From: Cornelius Roemer Date: Mon, 23 Jun 2025 16:40:16 +0200 Subject: [PATCH 05/10] Update conf.py Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com> --- conf.py | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/conf.py b/conf.py index 3b758b4ae..df71b1ce1 100644 --- a/conf.py +++ b/conf.py @@ -172,13 +172,7 @@ with open("include/release-cycle.json", encoding="UTF-8") as _f: _cycle = json.load(_f) -_main_entries = [v for v, d in _cycle.items() if d.get("branch") == "main"] -if len(_main_entries) != 1: - raise RuntimeError( - "release-cycle.json must contain exactly one entry with 'branch': 'main'" - ) - -_main_version = _main_entries[0] +main_version = next(version for version, data in _cycle.items() if data.get("branch") == "main") # prolog and epilogs rst_prolog = f""" From 97c8abb63ad1f077e4fba1236c8430edda104773 Mon Sep 17 00:00:00 2001 From: Cornelius Roemer Date: Mon, 23 Jun 2025 16:40:30 +0200 Subject: [PATCH 06/10] Update conf.py Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com> --- conf.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/conf.py b/conf.py index df71b1ce1..a684d272b 100644 --- a/conf.py +++ b/conf.py @@ -192,7 +192,7 @@ .. _Refactoring the DevGuide: https://discuss.python.org/t/refactoring-the-devguide-into-a-contribution-guide/63409 -.. |mainversion| replace:: {_main_version} +.. |main_version| replace:: {_main_version} """ From ac60826f57f8894f02d9a63e9ae850ddfbd5753a Mon Sep 17 00:00:00 2001 From: Cornelius Roemer Date: Mon, 23 Jun 2025 16:40:36 +0200 Subject: [PATCH 07/10] Update versions.rst Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com> --- versions.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/versions.rst b/versions.rst index 1e36c197e..0a52829c2 100644 --- a/versions.rst +++ b/versions.rst @@ -5,7 +5,7 @@ Status of Python versions ========================= -The ``main`` branch is currently the future Python |mainversion|, and is the only +The ``main`` branch is currently the future Python |main_version|, and is the only branch that accepts new features. The latest release for each Python version can be found on the `download page `_. From 6da61e30109baed8cc02340101489ddccf6fd3e8 Mon Sep 17 00:00:00 2001 From: Cornelius Roemer Date: Mon, 23 Jun 2025 16:41:47 +0200 Subject: [PATCH 08/10] Apply suggestions from code review --- conf.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/conf.py b/conf.py index a684d272b..e680f49e7 100644 --- a/conf.py +++ b/conf.py @@ -172,7 +172,7 @@ with open("include/release-cycle.json", encoding="UTF-8") as _f: _cycle = json.load(_f) -main_version = next(version for version, data in _cycle.items() if data.get("branch") == "main") +_main_version = next(version for version, data in _cycle.items() if data.get("branch") == "main") # prolog and epilogs rst_prolog = f""" From 68a457a98c047e948a4954d0283b2f4185a7d44b Mon Sep 17 00:00:00 2001 From: Cornelius Roemer Date: Mon, 23 Jun 2025 17:10:51 +0200 Subject: [PATCH 09/10] Update conf.py Co-authored-by: Ezio Melotti --- conf.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/conf.py b/conf.py index e680f49e7..2f039ea3e 100644 --- a/conf.py +++ b/conf.py @@ -172,7 +172,8 @@ with open("include/release-cycle.json", encoding="UTF-8") as _f: _cycle = json.load(_f) -_main_version = next(version for version, data in _cycle.items() if data.get("branch") == "main") +_main_version = next(version for version, data in _cycle.items() + if data.get("branch") == "main") # prolog and epilogs rst_prolog = f""" From 6d044ac913ea860e36c345a0c85a2f641ff218ce Mon Sep 17 00:00:00 2001 From: Cornelius Roemer Date: Mon, 23 Jun 2025 17:36:00 +0200 Subject: [PATCH 10/10] Fix format --- conf.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/conf.py b/conf.py index 2f039ea3e..9bfe2305c 100644 --- a/conf.py +++ b/conf.py @@ -172,8 +172,9 @@ with open("include/release-cycle.json", encoding="UTF-8") as _f: _cycle = json.load(_f) -_main_version = next(version for version, data in _cycle.items() - if data.get("branch") == "main") +_main_version = next( + version for version, data in _cycle.items() if data.get("branch") == "main" +) # prolog and epilogs rst_prolog = f"""