Skip to content
Merged
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: 1 addition & 2 deletions .bazelrc
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,9 @@ common --disk_cache=~/.cache/bazel/bazel-disk-cache
common --repository_cache=~/.cache/bazel/bazel-repo-cache
# Hardlinks save disk space and copy time when unpacking repositories
common --experimental_repository_cache_hardlinks=true
import %workspace%/downloader_cfg.bazelrc
# 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

# BazelCI's default and RBE bzlmod jobs pass --config=ci; see
# .bazelci/presubmit.yml.
Expand Down
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ repos:
name: Sync downloader configs
language: system
entry: ./dev/sync_downloader_configs.py
files: downloader_config\.cfg$
files: (downloader_config\.cfg|downloader_cfg\.bazelrc)$
pass_filenames: false
- id: gazelle
name: Run Gazelle
Expand Down
1 change: 1 addition & 0 deletions BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ filegroup(
"MODULE.bazel",
"WORKSPACE",
"WORKSPACE.bzlmod",
"downloader_cfg.bazelrc",
"downloader_config.cfg",
"internal_dev_deps.bzl",
"internal_dev_setup.bzl",
Expand Down
41 changes: 26 additions & 15 deletions dev/sync_downloader_configs.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,26 @@
#!/usr/bin/env python3

"""Synchronizes downloader_config.cfg across subworkspaces.
"""Synchronizes Bazel downloader configuration files across subworkspaces.

Usage:
./dev/sync_downloader_configs.py

Copies the root `downloader_config.cfg` (Bazel downloader rewrite rules) to each
standalone module subworkspace and exits with status 1 if any file was updated.
Copies root downloader configuration files (Bazel downloader rewrite rules and
flags) to each standalone module subworkspace and exits with status 1 if any
file was updated.
"""

import sys
from pathlib import Path

# Config filenames relative to a module root directory.
_SYNCED_FILES = (
# keep-sorted start
"downloader_cfg.bazelrc",
"downloader_config.cfg",
# keep-sorted end
)

# Standalone module subworkspace paths relative to the repository root.
_SUBWORKSPACE_DIRS = (
# keep-sorted start
Expand All @@ -23,18 +32,20 @@

def main() -> None:
repo_root = Path(__file__).resolve().parent.parent
canonical = repo_root / "downloader_config.cfg"
canonical_content = canonical.read_text(encoding="utf-8")

changed = False
for rel_dir in _SUBWORKSPACE_DIRS:
sub = repo_root / rel_dir / "downloader_config.cfg"
if sub.read_text(encoding="utf-8") != canonical_content:
sub.write_text(canonical_content, encoding="utf-8")
print(f"Updated {sub.relative_to(repo_root)}")
changed = True

if changed:

updated: list[str] = []
for filename in _SYNCED_FILES:
canonical = repo_root / filename
canonical_content = canonical.read_text(encoding="utf-8")
for rel_dir in _SUBWORKSPACE_DIRS:
sub = repo_root / rel_dir / filename
if sub.read_text(encoding="utf-8") != canonical_content:
sub.write_text(canonical_content, encoding="utf-8")
updated.append(sub.relative_to(repo_root).as_posix())

if updated:
for rel_path in sorted(updated):
print(f"{rel_path}: out of sync (updated from root)")
sys.exit(1)


Expand Down
6 changes: 6 additions & 0 deletions downloader_cfg.bazelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Mitigate transient CI network failures via increased HTTP timeouts and retries.
# Note: --experimental_downloader_config is set per workspace depth because
# Bazel 10+ treats --downloader_config as allowMultiple=true (accumulating all
# passed paths) and resolves relative paths against the active workspace root.
common --http_timeout_scaling=10.0
common --experimental_repository_downloader_retries=10
5 changes: 1 addition & 4 deletions examples/build_file_generation/.bazelrc
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,4 @@ common --noenable_bzlmod
common --enable_workspace
common --incompatible_python_disallow_native_rules
common --incompatible_default_to_explicit_init_py
# Mitigate transient CI network failures via mirror fallback and retries.
common --experimental_downloader_config=../../downloader_config.cfg
common --http_timeout_scaling=10.0
common --experimental_repository_downloader_retries=10
import %workspace%/../downloader_cfg.bazelrc
5 changes: 1 addition & 4 deletions examples/bzlmod/.bazelrc
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,4 @@ test --test_output=errors --enable_runfiles
# Windows requires these for multi-python support:
build --enable_runfiles
common:bazel7.x --incompatible_python_disallow_native_rules
# Mitigate transient CI network failures via mirror fallback and retries.
common --experimental_downloader_config=../../downloader_config.cfg
common --http_timeout_scaling=10.0
common --experimental_repository_downloader_retries=10
import %workspace%/../downloader_cfg.bazelrc
4 changes: 4 additions & 0 deletions examples/downloader_cfg.bazelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import %workspace%/../../downloader_cfg.bazelrc
# Bazel resolves --experimental_downloader_config relative to the active
# workspace directory rather than the imported .bazelrc file's directory.
common --experimental_downloader_config=../../downloader_config.cfg
5 changes: 1 addition & 4 deletions examples/multi_python_versions/.bazelrc
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,4 @@ build --enable_runfiles

coverage --java_runtime_version=remotejdk_11
common:bazel7.x --incompatible_python_disallow_native_rules
# Mitigate transient CI network failures via mirror fallback and retries.
common --experimental_downloader_config=../../downloader_config.cfg
common --http_timeout_scaling=10.0
common --experimental_repository_downloader_retries=10
import %workspace%/../downloader_cfg.bazelrc
5 changes: 1 addition & 4 deletions examples/pip_parse/.bazelrc
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
common --incompatible_python_disallow_native_rules
# Mitigate transient CI network failures via mirror fallback and retries.
common --experimental_downloader_config=../../downloader_config.cfg
common --http_timeout_scaling=10.0
common --experimental_repository_downloader_retries=10
import %workspace%/../downloader_cfg.bazelrc

# https://docs.bazel.build/versions/main/best-practices.html#using-the-bazelrc-file
try-import %workspace%/user.bazelrc
5 changes: 1 addition & 4 deletions examples/pip_parse_vendored/.bazelrc
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,4 @@ build --enable_runfiles
common --noenable_bzlmod
common --enable_workspace
common --incompatible_python_disallow_native_rules
# Mitigate transient CI network failures via mirror fallback and retries.
common --experimental_downloader_config=../../downloader_config.cfg
common --http_timeout_scaling=10.0
common --experimental_repository_downloader_retries=10
import %workspace%/../downloader_cfg.bazelrc
3 changes: 1 addition & 2 deletions gazelle/.bazelrc
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
common --deleted_packages=examples/bzlmod_build_file_generation
common --deleted_packages=examples/bzlmod_build_file_generation/runfiles
import %workspace%/downloader_cfg.bazelrc
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
6 changes: 6 additions & 0 deletions gazelle/downloader_cfg.bazelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Mitigate transient CI network failures via increased HTTP timeouts and retries.
# Note: --experimental_downloader_config is set per workspace depth because
# Bazel 10+ treats --downloader_config as allowMultiple=true (accumulating all
# passed paths) and resolves relative paths against the active workspace root.
common --http_timeout_scaling=10.0
common --experimental_repository_downloader_retries=10
4 changes: 1 addition & 3 deletions gazelle/examples/bzlmod_build_file_generation/.bazelrc
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,5 @@ common:bazel7.x --incompatible_python_disallow_native_rules
# and the bazel_dep version of rules_python is used.
common --override_module=rules_python=../../../

# Mitigate transient CI network failures via mirror fallback and retries.
import %workspace%/../../downloader_cfg.bazelrc
common --experimental_downloader_config=../../downloader_config.cfg
common --http_timeout_scaling=10.0
common --experimental_repository_downloader_retries=10
3 changes: 1 addition & 2 deletions sphinxdocs/.bazelrc
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,8 @@ build --enable_runfiles

# Local disk cache greatly speeds up builds if the regular cache is lost
common --disk_cache=~/.cache/bazel/bazel-disk-cache
import %workspace%/downloader_cfg.bazelrc
common --experimental_downloader_config=downloader_config.cfg
common --http_timeout_scaling=10.0
common --experimental_repository_downloader_retries=10

common --incompatible_python_disallow_native_rules
common --incompatible_no_implicit_file_export
Expand Down
6 changes: 6 additions & 0 deletions sphinxdocs/downloader_cfg.bazelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Mitigate transient CI network failures via increased HTTP timeouts and retries.
# Note: --experimental_downloader_config is set per workspace depth because
# Bazel 10+ treats --downloader_config as allowMultiple=true (accumulating all
# passed paths) and resolves relative paths against the active workspace root.
common --http_timeout_scaling=10.0
common --experimental_repository_downloader_retries=10
4 changes: 1 addition & 3 deletions sphinxdocs/integration_tests/bcr/.bazelrc
Original file line number Diff line number Diff line change
@@ -1,4 +1,2 @@
# Mitigate transient CI network failures via mirror fallback and retries.
import %workspace%/../../downloader_cfg.bazelrc
common --experimental_downloader_config=../../downloader_config.cfg
common --http_timeout_scaling=10.0
common --experimental_repository_downloader_retries=10
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
# directly to the running persistent worker instead of restoring pre-built HTML cache results across test steps.
common --disk_cache=
build --noremote_accept_cached
common --http_timeout_scaling=10.0
common --experimental_repository_downloader_retries=10
import %workspace%/../../../downloader_cfg.bazelrc
common --experimental_downloader_config=../../../downloader_config.cfg
common --lockfile_mode=off
5 changes: 1 addition & 4 deletions tests/integration/bzlmod_lockfile/.bazelrc
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,7 @@ build --enable_runfiles
common --lockfile_mode=error

common --experimental_isolated_extension_usages
# Mitigate transient CI network failures via mirror fallback and retries.
common --experimental_downloader_config=../../../downloader_config.cfg
common --http_timeout_scaling=10.0
common --experimental_repository_downloader_retries=10
import %workspace%/../downloader_cfg.bazelrc

# https://docs.bazel.build/versions/main/best-practices.html#using-the-bazelrc-file
try-import %workspace%/user.bazelrc
5 changes: 1 addition & 4 deletions tests/integration/compile_pip_requirements/.bazelrc
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,4 @@ test --test_output=errors
# Windows requires these for multi-python support:
build --enable_runfiles
common:bazel7.x --incompatible_python_disallow_native_rules
# Mitigate transient CI network failures via mirror fallback and retries.
common --experimental_downloader_config=../../../downloader_config.cfg
common --http_timeout_scaling=10.0
common --experimental_repository_downloader_retries=10
import %workspace%/../downloader_cfg.bazelrc
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
test --test_output=errors
common:bazel7.x --incompatible_python_disallow_native_rules
# Mitigate transient CI network failures via mirror fallback and retries.
common --experimental_downloader_config=../../../downloader_config.cfg
common --http_timeout_scaling=10.0
common --experimental_repository_downloader_retries=10
import %workspace%/../downloader_cfg.bazelrc
5 changes: 1 addition & 4 deletions tests/integration/custom_commands/.bazelrc
Original file line number Diff line number Diff line change
@@ -1,4 +1 @@
# Mitigate transient CI network failures via mirror fallback and retries.
common --experimental_downloader_config=../../../downloader_config.cfg
common --http_timeout_scaling=10.0
common --experimental_repository_downloader_retries=10
import %workspace%/../downloader_cfg.bazelrc
4 changes: 4 additions & 0 deletions tests/integration/downloader_cfg.bazelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import %workspace%/../../../downloader_cfg.bazelrc
# Bazel resolves --experimental_downloader_config relative to the active
# workspace directory rather than the imported .bazelrc file's directory.
common --experimental_downloader_config=../../../downloader_config.cfg
1 change: 1 addition & 0 deletions tests/integration/integration_test.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ def rules_python_integration_test(
native.filegroup(
name = name + "_workspace_files",
srcs = workspace_files + [
"downloader_cfg.bazelrc",
"//:distribution",
],
)
Expand Down
5 changes: 1 addition & 4 deletions tests/integration/local_toolchains/.bazelrc
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,4 @@ build --enable_runfiles
common:bazel7.x --incompatible_python_disallow_native_rules
build --//:py=local
common --announce_rc
# Mitigate transient CI network failures via mirror fallback and retries.
common --experimental_downloader_config=../../../downloader_config.cfg
common --http_timeout_scaling=10.0
common --experimental_repository_downloader_retries=10
import %workspace%/../downloader_cfg.bazelrc
5 changes: 1 addition & 4 deletions tests/integration/pip_parse/.bazelrc
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,7 @@

build --enable_runfiles
common:bazel7.x --incompatible_python_disallow_native_rules
# Mitigate transient CI network failures via mirror fallback and retries.
common --experimental_downloader_config=../../../downloader_config.cfg
common --http_timeout_scaling=10.0
common --experimental_repository_downloader_retries=10
import %workspace%/../downloader_cfg.bazelrc

# https://docs.bazel.build/versions/main/best-practices.html#using-the-bazelrc-file
try-import %workspace%/user.bazelrc
5 changes: 1 addition & 4 deletions tests/integration/pip_parse_isolated/.bazelrc
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,7 @@
build --enable_runfiles

common --experimental_isolated_extension_usages
# Mitigate transient CI network failures via mirror fallback and retries.
common --experimental_downloader_config=../../../downloader_config.cfg
common --http_timeout_scaling=10.0
common --experimental_repository_downloader_retries=10
import %workspace%/../downloader_cfg.bazelrc

# https://docs.bazel.build/versions/main/best-practices.html#using-the-bazelrc-file
try-import %workspace%/user.bazelrc
5 changes: 1 addition & 4 deletions tests/integration/prebuilt_toolchain/.bazelrc
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
common --lockfile_mode=off
test --test_output=errors
build --enable_runfiles
# Mitigate transient CI network failures via mirror fallback and retries.
common --experimental_downloader_config=../../../downloader_config.cfg
common --http_timeout_scaling=10.0
common --experimental_repository_downloader_retries=10
import %workspace%/../downloader_cfg.bazelrc
5 changes: 1 addition & 4 deletions tests/integration/py_cc_toolchain_registered/.bazelrc
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
# This aids debugging on failure
build --toolchain_resolution_debug=python
common:bazel7.x --incompatible_python_disallow_native_rules
# Mitigate transient CI network failures via mirror fallback and retries.
common --experimental_downloader_config=../../../downloader_config.cfg
common --http_timeout_scaling=10.0
common --experimental_repository_downloader_retries=10
import %workspace%/../downloader_cfg.bazelrc
5 changes: 1 addition & 4 deletions tests/integration/runtime_manifests/.bazelrc
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,4 @@
common:fast-tests --build_tests_only=true
common:fast-tests --build_tag_filters=-large,-enormous,-integration-test
common:fast-tests --test_tag_filters=-large,-enormous,-integration-test
# Mitigate transient CI network failures via mirror fallback and retries.
common --experimental_downloader_config=../../../downloader_config.cfg
common --http_timeout_scaling=10.0
common --experimental_repository_downloader_retries=10
import %workspace%/../downloader_cfg.bazelrc
5 changes: 1 addition & 4 deletions tests/integration/toolchain_target_settings/.bazelrc
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
common --lockfile_mode=off
test --test_output=errors
build --enable_runfiles
# Mitigate transient CI network failures via mirror fallback and retries.
common --experimental_downloader_config=../../../downloader_config.cfg
common --http_timeout_scaling=10.0
common --experimental_repository_downloader_retries=10
import %workspace%/../downloader_cfg.bazelrc
5 changes: 1 addition & 4 deletions tests/integration/unified_pypi/.bazelrc
Original file line number Diff line number Diff line change
@@ -1,5 +1,2 @@
common --experimental_enable_bzlmod
# Mitigate transient CI network failures via mirror fallback and retries.
common --experimental_downloader_config=../../../downloader_config.cfg
common --http_timeout_scaling=10.0
common --experimental_repository_downloader_retries=10
import %workspace%/../downloader_cfg.bazelrc
5 changes: 1 addition & 4 deletions tests/integration/uv_lock/.bazelrc
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
build --enable_runfiles
common --experimental_isolated_extension_usages
common --action_env=UV_EXTRA_INDEX_URL
# Mitigate transient CI network failures via mirror fallback and retries.
common --experimental_downloader_config=../../../downloader_config.cfg
common --http_timeout_scaling=10.0
common --experimental_repository_downloader_retries=10
import %workspace%/../downloader_cfg.bazelrc

try-import %workspace%/user.bazelrc
5 changes: 1 addition & 4 deletions tests/integration/validate_test_main/.bazelrc
Original file line number Diff line number Diff line change
@@ -1,4 +1 @@
# Mitigate transient CI network failures via mirror fallback and retries.
common --experimental_downloader_config=../../../downloader_config.cfg
common --http_timeout_scaling=10.0
common --experimental_repository_downloader_retries=10
import %workspace%/../downloader_cfg.bazelrc
5 changes: 1 addition & 4 deletions tests/integration/whl_library/.bazelrc
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
common --incompatible_default_to_explicit_init_py
test --test_output=errors
# Mitigate transient CI network failures via mirror fallback and retries.
common --experimental_downloader_config=../../../downloader_config.cfg
common --http_timeout_scaling=10.0
common --experimental_repository_downloader_retries=10
import %workspace%/../downloader_cfg.bazelrc
Loading