diff --git a/.agents/rules/rules_python.md b/.agents/rules/rules_python.md index 0659b0ba67..96cf90c98e 100644 --- a/.agents/rules/rules_python.md +++ b/.agents/rules/rules_python.md @@ -17,10 +17,11 @@ description: rules_python-specific Bzlmod, PyPI, and rule usage invariants to the same name). ## Minimum Supported Bazel Version -* `//:version.bzl` defines `MINIMUM_BAZEL_VERSION`. Do not add compatibility - logic, feature guards, or comments for older Bazel versions. -* When guarding a feature added after `MINIMUM_BAZEL_VERSION`, verify and - comment the exact Bazel version that introduced it. +* The minimum supported Bazel version is the `bazel` version of + `.minimum_supported_version` in `.bazelci/presubmit.yml`. Do not add + compatibility logic, feature guards, or comments for older Bazel versions. +* When guarding a feature added after the minimum supported Bazel version, + verify and comment the exact Bazel version that introduced it. ## Internal Labels & Helpers * **Toolchain Type Labels**: Define toolchain type constants in diff --git a/.agents/skills/review-code/SKILL.md b/.agents/skills/review-code/SKILL.md index 36f4f3effd..40f446c7c8 100644 --- a/.agents/skills/review-code/SKILL.md +++ b/.agents/skills/review-code/SKILL.md @@ -68,7 +68,7 @@ file from `.agents/skills/review-code/`: - Prompt file: `.agents/skills/review-code/review-rules-python-prompt.md` - Focus: Audits changes against `.agents/rules/rules_python.md` (e.g., - `pip.dep()` declarations in `MODULE.bazel` and `MINIMUM_BAZEL_VERSION` + `pip.dep()` declarations in `MODULE.bazel` and minimum Bazel version bounds). 9. **News Entry Sub-Agent** (`Role: "News Entry Auditor"`): diff --git a/.agents/skills/review-code/review-rules-python-prompt.md b/.agents/skills/review-code/review-rules-python-prompt.md index 8d22ffa7ed..6a06c8fe00 100644 --- a/.agents/skills/review-code/review-rules-python-prompt.md +++ b/.agents/skills/review-code/review-rules-python-prompt.md @@ -2,14 +2,14 @@ You are a specialized `rules_python` Usage Auditor sub-agent. Your sole task is to audit all changes in `git diff` against `rules_python` Bzlmod, Bazel version support, and rule usage invariants: -1. Read and strictly enforce `.agents/rules/rules_python.md`, `version.bzl`, and - `AGENTS.md`. +1. Read and strictly enforce `.agents/rules/rules_python.md` and `AGENTS.md`. 2. Verify that every `@pypi//` target referenced by non-test rules, macros, or `BUILD` files under `python/**` (including default attribute values and `alias` targets) has a corresponding `pip.dep(name = "")` declaration on the non-dev `pip` extension in `MODULE.bazel` (with `"pypi"` in `use_repo(pip, ...)`). 3. Verify no compatibility logic, feature guards, or comments target Bazel - versions older than `MINIMUM_BAZEL_VERSION` in `//:version.bzl`. + versions older than the minimum supported Bazel version in + `.bazelci/presubmit.yml`. @.agents/skills/review-code/review-report-format.md diff --git a/.agents/skills/review-code/review-starlark-prompt.md b/.agents/skills/review-code/review-starlark-prompt.md index a8fd4144e6..47450dc82d 100644 --- a/.agents/skills/review-code/review-starlark-prompt.md +++ b/.agents/skills/review-code/review-starlark-prompt.md @@ -26,7 +26,8 @@ in `git diff` against the project's Starlark coding rules and conventions: 10. Verify non-obvious workarounds have comments stating the intent, why the direct approach fails, and why the workaround works. 11. Verify no compatibility logic or feature guards target Bazel versions - older than `MINIMUM_BAZEL_VERSION` in `//:version.bzl`. + older than the minimum supported Bazel version in + `.bazelci/presubmit.yml`. 12. Inspect the full `BUILD` file (not just the diff hunk) to flag overlapping or redundant `filegroup`, `exports_files`, or `glob(...)` definitions, and flag top-level target-instantiation ternaries (`rule_a(...) if cond else diff --git a/.bazelci/presubmit.yml b/.bazelci/presubmit.yml index 04207127ce..2f7bdd96ed 100644 --- a/.bazelci/presubmit.yml +++ b/.bazelci/presubmit.yml @@ -20,12 +20,10 @@ buildifier: warnings: "all" # LINT.ThenChange(//.pre-commit-config.yaml:buildifier) # NOTE: Minimum supported version is 7.x -# LINT.IfChange(minimum_supported_version) .minimum_supported_version: &minimum_supported_version # For testing minimum supported version. bazel: 7.x skip_in_bazel_downstream_pipeline: "Bazel 7 required" -# LINT.ThenChange(//version.bzl:minimum_bazel_version) .reusable_config: &reusable_config # USE_BAZEL_DIFF is disabled because target_compatible_with is used heavily, # but BazelCI's bazel-diff integration errors when handling them. diff --git a/AGENTS.md b/AGENTS.md index 118bb366d0..f33bc53d4b 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -204,8 +204,9 @@ This repository contains 3 Bazel bzlmod modules. public API. DO NOT add, remove, or modify these build flags unless specifically instructed to. -`version.bzl` defines `MINIMUM_BAZEL_VERSION`. Do not add compatibility logic -or feature guards for Bazel versions older than `MINIMUM_BAZEL_VERSION`. +The minimum supported Bazel version is the `bazel` version of +`.minimum_supported_version` in `.bazelci/presubmit.yml`. Do not add +compatibility logic or feature guards for older Bazel versions. `bazel query --output=build` can be used to inspect target definitions. diff --git a/BUILD.bazel b/BUILD.bazel index 9d3de9f800..4af734601c 100644 --- a/BUILD.bazel +++ b/BUILD.bazel @@ -12,8 +12,6 @@ # See the License for the specific language governing permissions and # limitations under the License. -load("@bazel_skylib//:bzl_library.bzl", "bzl_library") - # Resolve rules_cc Starlark libraries to their correct targets # gazelle:resolve starlark @rules_cc//cc/common:cc_info.bzl @rules_cc//cc/common:common # gazelle:resolve starlark @rules_cc//cc/common:cc_common.bzl @rules_cc//cc/common:common @@ -56,7 +54,6 @@ licenses(["notice"]) exports_files([ ".clippy.toml", "LICENSE", - "version.bzl", ]) exports_files( @@ -108,7 +105,6 @@ filegroup( "WORKSPACE.bzlmod", "internal_dev_deps.bzl", "internal_dev_setup.bzl", - "version.bzl", ":downloader_configs", "//command_line_option:distribution", "//crates:distribution", @@ -131,11 +127,4 @@ filegroup( visibility = ["//visibility:public"], ) -# keep -bzl_library( - name = "version", - srcs = ["version.bzl"], - visibility = ["//:__subpackages__"], -) - # No-op change to verify PR metadata checks diff --git a/MODULE.bazel b/MODULE.bazel index b7301c7291..7d5ade079c 100644 --- a/MODULE.bazel +++ b/MODULE.bazel @@ -494,7 +494,7 @@ use_repo( # "build_bazel_bazel_rolling", "build_bazel_bazel_self", ) -# LINT.ThenChange(//version.bzl:supported_bazel_versions) +# LINT.ThenChange(//internal_dev_setup.bzl:workspace_bazel_binaries) # TODO @aignas 2025-01-27: should this be moved to `//python/extensions:uv.bzl` or should # it stay as it is? I think I may prefer to move it. diff --git a/internal_dev_setup.bzl b/internal_dev_setup.bzl index 0bbcd97748..9d7fd5998f 100644 --- a/internal_dev_setup.bzl +++ b/internal_dev_setup.bzl @@ -21,7 +21,6 @@ load("@com_google_protobuf//:protobuf_deps.bzl", "protobuf_deps") load("@rules_bazel_integration_test//bazel_integration_test:deps.bzl", "bazel_integration_test_rules_dependencies") load("@rules_bazel_integration_test//bazel_integration_test:repo_defs.bzl", "bazel_binaries") load("@rules_shell//shell:repositories.bzl", "rules_shell_dependencies", "rules_shell_toolchains") -load("//:version.bzl", "SUPPORTED_BAZEL_VERSIONS") load("//python:versions.bzl", "MINOR_MAPPING", "TOOL_VERSIONS") load("//python/private:pythons_hub.bzl", "hub_repo") # buildifier: disable=bzl-visibility load("//python/private:runtime_env_repo.bzl", "runtime_env_repo") # buildifier: disable=bzl-visibility @@ -57,7 +56,14 @@ def rules_python_internal_setup(): bazel_integration_test_rules_dependencies() bazel_starlib_dependencies() - bazel_binaries(versions = SUPPORTED_BAZEL_VERSIONS) + + # The integration tests are not run in the WORKSPACE builds of this repo, + # this is only needed for loading their BUILD files. Bazel 9 and later + # ignore the WORKSPACE files. + # LINT.IfChange(workspace_bazel_binaries) + bazel_binaries(versions = ["7.7.0", "8.5.1"]) + + # LINT.ThenChange(//MODULE.bazel:bazel_binaries) bazel_features_deps() rules_shell_dependencies() rules_shell_toolchains() diff --git a/version.bzl b/version.bzl deleted file mode 100644 index d48f48b4e7..0000000000 --- a/version.bzl +++ /dev/null @@ -1,40 +0,0 @@ -# Copyright 2019 The Bazel Authors. All rights reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -"""Versions of rules_python dependencies.""" - -# Currently used Bazel version. This version is what the rules here are tested -# against. -# LINT.IfChange(bazel_version) -BAZEL_VERSION = "8.x" -# LINT.ThenChange(//.bazelversion) - -# This is the minimum supported bazel version, that we have some tests for. -# LINT.IfChange(minimum_bazel_version) -MINIMUM_BAZEL_VERSION = "7.4.1" -# LINT.ThenChange(//.bazelci/presubmit.yml:minimum_supported_version) - -# Versions of Bazel which users should be able to use. -# Ensures we don't break backwards-compatibility, -# accidentally forcing users to update their LTS-supported bazel. -# These are the versions used when testing nested workspaces with -# rules_bazel_integration_test. -# LINT.IfChange(supported_bazel_versions) -SUPPORTED_BAZEL_VERSIONS = [ - BAZEL_VERSION, - MINIMUM_BAZEL_VERSION, -] -# LINT.ThenChange(//MODULE.bazel:bazel_binaries) - -def bazel_version_to_binary_label(version): - return "@build_bazel_bazel_%s//:bazel_binary" % version.replace(".", "_")