Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions news/4435.fixed.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
(toolchains) {obj}`python.single_version_override` without `urls` no longer
resets the `strip_prefix` of the existing archives, which broke the
freethreaded toolchains that use the `full` archives.
14 changes: 10 additions & 4 deletions python/private/python.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -612,12 +612,18 @@ def _process_single_version_overrides(*, tag, _fail = fail, default):
return

sha256 = dict(tag.sha256) or available_versions[tag.python_version]["sha256"]
override = {
"sha256": sha256,
"strip_prefix": {
if tag.urls:
strip_prefix = {
platform: tag.strip_prefix
for platform in sha256
},
}
else:
# The archives are not overridden, so keep their strip_prefix, which
# differs between the archive flavors.
strip_prefix = available_versions[tag.python_version]["strip_prefix"]
override = {
"sha256": sha256,
"strip_prefix": strip_prefix,
"url": {
platform: list(tag.urls)
for platform in tag.sha256
Expand Down
29 changes: 29 additions & 0 deletions tests/python/python_tests.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

load("@pythons_hub//:versions.bzl", "MINOR_MAPPING")
load("@rules_testing//lib:test_suite.bzl", "test_suite")
load("//python:versions.bzl", "TOOL_VERSIONS")
load("//python/private:bzlmod_enabled.bzl", "BZLMOD_ENABLED") # buildifier: disable=bzl-visibility
load("//python/private:python.bzl", "parse_modules") # buildifier: disable=bzl-visibility
load("//python/private:repo_utils.bzl", "repo_utils") # buildifier: disable=bzl-visibility
Expand Down Expand Up @@ -441,6 +442,34 @@ def _test_libpython_override(env):

_tests.append(_test_libpython_override)

def _test_single_version_override_keeps_strip_prefix(env):
# This version has `full` archives for the freethreaded builds, which use
# a different strip_prefix.
python_version = "3.13.0"
py = parse_modules(
module_ctx = python_ext.mctx(
python_ext.module(
name = "my_module",
is_root = True,
single_version_override = [
python_ext.single_version_override(
libpython = "exclude",
python_version = python_version,
),
],
toolchain = [python_ext.toolchain(python_version = "3.13")],
),
_rules_python_module(),
),
logger = repo_utils.logger(verbosity_level = 0, name = "python"),
)

env.expect.that_dict(
py.config.default["tool_versions"][python_version]["strip_prefix"],
).contains_exactly(TOOL_VERSIONS[python_version]["strip_prefix"])

_tests.append(_test_single_version_override_keeps_strip_prefix)

_ARCHIVE_FLAVOR_MANIFEST = """
1111111111111111111111111111111111111111111111111111111111111111 20260414/cpython-3.14.4+20260414-x86_64-unknown-linux-gnu-install_only.tar.gz
2222222222222222222222222222222222222222222222222222222222222222 20260414/cpython-3.14.4+20260414-x86_64-unknown-linux-gnu-install_only_stripped.tar.gz
Expand Down
Loading