Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
85e7778
feat(toolchains): support dynamic registration from remote manifest
rickeylev May 31, 2026
7533be3
test(python): bypass bzlmod extension unit tests under legacy workspa…
rickeylev May 31, 2026
4cbfe5e
refactor(test): inline python test helpers into python_tests.bzl
rickeylev May 31, 2026
2f37ffc
Add add_runtime_manifest_files to python.override
rickeylev Jun 6, 2026
1cad325
Expose freethreaded and archive_flavor in PBS manifest parsing
rickeylev Jun 6, 2026
738d995
Update docs/toolchains.md for add_runtime_manifest_files
rickeylev Jun 6, 2026
fd22fc7
Prefer install_only archive flavors in PBS manifest resolution
rickeylev Jun 6, 2026
8eb3ff2
Ignore unrecognized archive flavors in PBS manifest resolution
rickeylev Jun 6, 2026
e3e8a78
Merge upstream main into feat.toolchain.manifest
rickeylev Jun 6, 2026
80a6ac4
Register builtin runtimes via centralized runtime manifest
rickeylev Jun 6, 2026
221991c
Refactor runtime manifest parsing to emit simple manifest structs
rickeylev Jun 7, 2026
faf57d5
Merge branch 'fetch-runtimes-from-manifest' into register-builtin-run…
rickeylev Jun 8, 2026
634aa42
Fix bzl_library dependencies for Stardoc API generation
rickeylev Jun 8, 2026
437cfb1
Merge remote-tracking branch 'upstream/main' into register-builtin-ru…
rickeylev Jun 9, 2026
fd12e42
build: configure secondary mirror fallback for Stardoc and add retry …
rickeylev Jun 9, 2026
8347229
build: strengthen downloader resilience against 504 timeouts
rickeylev Jun 9, 2026
f9ae916
build: fix primary pass-through rewrites in downloader_config.cfg
rickeylev Jun 9, 2026
d40fa3e
docs: enforce modern Python version on sphinx-build binary
rickeylev Jun 9, 2026
9dc9da6
Robustify manifest platform matching and microarch sorting
rickeylev Jun 9, 2026
b6d67d3
Merge remote-tracking branch 'upstream/main' into register-builtin-ru…
rickeylev Jun 9, 2026
d056f49
Rename plain flavor attribute to build_flavor in manifest parser
rickeylev Jun 9, 2026
72ac435
feat(toolchains): Populate runtimes_manifest.txt with historical Pyth…
rickeylev Jun 10, 2026
973ef5a
feat(toolchains): Unified historical release manifest, dynamic WORKSP…
rickeylev Jun 10, 2026
d9423c2
restore accurate runtimes manifest
rickeylev Jun 10, 2026
c0bc526
feat(toolchains): Universal slice refactoring and top-level WORKSPACE…
rickeylev Jun 10, 2026
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 .bazelrc
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@ common --enable_bzlmod
common --disk_cache=~/.cache/bazel/bazel-disk-cache
# Drop `experimental_` prefix once Bazel 7 is no longer supported
common --experimental_downloader_config=downloader_config.cfg
common --http_timeout_scaling=10.0
common --experimental_repository_downloader_retries=10



# Additional config to use for readthedocs builds.
Expand Down
3 changes: 2 additions & 1 deletion WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -68,11 +68,12 @@ load("//:internal_dev_setup.bzl", "rules_python_internal_setup")

rules_python_internal_setup()

load("@pythons_hub//:versions.bzl", "PYTHON_VERSIONS")
load("//python:repositories.bzl", "py_repositories", "python_register_multi_toolchains")

py_repositories()

load("@pythons_hub//:versions.bzl", "PYTHON_VERSIONS")

python_register_multi_toolchains(
name = "python",
default_version = "3.11",
Expand Down
2 changes: 1 addition & 1 deletion docs/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -170,8 +170,8 @@ sphinx_build_binary(
labels.BOOTSTRAP_IMPL: "script",
labels.VENVS_SITE_PACKAGES: "yes",
labels.PY_FREETHREADED: "yes",
labels.PYTHON_VERSION: "3.14",
},
python_version = "3.14",
target_compatible_with = _TARGET_COMPATIBLE_WITH,
deps = [
"@dev_pip//myst_parser",
Expand Down
7 changes: 7 additions & 0 deletions downloader_config.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ rewrite ^github\.com/bazelbuild/bazel-skylib/(.*) github.com/bazelbuild/bazel-sk
rewrite ^github\.com/bazelbuild/platforms/(.*) github.com/bazelbuild/platforms/$1
rewrite ^github\.com/bazelbuild/rules_kotlin/(.*) github.com/bazelbuild/rules_kotlin/$1
rewrite ^github\.com/bazelbuild/rules_shell/(.*) github.com/bazelbuild/rules_shell/$1
rewrite ^github\.com/bazelbuild/rules_java/(.*) github.com/bazelbuild/rules_java/$1
rewrite ^github\.com/bazelbuild/stardoc/(.*) github.com/bazelbuild/stardoc/$1


# Fall back to mirror (secondary)
# Tracking upstream BCR mirror addition: https://github.com/bazelbuild/platforms/issues/139
Expand All @@ -14,3 +17,7 @@ rewrite ^github\.com/bazelbuild/bazel-skylib/(.*) mirror.bazel.build/github.com/
rewrite ^github\.com/bazelbuild/platforms/(.*) mirror.bazel.build/github.com/bazelbuild/platforms/$1
rewrite ^github\.com/bazelbuild/rules_kotlin/(.*) mirror.bazel.build/github.com/bazelbuild/rules_kotlin/$1
rewrite ^github\.com/bazelbuild/rules_shell/(.*) mirror.bazel.build/github.com/bazelbuild/rules_shell/$1
rewrite ^github\.com/bazelbuild/rules_java/(.*) mirror.bazel.build/github.com/bazelbuild/rules_java/$1
rewrite ^github\.com/bazelbuild/stardoc/(.*) mirror.bazel.build/github.com/bazelbuild/stardoc/$1


3 changes: 3 additions & 0 deletions gazelle/.bazelrc
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
common --deleted_packages=examples/bzlmod_build_file_generation
common --deleted_packages=examples/bzlmod_build_file_generation/runfiles
common --experimental_downloader_config=downloader_config.cfg
common --http_timeout_scaling=10.0
common --experimental_repository_downloader_retries=10


test --test_output=errors

Expand Down
7 changes: 7 additions & 0 deletions gazelle/downloader_config.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ rewrite ^github\.com/bazelbuild/bazel-skylib/(.*) github.com/bazelbuild/bazel-sk
rewrite ^github\.com/bazelbuild/platforms/(.*) github.com/bazelbuild/platforms/$1
rewrite ^github\.com/bazelbuild/rules_kotlin/(.*) github.com/bazelbuild/rules_kotlin/$1
rewrite ^github\.com/bazelbuild/rules_shell/(.*) github.com/bazelbuild/rules_shell/$1
rewrite ^github\.com/bazelbuild/rules_java/(.*) github.com/bazelbuild/rules_java/$1
rewrite ^github\.com/bazelbuild/stardoc/(.*) github.com/bazelbuild/stardoc/$1


# Fall back to mirror (secondary)
# Tracking upstream BCR mirror addition: https://github.com/bazelbuild/platforms/issues/139
Expand All @@ -14,3 +17,7 @@ rewrite ^github\.com/bazelbuild/bazel-skylib/(.*) mirror.bazel.build/github.com/
rewrite ^github\.com/bazelbuild/platforms/(.*) mirror.bazel.build/github.com/bazelbuild/platforms/$1
rewrite ^github\.com/bazelbuild/rules_kotlin/(.*) mirror.bazel.build/github.com/bazelbuild/rules_kotlin/$1
rewrite ^github\.com/bazelbuild/rules_shell/(.*) mirror.bazel.build/github.com/bazelbuild/rules_shell/$1
rewrite ^github\.com/bazelbuild/rules_java/(.*) mirror.bazel.build/github.com/bazelbuild/rules_java/$1
rewrite ^github\.com/bazelbuild/stardoc/(.*) mirror.bazel.build/github.com/bazelbuild/stardoc/$1


Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

nit: extra newlines, here and in other downloader_config files.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

All 3 downloader_config files are identical - can/should they be deduped? In a separate PR.

5 changes: 3 additions & 2 deletions internal_dev_deps.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.

"""Dependencies that are needed for development and testing of rules_python itself."""
"""Dependencies that are needed for development and testing of rules_python itself in WORKSPACE mode."""

load("@bazel_tools//tools/build_defs/repo:http.bzl", _http_archive = "http_archive", _http_file = "http_file")
load("@bazel_tools//tools/build_defs/repo:local.bzl", "local_repository")
Expand All @@ -34,7 +34,7 @@ def http_file(name, **kwargs):
)

def rules_python_internal_deps():
"""Fetches all required dependencies for developing/testing rules_python itself.
"""Fetches all required dependencies for developing/testing rules_python itself in WORKSPACE mode.

Setup of these dependencies is done by `internal_dev_setup.bzl`

Expand All @@ -46,6 +46,7 @@ def rules_python_internal_deps():
transition_settings = [
str(Label("//tests/multi_pypi:external_deps_name")),
],
workspace_mode = True,
)

# Sphinxdocs doesn't support workspace mode, but we have to define it
Expand Down
1 change: 1 addition & 0 deletions python/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,7 @@ filegroup(
exports_files([
"defs.bzl",
"python.bzl", # Deprecated, please use defs.bzl
"runtimes_manifest.txt",
])

# This target can be used to inspect the current Python major version. To use,
Expand Down
4 changes: 3 additions & 1 deletion python/private/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,7 @@ bzl_library(
name = "internal_config_repo_bzl",
srcs = ["internal_config_repo.bzl"],
deps = [
":pbs_manifest_bzl",
":repo_utils_bzl",
":text_util_bzl",
],
Expand Down Expand Up @@ -298,12 +299,12 @@ bzl_library(
":bazel_tools_bzl",
":coverage_deps_bzl",
":full_version_bzl",
":internal_config_repo_bzl",
":python_repository_bzl",
":repo_utils_bzl",
":toolchains_repo_bzl",
"//python:versions_bzl",
"//python/private/pypi:deps_bzl",
"@rules_python_internal//:manifest_tool_versions_bzl",
],
)

Expand Down Expand Up @@ -332,6 +333,7 @@ bzl_library(
name = "pythons_hub_bzl",
srcs = ["pythons_hub.bzl"],
deps = [
":pbs_manifest_bzl",
":py_toolchain_suite_bzl",
":text_util_bzl",
"//python:versions_bzl",
Expand Down
25 changes: 21 additions & 4 deletions python/private/internal_config_repo.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ settings for rules to later use.
"""

load("//python/private:text_util.bzl", "render")
load(":pbs_manifest.bzl", "parse_sha_manifest")
load(":repo_utils.bzl", "repo_utils")

_ENABLE_DEPRECATION_WARNINGS_ENVVAR_NAME = "RULES_PYTHON_DEPRECATION_WARNINGS"
Expand Down Expand Up @@ -49,13 +50,18 @@ package(
)

bzl_library(
name = "rules_python_config_bzl",
srcs = ["rules_python_config.bzl"]
name = "extra_transition_settings_bzl",
srcs = ["extra_transition_settings.bzl"],
)

bzl_library(
name = "extra_transition_settings_bzl",
srcs = ["extra_transition_settings.bzl"],
name = "manifest_tool_versions_bzl",
srcs = ["manifest_tool_versions.bzl"],
)

bzl_library(
name = "rules_python_config_bzl",
srcs = ["rules_python_config.bzl"],
)
"""

Expand Down Expand Up @@ -130,6 +136,13 @@ def _internal_config_repo_impl(rctx):
_TRANSITION_SETTINGS_DEBUG_TEMPLATE.format(lines = "\n".join(debug_lines)),
)

if rctx.attr.workspace_mode:
content = rctx.read(rctx.path(Label("//python:runtimes_manifest.txt")))
entries = parse_sha_manifest(content)
rctx.file("manifest_tool_versions.bzl", _render_manifest_entries(entries))
else:
rctx.file("manifest_tool_versions.bzl", "MANIFEST_ENTRIES = []\n")

return None

internal_config_repo = repository_rule(
Expand All @@ -139,8 +152,12 @@ internal_config_repo = repository_rule(
attrs = {
"transition_setting_generators": attr.string_list_dict(),
"transition_settings": attr.string_list(),
"workspace_mode": attr.bool(default = False),
},
)

def _bool_from_environ(rctx, key, default):
return bool(int(rctx.getenv(key, default)))

def _render_manifest_entries(entries):
return "MANIFEST_ENTRIES = {}\n".format(render.list(entries, value_repr = render.struct))
13 changes: 6 additions & 7 deletions python/private/pbs_manifest.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,15 @@ def parse_filename(filename):
"""
basename = filename.rpartition("/")[-1]
if basename.endswith(".tar.zst"):
name = basename.removesuffix(".tar.zst")
name = basename[:-8] # len(".tar.zst") == 8
elif basename.endswith(".tar.gz"):
name = basename.removesuffix(".tar.gz")
name = basename[:-7] # len(".tar.gz") == 7
else:
return None

if not name.startswith("cpython-"):
return None
name = name.removeprefix("cpython-")
name = name[8:] # len("cpython-") == 8

left, plus, tail = name.partition("+")
if plus:
Expand Down Expand Up @@ -101,8 +101,8 @@ def parse_filename(filename):
return {
"arch": arch,
"archive_flavor": archive_flavor,
"build_flavor": flavor,
"build_version": build_version,
"flavor": flavor,
"freethreaded": freethreaded,
"libc": libc,
"location": filename,
Expand All @@ -125,7 +125,7 @@ def parse_sha_manifest(content):
- archive_flavor: Release asset archive type (e.g., "full", "install_only").
- build_version: Standalone release date (e.g., "20260414").
- location: Full package filename or URL (e.g., "cpython-3.11.15..." or "https://...").
- flavor: Build configuration flavor (e.g., "install_only").
- build_flavor: Build configuration flavor (e.g., "debug", "pgo+lto").
- freethreaded: Whether the build is free-threaded (boolean).
- libc: C library type (e.g., "gnu", "musl", "msvc", or "").
- microarch: Microarchitecture level (e.g., "v2", "v3", or "").
Expand All @@ -137,13 +137,12 @@ def parse_sha_manifest(content):
results = []
for line in content.split("\n"):
line = line.strip()
if not line:
if not line or line.startswith("#"):
continue
parts = [p for p in line.split(" ") if p]
if len(parts) != 2:
continue
sha256, filename = parts

parsed = parse_filename(filename)
if parsed:
results.append(struct(
Expand Down
13 changes: 8 additions & 5 deletions python/private/print_toolchain_checksums.bzl
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
"""Print the toolchain versions.
"""

load("//python:versions.bzl", "TOOL_VERSIONS", "get_release_info")
load("@rules_python_internal//:manifest_tool_versions.bzl", "MANIFEST_ENTRIES")
load("//python:versions.bzl", "get_release_info", "tool_versions_from_manifest_entries")
load("//python/private:text_util.bzl", "render")
load("//python/private:version.bzl", "version")

Expand All @@ -12,11 +13,13 @@ def print_toolchains_checksums(name):
name: {type}`str`: the name of the runnable target.
"""
by_version = {}
tool_versions = tool_versions_from_manifest_entries(MANIFEST_ENTRIES)

for python_version, metadata in TOOL_VERSIONS.items():
for python_version, metadata in tool_versions.items():
by_version[python_version] = _commands_for_version(
python_version = python_version,
metadata = metadata,
tool_versions = tool_versions,
)

all_commands = sorted(
Expand Down Expand Up @@ -53,10 +56,10 @@ EOF
executable = True,
)

def _commands_for_version(*, python_version, metadata):
def _commands_for_version(*, python_version, metadata, tool_versions):
lines = []
first_platform = metadata["sha256"].keys()[0]
root, _, _ = get_release_info(first_platform, python_version)[1][0].rpartition("/")
root, _, _ = get_release_info(first_platform, python_version, tool_versions = tool_versions)[1][0].rpartition("/")
sha_url = "{}/{}".format(root, "SHA256SUMS")
prefix = metadata["strip_prefix"]
prefix = render.indent(
Expand All @@ -78,7 +81,7 @@ def _commands_for_version(*, python_version, metadata):
),
)
for platform in metadata["sha256"].keys()
for release_url in get_release_info(platform, python_version)[1]
for release_url in get_release_info(platform, python_version, tool_versions = tool_versions)[1]
] + [
" },",
" \"strip_prefix\": {strip_prefix},".format(strip_prefix = prefix),
Expand Down
1 change: 1 addition & 0 deletions python/private/py_repositories.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ def py_repositories(transition_settings = []):
internal_config_repo,
name = "rules_python_internal",
transition_settings = transition_settings,
workspace_mode = True,
)
maybe(
hub_repo,
Expand Down
Loading