Skip to content

Upgrade to Bazel 7.7.0, rules_python 1.0.0, and protobuf 29.5#47

Draft
rjhuijsman wants to merge 3 commits intomainfrom
rjh.bazel7
Draft

Upgrade to Bazel 7.7.0, rules_python 1.0.0, and protobuf 29.5#47
rjhuijsman wants to merge 3 commits intomainfrom
rjh.bazel7

Conversation

@rjhuijsman
Copy link
Contributor

Summary

This PR upgrades the Bazel build to Bazel 7.7.0 as part of a coordinated
upgrade across the entire monorepo. It also upgrades rules_python from
0.27.0 to 1.0.0 and protobuf from an older version to 29.5.

Why things had to change

Bazel 7.7.0 (.bazeliskrc)

Bumped USE_BAZEL_VERSION from 5.4.1 to 7.7.0.

bzlmod disabled (.bazelrc)

Bazel 7 enables bzlmod by default. Added common --enable_bzlmod=false
to keep the existing WORKSPACE-based build working until the project
is ready to migrate to MODULE.bazel.

repo_mapping parameter removed (bazel/repos.bzl, bazel/deps.bzl, bazel/py_toolchains.bzl)

Bazel 7 removed the repo_mapping parameter from repository rules
(http_archive, git_repository, etc.). All explicit repo_mapping = {}
arguments have been removed.

native.existing_rules() deprecated; external parameter removed (bazel/repos.bzl, WORKSPACE.bazel)

Bazel 7 deprecates native.existing_rules(). The pattern of accepting
an external parameter to conditionally register the repo's own
git_repository (so downstream consumers could pull it in) is replaced
throughout with maybe() from @bazel_tools//tools/build_defs/repo:utils.bzl,
which already skips registration if the repo already exists.

rules_python 1.0.0 (bazel/repos.bzl, bazel/pypi_repos.bzl)

Upgraded from 0.27.0 to 1.0.0, required by protobuf 29.x which loads
rules_python internally. In 1.0.0, the @python3_10_12//:defs.bzl
interpreter symbol no longer exists; it is replaced by the label string
"@python3_10_12_host//:python".

protobuf 29.5 (bazel/repos.bzl)

Upgraded to protobuf 29.5 (switching from a git_repository to a more
reproducible http_archive). This required downstream changes:

  • rules.bzl: ProtoInfo moved from @rules_proto//proto:defs.bzl
    to @com_google_protobuf//bazel/common:proto_info.bzl. Also fixed a
    latent output-directory bug exposed by Bazel 7: output_files[0].path
    for directory-typed outputs already includes the workspace root for
    external repos, so the old code that appended workspace_root again
    was doubling the path and breaking protoc invocations when this rule
    is consumed from an external workspace.
  • tests/python/BUILD.bazel: py_proto_library moved to
    @com_google_protobuf//bazel:py_proto_library.bzl; attribute renamed
    from srcs to deps.
  • tests/cpp/BUILD.bazel: cc_proto_library moved to
    @com_google_protobuf//bazel:cc_proto_library.bzl.
  • requirements.in / requirements_lock.txt: The Python protobuf
    runtime must match the gencode version. Protobuf 29.5 produces gencode
    for runtime >=5.29.5; the old >=3 lower bound caused a
    VersionError at import time.

Test plan

  • bazel test //... in this repo passes
  • bazel test //... in the monorepo passes (consumes this as a submodule)
  • PR for dependent repos (stout, public, mono) is also merged

Bazel 7 introduces several breaking changes that required updates:

- `.bazeliskrc`: Bump version from 5.4.1 to 7.7.0.

- `.bazelrc`: Add `common --enable_bzlmod=false`. Bazel 7 enables
  bzlmod by default; disabling it keeps the WORKSPACE-based build
  working until we are ready to migrate to MODULE.bazel.

- `WORKSPACE.bazel`: Remove the `external = False` argument from
  `repos()`. This parameter no longer exists (see repos.bzl below).

- `bazel/repos.bzl`: Bazel 7 removes the `repo_mapping` parameter
  from repository rules (`http_archive`, `git_repository`, etc.),
  so all explicit `repo_mapping = {}` arguments are removed.
  `native.existing_rules()` is deprecated in Bazel 7; the
  conditional self-registration pattern (`if external:`) is replaced
  throughout with `maybe()` from `@bazel_tools`. `rules_python` is
  upgraded from 0.27.0 to 1.0.0 (required by protobuf 29.x). The
  `com_google_protobuf` `git_repository` is replaced with an
  `http_archive` for protobuf 29.5 (better reproducibility and
  avoids git fetch overhead).

- `bazel/deps.bzl`, `bazel/py_toolchains.bzl`: Remove `repo_mapping`
  parameter (no longer accepted by the called functions).

- `bazel/pypi_repos.bzl`: rules_python 1.0.0 removed the
  `@python3_10_12//:defs.bzl` `interpreter` symbol. Replace with
  the `"@python3_10_12_host//:python"` label string.

- `rules.bzl`: Update `ProtoInfo` import from
  `@rules_proto//proto:defs.bzl` to
  `@com_google_protobuf//bazel/common:proto_info.bzl` (moved in
  protobuf 29.x). Also fix a latent output-directory bug: in Bazel 7,
  `output_files[0].path` for directory-typed outputs already includes
  the workspace root for external repos; the old code appended it a
  second time, doubling the path and breaking protoc invocations when
  this rule is used from an external consumer.

- `tests/python/BUILD.bazel`: protobuf 29.x moved `py_proto_library`
  to `@com_google_protobuf//bazel:py_proto_library.bzl` and changed
  the attribute from `srcs` to `deps`.

- `tests/cpp/BUILD.bazel`: protobuf 29.x moved `cc_proto_library` to
  `@com_google_protobuf//bazel:cc_proto_library.bzl`.

- `requirements.in`, `requirements_lock.txt`: Bump the minimum
  protobuf Python runtime from `>=3` to `>=5.29.5` to match the
  gencode version produced by protobuf 29.5, and regenerate the
  lock file accordingly.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@aviator-app
Copy link

aviator-app bot commented Mar 24, 2026

Current Aviator status

Aviator will automatically update this comment as the status of the PR changes.
Comment /aviator refresh to force Aviator to re-examine your PR (or learn about other /aviator commands).

This pull request is currently open (not queued).

How to merge

To merge this PR, comment /aviator merge or add the mergequeue-ready label.


See the real-time status of this PR on the Aviator webapp.
Use the Aviator Chrome Extension to see the status of your PR within GitHub.

rjhuijsman and others added 2 commits March 24, 2026 09:49
Trailing comma in multi-line function call required by buildifier.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
On resource-constrained CI runners (e.g., macOS arm64), the default
600s timeout for whl_library extraction may be insufficient when
running concurrently with intensive C++ compilation. Increase to
1800s to avoid spurious timeouts.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant