https://github.com/python/cpython/commit/b643826c1164274e35f55d2236aa47085e2a5efc
commit: b643826c1164274e35f55d2236aa47085e2a5efc
branch: main
author: Hugo van Kemenade <[email protected]>
committer: hugovk <[email protected]>
date: 2026-06-03T16:37:09+03:00
summary:

Docs: Replace hardcoded `SOURCE_URI` with `patchlevel` check (#150850)

files:
M Doc/conf.py
M Doc/tools/extensions/pyspecific.py

diff --git a/Doc/conf.py b/Doc/conf.py
index 3856f4fe9b375c4..9b103a594b235cf 100644
--- a/Doc/conf.py
+++ b/Doc/conf.py
@@ -8,15 +8,13 @@
 
 import os
 import sys
-from importlib import import_module
 from importlib.util import find_spec
 
 # Make our custom extensions available to Sphinx
 sys.path.append(os.path.abspath('tools/extensions'))
 sys.path.append(os.path.abspath('includes'))
 
-# Python specific content from Doc/Tools/extensions/pyspecific.py
-from pyspecific import SOURCE_URI
+from patchlevel import get_header_version_info, get_version_info
 
 # General configuration
 # ---------------------
@@ -78,7 +76,7 @@
 # We look for the Include/patchlevel.h file in the current Python source tree
 # and replace the values accordingly.
 # See Doc/tools/extensions/patchlevel.py
-version, release = import_module('patchlevel').get_version_info()
+version, release = get_version_info()
 
 rst_epilog = f"""
 .. |python_version_literal| replace:: ``Python {version}``
@@ -555,16 +553,20 @@
     r'https://unix.org/version2/whatsnew/lp64_wp.html',
 ]
 
+
 # Options for sphinx.ext.extlinks
 # -------------------------------
 
+v = get_header_version_info()
+branch = "main" if v.releaselevel == "alpha" else f"{v.major}.{v.minor}"
+
 # This config is a dictionary of external sites,
 # mapping unique short aliases to a base URL and a prefix.
 # https://www.sphinx-doc.org/en/master/usage/extensions/extlinks.html
 extlinks = {
     "oss-fuzz": ("https://issues.oss-fuzz.com/issues/%s";, "#%s"),
     "pypi": ("https://pypi.org/project/%s/";, "%s"),
-    "source": (SOURCE_URI, "%s"),
+    "source": (f"https://github.com/python/cpython/tree/{branch}/%s";, "%s"),
 }
 extlinks_detect_hardcoded_links = True
 
diff --git a/Doc/tools/extensions/pyspecific.py 
b/Doc/tools/extensions/pyspecific.py
index f9bf273e7624a04..9b335f2976a2fa3 100644
--- a/Doc/tools/extensions/pyspecific.py
+++ b/Doc/tools/extensions/pyspecific.py
@@ -10,19 +10,10 @@
 """
 
 import re
-import io
-from os import getenv, path
 
-from docutils import nodes
-from docutils.parsers.rst import directives
-from docutils.utils import unescape
 from sphinx import addnodes
-from sphinx.domains.python import PyFunction, PyMethod, PyModule
-from sphinx.locale import _ as sphinx_gettext
-from sphinx.util.docutils import SphinxDirective
+from sphinx.domains.python import PyFunction, PyMethod
 
-# Used in conf.py and updated here by python/release-tools/run_release.py
-SOURCE_URI = 'https://github.com/python/cpython/tree/main/%s'
 
 class PyAwaitableMixin(object):
     def handle_signature(self, sig, signode):

_______________________________________________
Python-checkins mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3//lists/python-checkins.python.org
Member address: [email protected]

Reply via email to