Skip to content

Docs: Replace hardcoded SOURCE_URI with patchlevel check#150850

Merged
hugovk merged 2 commits into
python:mainfrom
hugovk:rm-SOURCE_URI
Jun 3, 2026
Merged

Docs: Replace hardcoded SOURCE_URI with patchlevel check#150850
hugovk merged 2 commits into
python:mainfrom
hugovk:rm-SOURCE_URI

Conversation

@hugovk
Copy link
Copy Markdown
Member

@hugovk hugovk commented Jun 3, 2026

During yesterday's 3.15.0b2 release, the reminder to update SOURCE_URI triggered.

SOURCE_URI is used for linking stdlib pages such as:

But this reminder was meant to happen during b1, when the 3.15 branch is created. It happened during b1 for 3.14.

See #150783 (comment).

The cause of this was this fix: python/release-tools#379.

But rather than updating release-tools to trigger the reminder during b1 (and it's a disruptive reminder), let's remove the hardcoding in SOURCE_URI altogether, and replace it with a check for the release level:

  • For alpha (and that includes main as it is now, pre-a1): link to main.
  • Otherwise: link to the relevant 3.x.

And we do this directly where it's used in conf.py instead of in pyspecfic.py and importing from there.

Also remove a bunch of unused imports pyspecfic.py.

@hugovk hugovk requested a review from AA-Turner as a code owner June 3, 2026 12:47
@hugovk hugovk added the needs backport to 3.13 bugs and security fixes label Jun 3, 2026
@hugovk hugovk requested a review from StanFromIreland as a code owner June 3, 2026 12:47
@hugovk hugovk added needs backport to 3.14 bugs and security fixes needs backport to 3.15 pre-release feature fixes, bugs and security fixes labels Jun 3, 2026
Comment thread Doc/conf.py
# -------------------------------

v = get_header_version_info()
branch = "main" if v.releaselevel == "alpha" else f"{v.major}.{v.minor}"
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We already calculate the version above, can we re-use that?

cpython/Doc/conf.py

Lines 78 to 81 in 6453065

# 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()

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

They're strings like "3.16" and "3.16.0a0". I suppose we could do "a" in release, but it's cleaner to check releaselevel.

But we can clean up these imports: no need for importlib.import_module because we've already done sys.path.append(os.path.abspath('tools/extensions')).

@StanFromIreland
Copy link
Copy Markdown
Member

I tested it in the preview by going to this section and clicking the last link and I can confirm it works :-)

Copy link
Copy Markdown
Member

@StanFromIreland StanFromIreland left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@hugovk hugovk merged commit b643826 into python:main Jun 3, 2026
34 checks passed
@hugovk hugovk deleted the rm-SOURCE_URI branch June 3, 2026 13:37
@miss-islington-app
Copy link
Copy Markdown

Thanks @hugovk for the PR 🌮🎉.. I'm working now to backport this PR to: 3.13, 3.14, 3.15.
🐍🍒⛏🤖

@miss-islington-app
Copy link
Copy Markdown

Sorry, @hugovk, I could not cleanly backport this to 3.15 due to a conflict.
Please backport using cherry_picker on command line.

cherry_picker b643826c1164274e35f55d2236aa47085e2a5efc 3.15

@miss-islington-app
Copy link
Copy Markdown

Sorry, @hugovk, I could not cleanly backport this to 3.14 due to a conflict.
Please backport using cherry_picker on command line.

cherry_picker b643826c1164274e35f55d2236aa47085e2a5efc 3.14

@miss-islington-app
Copy link
Copy Markdown

Sorry, @hugovk, I could not cleanly backport this to 3.13 due to a conflict.
Please backport using cherry_picker on command line.

cherry_picker b643826c1164274e35f55d2236aa47085e2a5efc 3.13

@bedevere-app
Copy link
Copy Markdown

bedevere-app Bot commented Jun 3, 2026

GH-150855 is a backport of this pull request to the 3.15 branch.

@bedevere-app bedevere-app Bot removed the needs backport to 3.15 pre-release feature fixes, bugs and security fixes label Jun 3, 2026
@bedevere-app
Copy link
Copy Markdown

bedevere-app Bot commented Jun 3, 2026

GH-150856 is a backport of this pull request to the 3.14 branch.

@bedevere-app bedevere-app Bot removed the needs backport to 3.14 bugs and security fixes label Jun 3, 2026
@bedevere-app
Copy link
Copy Markdown

bedevere-app Bot commented Jun 3, 2026

GH-150857 is a backport of this pull request to the 3.13 branch.

@bedevere-app bedevere-app Bot removed the needs backport to 3.13 bugs and security fixes label Jun 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants