From cc5d692dfcd86dc091cc3deda7608b758a4586a1 Mon Sep 17 00:00:00 2001 From: Ignas Anikevicius <240938+aignas@users.noreply.github.com> Date: Fri, 21 Nov 2025 08:55:19 +0900 Subject: [PATCH 01/14] stop chmoding --- python/private/python_repository.bzl | 7 ------- 1 file changed, 7 deletions(-) diff --git a/python/private/python_repository.bzl b/python/private/python_repository.bzl index cb0731e6eb..f79b3bc74f 100644 --- a/python/private/python_repository.bzl +++ b/python/private/python_repository.bzl @@ -130,13 +130,6 @@ def _python_repository_impl(rctx): # # Note, when on Windows the `chmod` may not work if "windows" not in platform and "windows" != repo_utils.get_platforms_os_name(rctx): - repo_utils.execute_checked( - rctx, - op = "python_repository.MakeReadOnly", - arguments = [repo_utils.which_checked(rctx, "chmod"), "-R", "ugo-w", "lib"], - logger = logger, - ) - # If the user is not ignoring the warnings, then proceed to run a check, # otherwise these steps can be skipped, as they both result in some warning. if not rctx.attr.ignore_root_user_error: From 788b358224edad15fcb7abd241674265088f7fae Mon Sep 17 00:00:00 2001 From: Ignas Anikevicius <240938+aignas@users.noreply.github.com> Date: Fri, 21 Nov 2025 08:56:51 +0900 Subject: [PATCH 02/14] make ignore_root_user_error noop in python_repository --- python/private/python_repository.bzl | 55 +++++----------------------- 1 file changed, 10 insertions(+), 45 deletions(-) diff --git a/python/private/python_repository.bzl b/python/private/python_repository.bzl index f79b3bc74f..16c522f398 100644 --- a/python/private/python_repository.bzl +++ b/python/private/python_repository.bzl @@ -123,38 +123,6 @@ def _python_repository_impl(rctx): logger = logger, ) - # Make the Python installation read-only. This is to prevent issues due to - # pycs being generated at runtime: - # * The pycs are not deterministic (they contain timestamps) - # * Multiple processes trying to write the same pycs can result in errors. - # - # Note, when on Windows the `chmod` may not work - if "windows" not in platform and "windows" != repo_utils.get_platforms_os_name(rctx): - # If the user is not ignoring the warnings, then proceed to run a check, - # otherwise these steps can be skipped, as they both result in some warning. - if not rctx.attr.ignore_root_user_error: - exec_result = repo_utils.execute_unchecked( - rctx, - op = "python_repository.TestReadOnly", - arguments = [repo_utils.which_checked(rctx, "touch"), "lib/.test"], - logger = logger, - ) - - # The issue with running as root is the installation is no longer - # read-only, so the problems due to pyc can resurface. - if exec_result.return_code == 0: - stdout = repo_utils.execute_checked_stdout( - rctx, - op = "python_repository.GetUserId", - arguments = [repo_utils.which_checked(rctx, "id"), "-u"], - logger = logger, - ) - uid = int(stdout.strip()) - if uid == 0: - logger.warn("The current user is root, which can cause spurious cache misses or build failures with the hermetic Python interpreter. See https://github.com/bazel-contrib/rules_python/pull/713.") - else: - logger.warn("The current user has CAP_DAC_OVERRIDE set, which can cause spurious cache misses or build failures with the hermetic Python interpreter. See https://github.com/bazel-contrib/rules_python/pull/713.") - python_bin = "python.exe" if ("windows" in platform) else "bin/python3" if "linux" in platform: @@ -179,17 +147,15 @@ def _python_repository_impl(rctx): break glob_include = [] - glob_exclude = [] - if rctx.attr.ignore_root_user_error or "windows" in platform: - glob_exclude += [ - # These pycache files are created on first use of the associated python files. - # Exclude them from the glob because otherwise between the first time and second time a python toolchain is used," - # the definition of this filegroup will change, and depending rules will get invalidated." - # See https://github.com/bazel-contrib/rules_python/issues/1008 for unconditionally adding these to toolchains so we can stop ignoring them." - # pyc* is ignored because pyc creation creates temporary .pyc.NNNN files - "**/__pycache__/*.pyc*", - "**/__pycache__/*.pyo*", - ] + glob_exclude = [ + # These pycache files are created on first use of the associated python files. + # Exclude them from the glob because otherwise between the first time and second time a python toolchain is used," + # the definition of this filegroup will change, and depending rules will get invalidated." + # See https://github.com/bazel-contrib/rules_python/issues/1008 for unconditionally adding these to toolchains so we can stop ignoring them." + # pyc* is ignored because pyc creation creates temporary .pyc.NNNN files + "**/__pycache__/*.pyc*", + "**/__pycache__/*.pyo*", + ] if "windows" in platform: glob_include += [ @@ -242,7 +208,6 @@ define_hermetic_runtime_toolchain_impl( "coverage_tool": rctx.attr.coverage_tool, "distutils": rctx.attr.distutils, "distutils_content": rctx.attr.distutils_content, - "ignore_root_user_error": rctx.attr.ignore_root_user_error, "name": rctx.attr.name, "netrc": rctx.attr.netrc, "patch_strip": rctx.attr.patch_strip, @@ -292,7 +257,7 @@ For more information see {attr}`py_runtime.coverage_tool`. ), "ignore_root_user_error": attr.bool( default = True, - doc = "Whether the check for root should be ignored or not. This causes cache misses with .pyc files.", + doc = "Noop, will be removed in the next major release", mandatory = False, ), "netrc": attr.string( From fe08b6a725dacb7ca77505f774133f09f116b703 Mon Sep 17 00:00:00 2001 From: Ignas Anikevicius <240938+aignas@users.noreply.github.com> Date: Fri, 21 Nov 2025 09:00:18 +0900 Subject: [PATCH 03/14] remove ignore_root from the python extension --- python/private/python.bzl | 34 ++------------- tests/python/python_tests.bzl | 79 +---------------------------------- 2 files changed, 5 insertions(+), 108 deletions(-) diff --git a/python/private/python.bzl b/python/private/python.bzl index a1fe80e0ce..613bf36efe 100644 --- a/python/private/python.bzl +++ b/python/private/python.bzl @@ -76,13 +76,6 @@ def parse_modules(*, module_ctx, logger, _fail = fail): # Map of string Major.Minor or Major.Minor.Patch to the toolchain_info struct global_toolchain_versions = {} - ignore_root_user_error = None - - # if the root module does not register any toolchain then the - # ignore_root_user_error takes its default value: True - if not module_ctx.modules[0].tags.toolchain: - ignore_root_user_error = True - config = _get_toolchain_config(modules = module_ctx.modules, _fail = _fail) default_python_version = _compute_default_python_version(module_ctx) @@ -115,15 +108,6 @@ def parse_modules(*, module_ctx, logger, _fail = fail): # * The root module is allowed to override the rules_python default. is_default = default_python_version == toolchain_version - # Also only the root module should be able to decide ignore_root_user_error. - # Modules being depended upon don't know the final environment, so they aren't - # in the right position to know or decide what the correct setting is. - - # If an inconsistency in the ignore_root_user_error among multiple toolchains is detected, fail. - if ignore_root_user_error != None and toolchain_attr.ignore_root_user_error != ignore_root_user_error: - fail("Toolchains in the root module must have consistent 'ignore_root_user_error' attributes") - - ignore_root_user_error = toolchain_attr.ignore_root_user_error elif mod.name == "rules_python" and not default_toolchain: # This branch handles when the root module doesn't declare a # Python toolchain @@ -166,7 +150,6 @@ def parse_modules(*, module_ctx, logger, _fail = fail): global_toolchain_versions[toolchain_version] = toolchain_info if debug_info: debug_info["toolchains_registered"].append({ - "ignore_root_user_error": ignore_root_user_error, "module": {"is_root": mod.is_root, "name": mod.name}, "name": toolchain_name, }) @@ -185,8 +168,6 @@ def parse_modules(*, module_ctx, logger, _fail = fail): elif toolchain_info: toolchains.append(toolchain_info) - config.default.setdefault("ignore_root_user_error", ignore_root_user_error) - # A default toolchain is required so that the non-version-specific rules # are able to match a toolchain. if default_toolchain == None: @@ -711,7 +692,6 @@ def _process_global_overrides(*, tag, default, _fail = fail): default["minor_mapping"] = tag.minor_mapping forwarded_attrs = sorted(AUTH_ATTRS) + [ - "ignore_root_user_error", "base_url", "register_all_versions", ] @@ -963,7 +943,6 @@ def _create_toolchain_attrs_struct( is_default = is_default, python_version = python_version if python_version else tag.python_version, configure_coverage_tool = getattr(tag, "configure_coverage_tool", False), - ignore_root_user_error = getattr(tag, "ignore_root_user_error", True), ) _defaults = tag_class( @@ -1075,16 +1054,9 @@ Then the python interpreter will be available as `my_python_name`. "ignore_root_user_error": attr.bool( default = True, doc = """\ -The Python runtime installation is made read only. This improves the ability for -Bazel to cache it by preventing the interpreter from creating `.pyc` files for -the standard library dynamically at runtime as they are loaded (this often leads -to spurious cache misses or build failures). - -However, if the user is running Bazel as root, this read-onlyness is not -respected. Bazel will print a warning message when it detects that the runtime -installation is writable despite being made read only (i.e. it's running with -root access) while this attribute is set `False`, however this messaging can be ignored by setting -this to `False`. +:::{versionchanged} VERSION_NEXT_FEATURE +Noop, will be removed in the next major release. +::: """, mandatory = False, ), diff --git a/tests/python/python_tests.bzl b/tests/python/python_tests.bzl index f2e87274f8..781d55d833 100644 --- a/tests/python/python_tests.bzl +++ b/tests/python/python_tests.bzl @@ -75,7 +75,6 @@ def _override( auth_patterns = {}, available_python_versions = [], base_url = "", - ignore_root_user_error = True, minor_mapping = {}, netrc = "", register_all_versions = False): @@ -83,7 +82,6 @@ def _override( auth_patterns = auth_patterns, available_python_versions = available_python_versions, base_url = base_url, - ignore_root_user_error = ignore_root_user_error, minor_mapping = minor_mapping, netrc = netrc, register_all_versions = register_all_versions, @@ -164,11 +162,9 @@ def _test_default_from_rules_python_when_rules_python_is_root(env): env.expect.that_collection(py.config.kwargs).has_size(0) env.expect.that_collection(py.config.default.keys()).contains_exactly([ "base_url", - "ignore_root_user_error", "tool_versions", "platforms", ]) - env.expect.that_bool(py.config.default["ignore_root_user_error"]).equals(True) env.expect.that_str(py.default_python_version).equals("3.11") want_toolchain = struct( @@ -220,76 +216,6 @@ def _test_default_with_patch_version(env): _tests.append(_test_default_with_patch_version) -def _test_default_non_rules_python_ignore_root_user_error(env): - py = parse_modules( - module_ctx = _mock_mctx( - _mod( - name = "my_module", - toolchain = [_toolchain("3.12", ignore_root_user_error = False)], - is_root = True, - ), - _rules_python_module(), - ), - logger = repo_utils.logger(verbosity_level = 0, name = "python"), - ) - - env.expect.that_bool(py.config.default["ignore_root_user_error"]).equals(False) - env.expect.that_str(py.default_python_version).equals("3.12") - - my_module_toolchain = struct( - name = "python_3_12", - python_version = "3.12", - register_coverage_tool = False, - ) - rules_python_toolchain = struct( - name = "python_3_11", - python_version = "3.11", - register_coverage_tool = False, - ) - env.expect.that_collection(py.toolchains).contains_exactly([ - rules_python_toolchain, - my_module_toolchain, - ]).in_order() - -_tests.append(_test_default_non_rules_python_ignore_root_user_error) - -def _test_default_non_rules_python_ignore_root_user_error_non_root_module(env): - """Verify a non-root intermediate module has its ignore_root_user_error setting ignored.""" - py = parse_modules( - module_ctx = _mock_mctx( - _mod(name = "my_module", is_root = True, toolchain = [_toolchain("3.13")]), - _mod(name = "some_module", toolchain = [_toolchain("3.12", ignore_root_user_error = False)]), - _rules_python_module(), - ), - logger = repo_utils.logger(verbosity_level = 0, name = "python"), - ) - - env.expect.that_str(py.default_python_version).equals("3.13") - env.expect.that_bool(py.config.default["ignore_root_user_error"]).equals(True) - - my_module_toolchain = struct( - name = "python_3_13", - python_version = "3.13", - register_coverage_tool = False, - ) - some_module_toolchain = struct( - name = "python_3_12", - python_version = "3.12", - register_coverage_tool = False, - ) - rules_python_toolchain = struct( - name = "python_3_11", - python_version = "3.11", - register_coverage_tool = False, - ) - env.expect.that_collection(py.toolchains).contains_exactly([ - some_module_toolchain, - rules_python_toolchain, - my_module_toolchain, # this was the only toolchain, default to that - ]).in_order() - -_tests.append(_test_default_non_rules_python_ignore_root_user_error_non_root_module) - def _test_toolchain_ordering(env): py = parse_modules( module_ctx = _mock_mctx( @@ -510,8 +436,8 @@ def _test_first_occurance_of_the_toolchain_wins(env): env.expect.that_dict(py.debug_info).contains_exactly({ "toolchains_registered": [ - {"ignore_root_user_error": True, "module": {"is_root": True, "name": "my_module"}, "name": "python_3_12"}, - {"ignore_root_user_error": True, "module": {"is_root": False, "name": "rules_python"}, "name": "python_3_11"}, + {"module": {"is_root": True, "name": "my_module"}, "name": "python_3_12"}, + {"module": {"is_root": False, "name": "rules_python"}, "name": "python_3_11"}, ], }) @@ -538,7 +464,6 @@ def _test_auth_overrides(env): env.expect.that_dict(py.config.default).contains_at_least({ "auth_patterns": {"foo": "bar"}, - "ignore_root_user_error": True, "netrc": "/my/netrc", }) env.expect.that_str(py.default_python_version).equals("3.12") From a295977f5090c323b2d87a8acbd3d03480f6c7a2 Mon Sep 17 00:00:00 2001 From: Ignas Anikevicius <240938+aignas@users.noreply.github.com> Date: Fri, 21 Nov 2025 09:00:43 +0900 Subject: [PATCH 04/14] remove ignore_root integration tests --- .../ignore_root_user_error/.bazelrc | 7 ---- .../ignore_root_user_error/.gitignore | 1 - .../ignore_root_user_error/BUILD.bazel | 32 --------------- .../ignore_root_user_error/MODULE.bazel | 20 ---------- .../ignore_root_user_error/README.md | 2 - .../ignore_root_user_error/WORKSPACE | 14 ------- .../ignore_root_user_error/bzlmod_test.py | 40 ------------------- .../ignore_root_user_error/foo_test.py | 13 ------ .../submodule/BUILD.bazel | 0 .../submodule/MODULE.bazel | 9 ----- .../submodule/WORKSPACE | 0 11 files changed, 138 deletions(-) delete mode 100644 tests/integration/ignore_root_user_error/.bazelrc delete mode 100644 tests/integration/ignore_root_user_error/.gitignore delete mode 100644 tests/integration/ignore_root_user_error/BUILD.bazel delete mode 100644 tests/integration/ignore_root_user_error/MODULE.bazel delete mode 100644 tests/integration/ignore_root_user_error/README.md delete mode 100644 tests/integration/ignore_root_user_error/WORKSPACE delete mode 100644 tests/integration/ignore_root_user_error/bzlmod_test.py delete mode 100644 tests/integration/ignore_root_user_error/foo_test.py delete mode 100644 tests/integration/ignore_root_user_error/submodule/BUILD.bazel delete mode 100644 tests/integration/ignore_root_user_error/submodule/MODULE.bazel delete mode 100644 tests/integration/ignore_root_user_error/submodule/WORKSPACE diff --git a/tests/integration/ignore_root_user_error/.bazelrc b/tests/integration/ignore_root_user_error/.bazelrc deleted file mode 100644 index bb7b5742cd..0000000000 --- a/tests/integration/ignore_root_user_error/.bazelrc +++ /dev/null @@ -1,7 +0,0 @@ -common --action_env=RULES_PYTHON_BZLMOD_DEBUG=1 -common --lockfile_mode=off -test --test_output=errors - -# Windows requires these for multi-python support: -build --enable_runfiles -common:bazel7.x --incompatible_python_disallow_native_rules diff --git a/tests/integration/ignore_root_user_error/.gitignore b/tests/integration/ignore_root_user_error/.gitignore deleted file mode 100644 index ac51a054d2..0000000000 --- a/tests/integration/ignore_root_user_error/.gitignore +++ /dev/null @@ -1 +0,0 @@ -bazel-* diff --git a/tests/integration/ignore_root_user_error/BUILD.bazel b/tests/integration/ignore_root_user_error/BUILD.bazel deleted file mode 100644 index 6e3b7b9d24..0000000000 --- a/tests/integration/ignore_root_user_error/BUILD.bazel +++ /dev/null @@ -1,32 +0,0 @@ -# Copyright 2024 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. - -load("@rules_python//python:py_test.bzl", "py_test") -load("@rules_python//python/private:bzlmod_enabled.bzl", "BZLMOD_ENABLED") # buildifier: disable=bzl-visibility - -py_test( - name = "foo_test", - srcs = ["foo_test.py"], - visibility = ["//visibility:public"], -) - -py_test( - name = "bzlmod_test", - srcs = ["bzlmod_test.py"], - data = [ - "@rules_python//python/runfiles", - "@rules_python_bzlmod_debug//:debug_info.json", - ], - target_compatible_with = [] if BZLMOD_ENABLED else ["@platforms//:incompatible"], -) diff --git a/tests/integration/ignore_root_user_error/MODULE.bazel b/tests/integration/ignore_root_user_error/MODULE.bazel deleted file mode 100644 index 15c37c4388..0000000000 --- a/tests/integration/ignore_root_user_error/MODULE.bazel +++ /dev/null @@ -1,20 +0,0 @@ -module(name = "ignore_root_user_error") - -bazel_dep(name = "rules_python", version = "0.0.0") -local_path_override( - module_name = "rules_python", - path = "../../..", -) - -bazel_dep(name = "submodule") -local_path_override( - module_name = "submodule", - path = "submodule", -) - -python = use_extension("@rules_python//python/extensions:python.bzl", "python") -python.toolchain( - ignore_root_user_error = True, - python_version = "3.11", -) -use_repo(python, "rules_python_bzlmod_debug") diff --git a/tests/integration/ignore_root_user_error/README.md b/tests/integration/ignore_root_user_error/README.md deleted file mode 100644 index 47da5eb9ad..0000000000 --- a/tests/integration/ignore_root_user_error/README.md +++ /dev/null @@ -1,2 +0,0 @@ -# ignore_root_user_errors -There are cases when we have to run Python targets with root, e.g., in Docker containers, requiring setting `ignore_root_user_error = True` when registering Python toolchain. This test makes sure that rules_python works in this case. \ No newline at end of file diff --git a/tests/integration/ignore_root_user_error/WORKSPACE b/tests/integration/ignore_root_user_error/WORKSPACE deleted file mode 100644 index 7ac0a609eb..0000000000 --- a/tests/integration/ignore_root_user_error/WORKSPACE +++ /dev/null @@ -1,14 +0,0 @@ -local_repository( - name = "rules_python", - path = "../../..", -) - -load("@rules_python//python:repositories.bzl", "py_repositories", "python_register_toolchains") - -py_repositories() - -python_register_toolchains( - name = "python39", - ignore_root_user_error = True, - python_version = "3.9", -) diff --git a/tests/integration/ignore_root_user_error/bzlmod_test.py b/tests/integration/ignore_root_user_error/bzlmod_test.py deleted file mode 100644 index a1d6dc0630..0000000000 --- a/tests/integration/ignore_root_user_error/bzlmod_test.py +++ /dev/null @@ -1,40 +0,0 @@ -# Copyright 2024 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. - -import json -import pathlib -import unittest - -from python.runfiles import runfiles - - -class BzlmodTest(unittest.TestCase): - def test_ignore_root_user_error_true_for_all_toolchains(self): - rf = runfiles.Create() - debug_path = pathlib.Path( - rf.Rlocation("rules_python_bzlmod_debug/debug_info.json") - ) - debug_info = json.loads(debug_path.read_bytes()) - actual = debug_info["toolchains_registered"] - # Because the root module set ignore_root_user_error=True, that should - # be the default for all other toolchains. - for entry in actual: - self.assertTrue( - entry["ignore_root_user_error"], - msg=f"Expected ignore_root_user_error=True, but got: {entry}", - ) - - -if __name__ == "__main__": - unittest.main() diff --git a/tests/integration/ignore_root_user_error/foo_test.py b/tests/integration/ignore_root_user_error/foo_test.py deleted file mode 100644 index 724cdcb69a..0000000000 --- a/tests/integration/ignore_root_user_error/foo_test.py +++ /dev/null @@ -1,13 +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. diff --git a/tests/integration/ignore_root_user_error/submodule/BUILD.bazel b/tests/integration/ignore_root_user_error/submodule/BUILD.bazel deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/tests/integration/ignore_root_user_error/submodule/MODULE.bazel b/tests/integration/ignore_root_user_error/submodule/MODULE.bazel deleted file mode 100644 index f12870963c..0000000000 --- a/tests/integration/ignore_root_user_error/submodule/MODULE.bazel +++ /dev/null @@ -1,9 +0,0 @@ -module(name = "submodule") - -bazel_dep(name = "rules_python", version = "0.0.0") - -python = use_extension("@rules_python//python/extensions:python.bzl", "python") -python.toolchain( - ignore_root_user_error = False, - python_version = "3.10", -) diff --git a/tests/integration/ignore_root_user_error/submodule/WORKSPACE b/tests/integration/ignore_root_user_error/submodule/WORKSPACE deleted file mode 100644 index e69de29bb2..0000000000 From 851a60f83cf9adf7ef6ef571d5fb2cebd17a793d Mon Sep 17 00:00:00 2001 From: Ignas Anikevicius <240938+aignas@users.noreply.github.com> Date: Fri, 21 Nov 2025 09:05:36 +0900 Subject: [PATCH 05/14] cleanup and changelog --- .bazelrc | 8 ++++---- CHANGELOG.md | 5 +++++ tests/integration/BUILD.bazel | 16 ---------------- 3 files changed, 9 insertions(+), 20 deletions(-) diff --git a/.bazelrc b/.bazelrc index b5c9c7c1e2..b88b40f334 100644 --- a/.bazelrc +++ b/.bazelrc @@ -4,13 +4,13 @@ # (Note, we cannot use `common --deleted_packages` because the bazel version command doesn't support it) # To update these lines, execute # `bazel run @rules_bazel_integration_test//tools:update_deleted_packages` -build --deleted_packages=examples/build_file_generation,examples/build_file_generation/random_number_generator,examples/bzlmod,examples/bzlmod_build_file_generation,examples/bzlmod_build_file_generation/other_module/other_module/pkg,examples/bzlmod_build_file_generation/runfiles,examples/bzlmod/entry_points,examples/bzlmod/entry_points/tests,examples/bzlmod/libs/my_lib,examples/bzlmod/other_module,examples/bzlmod/other_module/other_module/pkg,examples/bzlmod/patches,examples/bzlmod/py_proto_library,examples/bzlmod/py_proto_library/example.com/another_proto,examples/bzlmod/py_proto_library/example.com/proto,examples/bzlmod/runfiles,examples/bzlmod/tests,examples/bzlmod/tests/other_module,examples/bzlmod/whl_mods,examples/multi_python_versions/libs/my_lib,examples/multi_python_versions/requirements,examples/multi_python_versions/tests,examples/pip_parse,examples/pip_parse_vendored,examples/pip_repository_annotations,examples/py_proto_library,examples/py_proto_library/example.com/another_proto,examples/py_proto_library/example.com/proto,gazelle,gazelle/manifest,gazelle/manifest/generate,gazelle/manifest/hasher,gazelle/manifest/test,gazelle/modules_mapping,gazelle/python,gazelle/pythonconfig,gazelle/python/private,rules_python-repro,tests/integration/compile_pip_requirements,tests/integration/compile_pip_requirements_test_from_external_repo,tests/integration/custom_commands,tests/integration/ignore_root_user_error,tests/integration/ignore_root_user_error/submodule,tests/integration/local_toolchains,tests/integration/pip_parse,tests/integration/pip_parse/empty,tests/integration/py_cc_toolchain_registered,tests/modules/another_module,tests/modules/other,tests/modules/other/nspkg_delta,tests/modules/other/nspkg_gamma,tests/modules/other/nspkg_single,tests/modules/other/simple_v1,tests/modules/other/simple_v2,tests/modules/other/with_external_data,tests/whl_with_build_files/testdata,tests/whl_with_build_files/testdata/somepkg,tests/whl_with_build_files/testdata/somepkg-1.0.dist-info,tests/whl_with_build_files/testdata/somepkg/subpkg -query --deleted_packages=examples/build_file_generation,examples/build_file_generation/random_number_generator,examples/bzlmod,examples/bzlmod_build_file_generation,examples/bzlmod_build_file_generation/other_module/other_module/pkg,examples/bzlmod_build_file_generation/runfiles,examples/bzlmod/entry_points,examples/bzlmod/entry_points/tests,examples/bzlmod/libs/my_lib,examples/bzlmod/other_module,examples/bzlmod/other_module/other_module/pkg,examples/bzlmod/patches,examples/bzlmod/py_proto_library,examples/bzlmod/py_proto_library/example.com/another_proto,examples/bzlmod/py_proto_library/example.com/proto,examples/bzlmod/runfiles,examples/bzlmod/tests,examples/bzlmod/tests/other_module,examples/bzlmod/whl_mods,examples/multi_python_versions/libs/my_lib,examples/multi_python_versions/requirements,examples/multi_python_versions/tests,examples/pip_parse,examples/pip_parse_vendored,examples/pip_repository_annotations,examples/py_proto_library,examples/py_proto_library/example.com/another_proto,examples/py_proto_library/example.com/proto,gazelle,gazelle/manifest,gazelle/manifest/generate,gazelle/manifest/hasher,gazelle/manifest/test,gazelle/modules_mapping,gazelle/python,gazelle/pythonconfig,gazelle/python/private,rules_python-repro,tests/integration/compile_pip_requirements,tests/integration/compile_pip_requirements_test_from_external_repo,tests/integration/custom_commands,tests/integration/ignore_root_user_error,tests/integration/ignore_root_user_error/submodule,tests/integration/local_toolchains,tests/integration/pip_parse,tests/integration/pip_parse/empty,tests/integration/py_cc_toolchain_registered,tests/modules/another_module,tests/modules/other,tests/modules/other/nspkg_delta,tests/modules/other/nspkg_gamma,tests/modules/other/nspkg_single,tests/modules/other/simple_v1,tests/modules/other/simple_v2,tests/modules/other/with_external_data,tests/whl_with_build_files/testdata,tests/whl_with_build_files/testdata/somepkg,tests/whl_with_build_files/testdata/somepkg-1.0.dist-info,tests/whl_with_build_files/testdata/somepkg/subpkg +build --deleted_packages=examples/build_file_generation,examples/build_file_generation/random_number_generator,examples/bzlmod,examples/bzlmod/entry_points,examples/bzlmod/entry_points/tests,examples/bzlmod/libs/my_lib,examples/bzlmod/other_module,examples/bzlmod/other_module/other_module/pkg,examples/bzlmod/patches,examples/bzlmod/py_proto_library,examples/bzlmod/py_proto_library/example.com/another_proto,examples/bzlmod/py_proto_library/example.com/proto,examples/bzlmod/runfiles,examples/bzlmod/tests,examples/bzlmod/tests/other_module,examples/bzlmod/whl_mods,examples/multi_python_versions/libs/my_lib,examples/multi_python_versions/requirements,examples/multi_python_versions/tests,examples/pip_parse,examples/pip_parse_vendored,examples/pip_repository_annotations,examples/py_proto_library,examples/py_proto_library/example.com/another_proto,examples/py_proto_library/example.com/proto,gazelle,gazelle/docs,gazelle/examples/bzlmod_build_file_generation,gazelle/examples/bzlmod_build_file_generation/other_module/other_module/pkg,gazelle/examples/bzlmod_build_file_generation/runfiles,gazelle/manifest,gazelle/manifest/generate,gazelle/manifest/hasher,gazelle/manifest/test,gazelle/modules_mapping,gazelle/python,gazelle/pythonconfig,gazelle/python/private,tests/integration/compile_pip_requirements,tests/integration/compile_pip_requirements_test_from_external_repo,tests/integration/custom_commands,tests/integration/local_toolchains,tests/integration/pip_parse,tests/integration/pip_parse/empty,tests/integration/py_cc_toolchain_registered,tests/modules/another_module,tests/modules/other,tests/modules/other/nspkg_delta,tests/modules/other/nspkg_gamma,tests/modules/other/nspkg_single,tests/modules/other/simple_v1,tests/modules/other/simple_v2,tests/modules/other/with_external_data,tests/whl_with_build_files/testdata,tests/whl_with_build_files/testdata/somepkg,tests/whl_with_build_files/testdata/somepkg-1.0.dist-info,tests/whl_with_build_files/testdata/somepkg/subpkg +query --deleted_packages=examples/build_file_generation,examples/build_file_generation/random_number_generator,examples/bzlmod,examples/bzlmod/entry_points,examples/bzlmod/entry_points/tests,examples/bzlmod/libs/my_lib,examples/bzlmod/other_module,examples/bzlmod/other_module/other_module/pkg,examples/bzlmod/patches,examples/bzlmod/py_proto_library,examples/bzlmod/py_proto_library/example.com/another_proto,examples/bzlmod/py_proto_library/example.com/proto,examples/bzlmod/runfiles,examples/bzlmod/tests,examples/bzlmod/tests/other_module,examples/bzlmod/whl_mods,examples/multi_python_versions/libs/my_lib,examples/multi_python_versions/requirements,examples/multi_python_versions/tests,examples/pip_parse,examples/pip_parse_vendored,examples/pip_repository_annotations,examples/py_proto_library,examples/py_proto_library/example.com/another_proto,examples/py_proto_library/example.com/proto,gazelle,gazelle/docs,gazelle/examples/bzlmod_build_file_generation,gazelle/examples/bzlmod_build_file_generation/other_module/other_module/pkg,gazelle/examples/bzlmod_build_file_generation/runfiles,gazelle/manifest,gazelle/manifest/generate,gazelle/manifest/hasher,gazelle/manifest/test,gazelle/modules_mapping,gazelle/python,gazelle/pythonconfig,gazelle/python/private,tests/integration/compile_pip_requirements,tests/integration/compile_pip_requirements_test_from_external_repo,tests/integration/custom_commands,tests/integration/local_toolchains,tests/integration/pip_parse,tests/integration/pip_parse/empty,tests/integration/py_cc_toolchain_registered,tests/modules/another_module,tests/modules/other,tests/modules/other/nspkg_delta,tests/modules/other/nspkg_gamma,tests/modules/other/nspkg_single,tests/modules/other/simple_v1,tests/modules/other/simple_v2,tests/modules/other/with_external_data,tests/whl_with_build_files/testdata,tests/whl_with_build_files/testdata/somepkg,tests/whl_with_build_files/testdata/somepkg-1.0.dist-info,tests/whl_with_build_files/testdata/somepkg/subpkg test --test_output=errors -common --deleted_packages=gazelle/examples/bzlmod_build_file_generation -common --deleted_packages=gazelle/examples/bzlmod_build_file_generation/runfiles +common --deleted_packages=examples/build_file_generation,examples/build_file_generation/random_number_generator,examples/bzlmod,examples/bzlmod/entry_points,examples/bzlmod/entry_points/tests,examples/bzlmod/libs/my_lib,examples/bzlmod/other_module,examples/bzlmod/other_module/other_module/pkg,examples/bzlmod/patches,examples/bzlmod/py_proto_library,examples/bzlmod/py_proto_library/example.com/another_proto,examples/bzlmod/py_proto_library/example.com/proto,examples/bzlmod/runfiles,examples/bzlmod/tests,examples/bzlmod/tests/other_module,examples/bzlmod/whl_mods,examples/multi_python_versions/libs/my_lib,examples/multi_python_versions/requirements,examples/multi_python_versions/tests,examples/pip_parse,examples/pip_parse_vendored,examples/pip_repository_annotations,examples/py_proto_library,examples/py_proto_library/example.com/another_proto,examples/py_proto_library/example.com/proto,gazelle,gazelle/docs,gazelle/examples/bzlmod_build_file_generation,gazelle/examples/bzlmod_build_file_generation/other_module/other_module/pkg,gazelle/examples/bzlmod_build_file_generation/runfiles,gazelle/manifest,gazelle/manifest/generate,gazelle/manifest/hasher,gazelle/manifest/test,gazelle/modules_mapping,gazelle/python,gazelle/pythonconfig,gazelle/python/private,tests/integration/compile_pip_requirements,tests/integration/compile_pip_requirements_test_from_external_repo,tests/integration/custom_commands,tests/integration/local_toolchains,tests/integration/pip_parse,tests/integration/pip_parse/empty,tests/integration/py_cc_toolchain_registered,tests/modules/another_module,tests/modules/other,tests/modules/other/nspkg_delta,tests/modules/other/nspkg_gamma,tests/modules/other/nspkg_single,tests/modules/other/simple_v1,tests/modules/other/simple_v2,tests/modules/other/with_external_data,tests/whl_with_build_files/testdata,tests/whl_with_build_files/testdata/somepkg,tests/whl_with_build_files/testdata/somepkg-1.0.dist-info,tests/whl_with_build_files/testdata/somepkg/subpkg +common --deleted_packages=examples/build_file_generation,examples/build_file_generation/random_number_generator,examples/bzlmod,examples/bzlmod/entry_points,examples/bzlmod/entry_points/tests,examples/bzlmod/libs/my_lib,examples/bzlmod/other_module,examples/bzlmod/other_module/other_module/pkg,examples/bzlmod/patches,examples/bzlmod/py_proto_library,examples/bzlmod/py_proto_library/example.com/another_proto,examples/bzlmod/py_proto_library/example.com/proto,examples/bzlmod/runfiles,examples/bzlmod/tests,examples/bzlmod/tests/other_module,examples/bzlmod/whl_mods,examples/multi_python_versions/libs/my_lib,examples/multi_python_versions/requirements,examples/multi_python_versions/tests,examples/pip_parse,examples/pip_parse_vendored,examples/pip_repository_annotations,examples/py_proto_library,examples/py_proto_library/example.com/another_proto,examples/py_proto_library/example.com/proto,gazelle,gazelle/docs,gazelle/examples/bzlmod_build_file_generation,gazelle/examples/bzlmod_build_file_generation/other_module/other_module/pkg,gazelle/examples/bzlmod_build_file_generation/runfiles,gazelle/manifest,gazelle/manifest/generate,gazelle/manifest/hasher,gazelle/manifest/test,gazelle/modules_mapping,gazelle/python,gazelle/pythonconfig,gazelle/python/private,tests/integration/compile_pip_requirements,tests/integration/compile_pip_requirements_test_from_external_repo,tests/integration/custom_commands,tests/integration/local_toolchains,tests/integration/pip_parse,tests/integration/pip_parse/empty,tests/integration/py_cc_toolchain_registered,tests/modules/another_module,tests/modules/other,tests/modules/other/nspkg_delta,tests/modules/other/nspkg_gamma,tests/modules/other/nspkg_single,tests/modules/other/simple_v1,tests/modules/other/simple_v2,tests/modules/other/with_external_data,tests/whl_with_build_files/testdata,tests/whl_with_build_files/testdata/somepkg,tests/whl_with_build_files/testdata/somepkg-1.0.dist-info,tests/whl_with_build_files/testdata/somepkg/subpkg # Do NOT implicitly create empty __init__.py files in the runfiles tree. # By default, these are created in every directory containing Python source code diff --git a/CHANGELOG.md b/CHANGELOG.md index d7403b4f1a..e1e1d2f654 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -55,6 +55,11 @@ END_UNRELEASED_TEMPLATE {#v0-0-0-removed} ### Removed +* (toolchain) `ignore_root_user_error` has now been flipped to be always enabled and + the `chmod` of the python toolchain directories have been removed. From now on `rules_python` + always adds the `pyc` files to the glob excludes and in order to avoid any problems when using + the toolchains in the repository phase, ensure that you pass `-B` to the python interpreter. + ([#2016](https://github.com/bazel-contrib/rules_python/issues/2016)) * (toolchain) Remove all of the python 3.9 toolchain versions except for the `3.9.25`. This version has reached EOL and will no longer receive any security fixes, please update to `3.10` or above. diff --git a/tests/integration/BUILD.bazel b/tests/integration/BUILD.bazel index 0e47faf91a..673312903d 100644 --- a/tests/integration/BUILD.bazel +++ b/tests/integration/BUILD.bazel @@ -75,22 +75,6 @@ rules_python_integration_test( workspace_path = "compile_pip_requirements", ) -rules_python_integration_test( - name = "ignore_root_user_error_test", - env = { - "RULES_PYTHON_BZLMOD_DEBUG": "1", - }, -) - -rules_python_integration_test( - name = "ignore_root_user_error_workspace_test", - bzlmod = False, - env = { - "RULES_PYTHON_BZLMOD_DEBUG": "1", - }, - workspace_path = "ignore_root_user_error", -) - rules_python_integration_test( name = "local_toolchains_test", env = { From 4decbc69d2f3592bf3ffb15cf6cd725ed0a28e14 Mon Sep 17 00:00:00 2001 From: Ignas Anikevicius <240938+aignas@users.noreply.github.com> Date: Fri, 21 Nov 2025 09:10:07 +0900 Subject: [PATCH 06/14] remove bazelci config --- .bazelci/presubmit.yml | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/.bazelci/presubmit.yml b/.bazelci/presubmit.yml index 1cb3a01365..41f511886b 100644 --- a/.bazelci/presubmit.yml +++ b/.bazelci/presubmit.yml @@ -611,19 +611,6 @@ tasks: - "git diff --exit-code" - integration_test_ignore_root_user_error_macos_workspace: - <<: *reusable_build_test_all - <<: *common_workspace_flags - name: "ignore_root_user_error: macOS, workspace" - working_directory: tests/integration/ignore_root_user_error - platform: macos - integration_test_ignore_root_user_error_windows_workspace: - <<: *reusable_build_test_all - <<: *common_workspace_flags - name: "ignore_root_user_error: Windows, workspace" - working_directory: tests/integration/ignore_root_user_error - platform: windows - integration_compile_pip_requirements_test_from_external_repo_ubuntu_min_workspace: <<: *minimum_supported_version <<: *common_workspace_flags_min_bazel From 34298becdcb98b56a387facecb2f22ddb5ba734b Mon Sep 17 00:00:00 2001 From: Ignas Anikevicius <240938+aignas@users.noreply.github.com> Date: Fri, 21 Nov 2025 14:46:57 +0900 Subject: [PATCH 07/14] new run --- .bazelrc | 6 +----- .pre-commit-config.yaml | 2 +- MODULE.bazel | 2 +- 3 files changed, 3 insertions(+), 7 deletions(-) diff --git a/.bazelrc b/.bazelrc index b88b40f334..ce4645d34e 100644 --- a/.bazelrc +++ b/.bazelrc @@ -4,14 +4,10 @@ # (Note, we cannot use `common --deleted_packages` because the bazel version command doesn't support it) # To update these lines, execute # `bazel run @rules_bazel_integration_test//tools:update_deleted_packages` -build --deleted_packages=examples/build_file_generation,examples/build_file_generation/random_number_generator,examples/bzlmod,examples/bzlmod/entry_points,examples/bzlmod/entry_points/tests,examples/bzlmod/libs/my_lib,examples/bzlmod/other_module,examples/bzlmod/other_module/other_module/pkg,examples/bzlmod/patches,examples/bzlmod/py_proto_library,examples/bzlmod/py_proto_library/example.com/another_proto,examples/bzlmod/py_proto_library/example.com/proto,examples/bzlmod/runfiles,examples/bzlmod/tests,examples/bzlmod/tests/other_module,examples/bzlmod/whl_mods,examples/multi_python_versions/libs/my_lib,examples/multi_python_versions/requirements,examples/multi_python_versions/tests,examples/pip_parse,examples/pip_parse_vendored,examples/pip_repository_annotations,examples/py_proto_library,examples/py_proto_library/example.com/another_proto,examples/py_proto_library/example.com/proto,gazelle,gazelle/docs,gazelle/examples/bzlmod_build_file_generation,gazelle/examples/bzlmod_build_file_generation/other_module/other_module/pkg,gazelle/examples/bzlmod_build_file_generation/runfiles,gazelle/manifest,gazelle/manifest/generate,gazelle/manifest/hasher,gazelle/manifest/test,gazelle/modules_mapping,gazelle/python,gazelle/pythonconfig,gazelle/python/private,tests/integration/compile_pip_requirements,tests/integration/compile_pip_requirements_test_from_external_repo,tests/integration/custom_commands,tests/integration/local_toolchains,tests/integration/pip_parse,tests/integration/pip_parse/empty,tests/integration/py_cc_toolchain_registered,tests/modules/another_module,tests/modules/other,tests/modules/other/nspkg_delta,tests/modules/other/nspkg_gamma,tests/modules/other/nspkg_single,tests/modules/other/simple_v1,tests/modules/other/simple_v2,tests/modules/other/with_external_data,tests/whl_with_build_files/testdata,tests/whl_with_build_files/testdata/somepkg,tests/whl_with_build_files/testdata/somepkg-1.0.dist-info,tests/whl_with_build_files/testdata/somepkg/subpkg -query --deleted_packages=examples/build_file_generation,examples/build_file_generation/random_number_generator,examples/bzlmod,examples/bzlmod/entry_points,examples/bzlmod/entry_points/tests,examples/bzlmod/libs/my_lib,examples/bzlmod/other_module,examples/bzlmod/other_module/other_module/pkg,examples/bzlmod/patches,examples/bzlmod/py_proto_library,examples/bzlmod/py_proto_library/example.com/another_proto,examples/bzlmod/py_proto_library/example.com/proto,examples/bzlmod/runfiles,examples/bzlmod/tests,examples/bzlmod/tests/other_module,examples/bzlmod/whl_mods,examples/multi_python_versions/libs/my_lib,examples/multi_python_versions/requirements,examples/multi_python_versions/tests,examples/pip_parse,examples/pip_parse_vendored,examples/pip_repository_annotations,examples/py_proto_library,examples/py_proto_library/example.com/another_proto,examples/py_proto_library/example.com/proto,gazelle,gazelle/docs,gazelle/examples/bzlmod_build_file_generation,gazelle/examples/bzlmod_build_file_generation/other_module/other_module/pkg,gazelle/examples/bzlmod_build_file_generation/runfiles,gazelle/manifest,gazelle/manifest/generate,gazelle/manifest/hasher,gazelle/manifest/test,gazelle/modules_mapping,gazelle/python,gazelle/pythonconfig,gazelle/python/private,tests/integration/compile_pip_requirements,tests/integration/compile_pip_requirements_test_from_external_repo,tests/integration/custom_commands,tests/integration/local_toolchains,tests/integration/pip_parse,tests/integration/pip_parse/empty,tests/integration/py_cc_toolchain_registered,tests/modules/another_module,tests/modules/other,tests/modules/other/nspkg_delta,tests/modules/other/nspkg_gamma,tests/modules/other/nspkg_single,tests/modules/other/simple_v1,tests/modules/other/simple_v2,tests/modules/other/with_external_data,tests/whl_with_build_files/testdata,tests/whl_with_build_files/testdata/somepkg,tests/whl_with_build_files/testdata/somepkg-1.0.dist-info,tests/whl_with_build_files/testdata/somepkg/subpkg +common --deleted_packages=examples/build_file_generation,examples/build_file_generation/random_number_generator,examples/bzlmod,examples/bzlmod/entry_points,examples/bzlmod/entry_points/tests,examples/bzlmod/libs/my_lib,examples/bzlmod/other_module,examples/bzlmod/other_module/other_module/pkg,examples/bzlmod/patches,examples/bzlmod/py_proto_library,examples/bzlmod/py_proto_library/example.com/another_proto,examples/bzlmod/py_proto_library/example.com/proto,examples/bzlmod/runfiles,examples/bzlmod/tests,examples/bzlmod/tests/other_module,examples/bzlmod/whl_mods,examples/multi_python_versions/libs/my_lib,examples/multi_python_versions/requirements,examples/multi_python_versions/tests,examples/pip_parse,examples/pip_parse_vendored,examples/pip_repository_annotations,examples/py_proto_library,examples/py_proto_library/example.com/another_proto,examples/py_proto_library/example.com/proto,gazelle,gazelle/docs,gazelle/examples/bzlmod_build_file_generation,gazelle/examples/bzlmod_build_file_generation/other_module/other_module/pkg,gazelle/examples/bzlmod_build_file_generation/runfiles,gazelle/manifest,gazelle/manifest/generate,gazelle/manifest/hasher,gazelle/manifest/test,gazelle/modules_mapping,gazelle/python,gazelle/python/private,gazelle/pythonconfig,tests/integration/compile_pip_requirements,tests/integration/compile_pip_requirements_test_from_external_repo,tests/integration/custom_commands,tests/integration/local_toolchains,tests/integration/pip_parse,tests/integration/pip_parse/empty,tests/integration/py_cc_toolchain_registered,tests/modules/another_module,tests/modules/other,tests/modules/other/nspkg_delta,tests/modules/other/nspkg_gamma,tests/modules/other/nspkg_single,tests/modules/other/simple_v1,tests/modules/other/simple_v2,tests/modules/other/with_external_data,tests/whl_with_build_files/testdata,tests/whl_with_build_files/testdata/somepkg,tests/whl_with_build_files/testdata/somepkg-1.0.dist-info,tests/whl_with_build_files/testdata/somepkg/subpkg test --test_output=errors -common --deleted_packages=examples/build_file_generation,examples/build_file_generation/random_number_generator,examples/bzlmod,examples/bzlmod/entry_points,examples/bzlmod/entry_points/tests,examples/bzlmod/libs/my_lib,examples/bzlmod/other_module,examples/bzlmod/other_module/other_module/pkg,examples/bzlmod/patches,examples/bzlmod/py_proto_library,examples/bzlmod/py_proto_library/example.com/another_proto,examples/bzlmod/py_proto_library/example.com/proto,examples/bzlmod/runfiles,examples/bzlmod/tests,examples/bzlmod/tests/other_module,examples/bzlmod/whl_mods,examples/multi_python_versions/libs/my_lib,examples/multi_python_versions/requirements,examples/multi_python_versions/tests,examples/pip_parse,examples/pip_parse_vendored,examples/pip_repository_annotations,examples/py_proto_library,examples/py_proto_library/example.com/another_proto,examples/py_proto_library/example.com/proto,gazelle,gazelle/docs,gazelle/examples/bzlmod_build_file_generation,gazelle/examples/bzlmod_build_file_generation/other_module/other_module/pkg,gazelle/examples/bzlmod_build_file_generation/runfiles,gazelle/manifest,gazelle/manifest/generate,gazelle/manifest/hasher,gazelle/manifest/test,gazelle/modules_mapping,gazelle/python,gazelle/pythonconfig,gazelle/python/private,tests/integration/compile_pip_requirements,tests/integration/compile_pip_requirements_test_from_external_repo,tests/integration/custom_commands,tests/integration/local_toolchains,tests/integration/pip_parse,tests/integration/pip_parse/empty,tests/integration/py_cc_toolchain_registered,tests/modules/another_module,tests/modules/other,tests/modules/other/nspkg_delta,tests/modules/other/nspkg_gamma,tests/modules/other/nspkg_single,tests/modules/other/simple_v1,tests/modules/other/simple_v2,tests/modules/other/with_external_data,tests/whl_with_build_files/testdata,tests/whl_with_build_files/testdata/somepkg,tests/whl_with_build_files/testdata/somepkg-1.0.dist-info,tests/whl_with_build_files/testdata/somepkg/subpkg -common --deleted_packages=examples/build_file_generation,examples/build_file_generation/random_number_generator,examples/bzlmod,examples/bzlmod/entry_points,examples/bzlmod/entry_points/tests,examples/bzlmod/libs/my_lib,examples/bzlmod/other_module,examples/bzlmod/other_module/other_module/pkg,examples/bzlmod/patches,examples/bzlmod/py_proto_library,examples/bzlmod/py_proto_library/example.com/another_proto,examples/bzlmod/py_proto_library/example.com/proto,examples/bzlmod/runfiles,examples/bzlmod/tests,examples/bzlmod/tests/other_module,examples/bzlmod/whl_mods,examples/multi_python_versions/libs/my_lib,examples/multi_python_versions/requirements,examples/multi_python_versions/tests,examples/pip_parse,examples/pip_parse_vendored,examples/pip_repository_annotations,examples/py_proto_library,examples/py_proto_library/example.com/another_proto,examples/py_proto_library/example.com/proto,gazelle,gazelle/docs,gazelle/examples/bzlmod_build_file_generation,gazelle/examples/bzlmod_build_file_generation/other_module/other_module/pkg,gazelle/examples/bzlmod_build_file_generation/runfiles,gazelle/manifest,gazelle/manifest/generate,gazelle/manifest/hasher,gazelle/manifest/test,gazelle/modules_mapping,gazelle/python,gazelle/pythonconfig,gazelle/python/private,tests/integration/compile_pip_requirements,tests/integration/compile_pip_requirements_test_from_external_repo,tests/integration/custom_commands,tests/integration/local_toolchains,tests/integration/pip_parse,tests/integration/pip_parse/empty,tests/integration/py_cc_toolchain_registered,tests/modules/another_module,tests/modules/other,tests/modules/other/nspkg_delta,tests/modules/other/nspkg_gamma,tests/modules/other/nspkg_single,tests/modules/other/simple_v1,tests/modules/other/simple_v2,tests/modules/other/with_external_data,tests/whl_with_build_files/testdata,tests/whl_with_build_files/testdata/somepkg,tests/whl_with_build_files/testdata/somepkg-1.0.dist-info,tests/whl_with_build_files/testdata/somepkg/subpkg - # Do NOT implicitly create empty __init__.py files in the runfiles tree. # By default, these are created in every directory containing Python source code # or shared libraries, and every parent directory of those directories, diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 91e449f950..14953d0a89 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -48,6 +48,6 @@ repos: language: system # 7.x is necessary until https://github.com/bazel-contrib/rules_bazel_integration_test/pull/414 # is merged and released - entry: env USE_BAZEL_VERSION=7.x bazel run @rules_bazel_integration_test//tools:update_deleted_packages + entry: bazel run @rules_bazel_integration_test//tools:update_deleted_packages --exclude-dir gazelle files: ^((examples|tests)/.*/(MODULE.bazel|WORKSPACE|WORKSPACE.bzlmod|BUILD.bazel)|.bazelrc)$ pass_filenames: false diff --git a/MODULE.bazel b/MODULE.bazel index 6e9b725c53..0f80b3202e 100644 --- a/MODULE.bazel +++ b/MODULE.bazel @@ -215,7 +215,7 @@ use_repo(pip, "rules_python_publish_deps") bazel_dep(name = "stardoc", version = "0.7.2", repo_name = "io_bazel_stardoc") # ===== DEV ONLY DEPS AND SETUP BELOW HERE ===== -bazel_dep(name = "rules_bazel_integration_test", version = "0.27.0", dev_dependency = True) +bazel_dep(name = "rules_bazel_integration_test", version = "0.34.0", dev_dependency = True) bazel_dep(name = "rules_testing", version = "0.6.0", dev_dependency = True) bazel_dep(name = "rules_shell", version = "0.3.0", dev_dependency = True) bazel_dep(name = "rules_multirun", version = "0.9.0", dev_dependency = True) From 510c28333a6d2eceb433994ee2ac0b7d978e8b8b Mon Sep 17 00:00:00 2001 From: Ignas Anikevicius <240938+aignas@users.noreply.github.com> Date: Fri, 21 Nov 2025 14:48:01 +0900 Subject: [PATCH 08/14] fix .bazelignore --- .bazelignore | 1 - 1 file changed, 1 deletion(-) diff --git a/.bazelignore b/.bazelignore index dd58b79e3c..2f50cc2c52 100644 --- a/.bazelignore +++ b/.bazelignore @@ -31,6 +31,5 @@ gazelle/examples/bzlmod_build_file_generation/bazel-bzlmod_build_file_generation gazelle/examples/bzlmod_build_file_generation/bazel-out gazelle/examples/bzlmod_build_file_generation/bazel-testlog tests/integration/compile_pip_requirements/bazel-compile_pip_requirements -tests/integration/ignore_root_user_error/bazel-ignore_root_user_error tests/integration/local_toolchains/bazel-local_toolchains tests/integration/py_cc_toolchain_registered/bazel-py_cc_toolchain_registered From dfcb8c320d4a6d5e21be80a8cacece0de324d2b1 Mon Sep 17 00:00:00 2001 From: Ignas Anikevicius <240938+aignas@users.noreply.github.com> Date: Fri, 21 Nov 2025 14:49:40 +0900 Subject: [PATCH 09/14] fix the gazelle docs exclusion --- .bazelrc | 2 +- .pre-commit-config.yaml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.bazelrc b/.bazelrc index ce4645d34e..9f115ec3b0 100644 --- a/.bazelrc +++ b/.bazelrc @@ -4,7 +4,7 @@ # (Note, we cannot use `common --deleted_packages` because the bazel version command doesn't support it) # To update these lines, execute # `bazel run @rules_bazel_integration_test//tools:update_deleted_packages` -common --deleted_packages=examples/build_file_generation,examples/build_file_generation/random_number_generator,examples/bzlmod,examples/bzlmod/entry_points,examples/bzlmod/entry_points/tests,examples/bzlmod/libs/my_lib,examples/bzlmod/other_module,examples/bzlmod/other_module/other_module/pkg,examples/bzlmod/patches,examples/bzlmod/py_proto_library,examples/bzlmod/py_proto_library/example.com/another_proto,examples/bzlmod/py_proto_library/example.com/proto,examples/bzlmod/runfiles,examples/bzlmod/tests,examples/bzlmod/tests/other_module,examples/bzlmod/whl_mods,examples/multi_python_versions/libs/my_lib,examples/multi_python_versions/requirements,examples/multi_python_versions/tests,examples/pip_parse,examples/pip_parse_vendored,examples/pip_repository_annotations,examples/py_proto_library,examples/py_proto_library/example.com/another_proto,examples/py_proto_library/example.com/proto,gazelle,gazelle/docs,gazelle/examples/bzlmod_build_file_generation,gazelle/examples/bzlmod_build_file_generation/other_module/other_module/pkg,gazelle/examples/bzlmod_build_file_generation/runfiles,gazelle/manifest,gazelle/manifest/generate,gazelle/manifest/hasher,gazelle/manifest/test,gazelle/modules_mapping,gazelle/python,gazelle/python/private,gazelle/pythonconfig,tests/integration/compile_pip_requirements,tests/integration/compile_pip_requirements_test_from_external_repo,tests/integration/custom_commands,tests/integration/local_toolchains,tests/integration/pip_parse,tests/integration/pip_parse/empty,tests/integration/py_cc_toolchain_registered,tests/modules/another_module,tests/modules/other,tests/modules/other/nspkg_delta,tests/modules/other/nspkg_gamma,tests/modules/other/nspkg_single,tests/modules/other/simple_v1,tests/modules/other/simple_v2,tests/modules/other/with_external_data,tests/whl_with_build_files/testdata,tests/whl_with_build_files/testdata/somepkg,tests/whl_with_build_files/testdata/somepkg-1.0.dist-info,tests/whl_with_build_files/testdata/somepkg/subpkg +common --deleted_packages=examples/build_file_generation,examples/build_file_generation/random_number_generator,examples/bzlmod,examples/bzlmod/entry_points,examples/bzlmod/entry_points/tests,examples/bzlmod/libs/my_lib,examples/bzlmod/other_module,examples/bzlmod/other_module/other_module/pkg,examples/bzlmod/patches,examples/bzlmod/py_proto_library,examples/bzlmod/py_proto_library/example.com/another_proto,examples/bzlmod/py_proto_library/example.com/proto,examples/bzlmod/runfiles,examples/bzlmod/tests,examples/bzlmod/tests/other_module,examples/bzlmod/whl_mods,examples/multi_python_versions/libs/my_lib,examples/multi_python_versions/requirements,examples/multi_python_versions/tests,examples/pip_parse,examples/pip_parse_vendored,examples/pip_repository_annotations,examples/py_proto_library,examples/py_proto_library/example.com/another_proto,examples/py_proto_library/example.com/proto,gazelle,gazelle/examples/bzlmod_build_file_generation,gazelle/examples/bzlmod_build_file_generation/other_module/other_module/pkg,gazelle/examples/bzlmod_build_file_generation/runfiles,gazelle/manifest,gazelle/manifest/generate,gazelle/manifest/hasher,gazelle/manifest/test,gazelle/modules_mapping,gazelle/python,gazelle/python/private,gazelle/pythonconfig,tests/integration/compile_pip_requirements,tests/integration/compile_pip_requirements_test_from_external_repo,tests/integration/custom_commands,tests/integration/local_toolchains,tests/integration/pip_parse,tests/integration/pip_parse/empty,tests/integration/py_cc_toolchain_registered,tests/modules/another_module,tests/modules/other,tests/modules/other/nspkg_delta,tests/modules/other/nspkg_gamma,tests/modules/other/nspkg_single,tests/modules/other/simple_v1,tests/modules/other/simple_v2,tests/modules/other/with_external_data,tests/whl_with_build_files/testdata,tests/whl_with_build_files/testdata/somepkg,tests/whl_with_build_files/testdata/somepkg-1.0.dist-info,tests/whl_with_build_files/testdata/somepkg/subpkg test --test_output=errors diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 14953d0a89..9aa006bda1 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -48,6 +48,6 @@ repos: language: system # 7.x is necessary until https://github.com/bazel-contrib/rules_bazel_integration_test/pull/414 # is merged and released - entry: bazel run @rules_bazel_integration_test//tools:update_deleted_packages --exclude-dir gazelle + entry: bazel run @rules_bazel_integration_test//tools:update_deleted_packages --exclude_dir gazelle/docs files: ^((examples|tests)/.*/(MODULE.bazel|WORKSPACE|WORKSPACE.bzlmod|BUILD.bazel)|.bazelrc)$ pass_filenames: false From a497e697d5412749e268175bf4ad9958b3e9b6b7 Mon Sep 17 00:00:00 2001 From: Ignas Anikevicius <240938+aignas@users.noreply.github.com> Date: Fri, 21 Nov 2025 21:52:57 +0900 Subject: [PATCH 10/14] revert to using a previous version of the bazel integration test rules and use our shell script to update deleted pkgs --- .bazelrc | 4 ++-- .pre-commit-config.yaml | 2 +- MODULE.bazel | 2 +- tools/update_deleted_packages.sh | 3 ++- 4 files changed, 6 insertions(+), 5 deletions(-) diff --git a/.bazelrc b/.bazelrc index 9f115ec3b0..e93baff4b8 100644 --- a/.bazelrc +++ b/.bazelrc @@ -3,8 +3,8 @@ # This lets us glob() up all the files inside the examples to make them inputs to tests # (Note, we cannot use `common --deleted_packages` because the bazel version command doesn't support it) # To update these lines, execute -# `bazel run @rules_bazel_integration_test//tools:update_deleted_packages` -common --deleted_packages=examples/build_file_generation,examples/build_file_generation/random_number_generator,examples/bzlmod,examples/bzlmod/entry_points,examples/bzlmod/entry_points/tests,examples/bzlmod/libs/my_lib,examples/bzlmod/other_module,examples/bzlmod/other_module/other_module/pkg,examples/bzlmod/patches,examples/bzlmod/py_proto_library,examples/bzlmod/py_proto_library/example.com/another_proto,examples/bzlmod/py_proto_library/example.com/proto,examples/bzlmod/runfiles,examples/bzlmod/tests,examples/bzlmod/tests/other_module,examples/bzlmod/whl_mods,examples/multi_python_versions/libs/my_lib,examples/multi_python_versions/requirements,examples/multi_python_versions/tests,examples/pip_parse,examples/pip_parse_vendored,examples/pip_repository_annotations,examples/py_proto_library,examples/py_proto_library/example.com/another_proto,examples/py_proto_library/example.com/proto,gazelle,gazelle/examples/bzlmod_build_file_generation,gazelle/examples/bzlmod_build_file_generation/other_module/other_module/pkg,gazelle/examples/bzlmod_build_file_generation/runfiles,gazelle/manifest,gazelle/manifest/generate,gazelle/manifest/hasher,gazelle/manifest/test,gazelle/modules_mapping,gazelle/python,gazelle/python/private,gazelle/pythonconfig,tests/integration/compile_pip_requirements,tests/integration/compile_pip_requirements_test_from_external_repo,tests/integration/custom_commands,tests/integration/local_toolchains,tests/integration/pip_parse,tests/integration/pip_parse/empty,tests/integration/py_cc_toolchain_registered,tests/modules/another_module,tests/modules/other,tests/modules/other/nspkg_delta,tests/modules/other/nspkg_gamma,tests/modules/other/nspkg_single,tests/modules/other/simple_v1,tests/modules/other/simple_v2,tests/modules/other/with_external_data,tests/whl_with_build_files/testdata,tests/whl_with_build_files/testdata/somepkg,tests/whl_with_build_files/testdata/somepkg-1.0.dist-info,tests/whl_with_build_files/testdata/somepkg/subpkg +# `./tools/update_deleted_packages.sh` +common --deleted_packages=examples/build_file_generation,examples/build_file_generation/random_number_generator,examples/bzlmod,examples/bzlmod/entry_points,examples/bzlmod/entry_points/tests,examples/bzlmod/libs/my_lib,examples/bzlmod/other_module,examples/bzlmod/other_module/other_module/pkg,examples/bzlmod/patches,examples/bzlmod/py_proto_library,examples/bzlmod/py_proto_library/example.com/another_proto,examples/bzlmod/py_proto_library/example.com/proto,examples/bzlmod/py_proto_library/foo_external,examples/bzlmod/runfiles,examples/bzlmod/tests,examples/bzlmod/tests/other_module,examples/bzlmod/whl_mods,examples/multi_python_versions/libs/my_lib,examples/multi_python_versions/requirements,examples/multi_python_versions/tests,examples/pip_parse,examples/pip_parse_vendored,examples/pip_repository_annotations,examples/py_proto_library,examples/py_proto_library/example.com/another_proto,examples/py_proto_library/example.com/proto,tests/integration/compile_pip_requirements,tests/integration/compile_pip_requirements_test_from_external_repo,tests/integration/custom_commands,tests/integration/local_toolchains,tests/integration/pip_parse,tests/integration/pip_parse/empty,tests/integration/py_cc_toolchain_registered,tests/modules/another_module,tests/modules/other,tests/modules/other/nspkg_delta,tests/modules/other/nspkg_gamma,tests/modules/other/nspkg_single,tests/modules/other/simple_v1,tests/modules/other/simple_v2,tests/modules/other/with_external_data test --test_output=errors diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 9aa006bda1..57d31f5f5f 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -48,6 +48,6 @@ repos: language: system # 7.x is necessary until https://github.com/bazel-contrib/rules_bazel_integration_test/pull/414 # is merged and released - entry: bazel run @rules_bazel_integration_test//tools:update_deleted_packages --exclude_dir gazelle/docs + entry: ./tools/update_deleted_packages.sh files: ^((examples|tests)/.*/(MODULE.bazel|WORKSPACE|WORKSPACE.bzlmod|BUILD.bazel)|.bazelrc)$ pass_filenames: false diff --git a/MODULE.bazel b/MODULE.bazel index 0f80b3202e..6e9b725c53 100644 --- a/MODULE.bazel +++ b/MODULE.bazel @@ -215,7 +215,7 @@ use_repo(pip, "rules_python_publish_deps") bazel_dep(name = "stardoc", version = "0.7.2", repo_name = "io_bazel_stardoc") # ===== DEV ONLY DEPS AND SETUP BELOW HERE ===== -bazel_dep(name = "rules_bazel_integration_test", version = "0.34.0", dev_dependency = True) +bazel_dep(name = "rules_bazel_integration_test", version = "0.27.0", dev_dependency = True) bazel_dep(name = "rules_testing", version = "0.6.0", dev_dependency = True) bazel_dep(name = "rules_shell", version = "0.3.0", dev_dependency = True) bazel_dep(name = "rules_multirun", version = "0.9.0", dev_dependency = True) diff --git a/tools/update_deleted_packages.sh b/tools/update_deleted_packages.sh index 17e33d182a..6333776afd 100755 --- a/tools/update_deleted_packages.sh +++ b/tools/update_deleted_packages.sh @@ -23,7 +23,7 @@ # 2. For each of the directories, get all directories that contains a BUILD.bazel file. # 3. Sort and remove duplicates. -set -euxo pipefail +set -euo pipefail DIR="$(dirname $0)/.." cd $DIR @@ -35,5 +35,6 @@ sed -i.bak "/^[^#].*--deleted_packages/s#=.*#=$(\ xargs -n 1 -I{} find {} \( -name BUILD -or -name BUILD.bazel \) | xargs -n 1 dirname | sort -u | + grep -v 'gazelle/docs' | paste -sd, -\ )#" $DIR/.bazelrc && rm .bazelrc.bak From 8d34217d3e0974fff359fefea25a4949328ef7e9 Mon Sep 17 00:00:00 2001 From: Ignas Anikevicius <240938+aignas@users.noreply.github.com> Date: Sat, 22 Nov 2025 14:47:31 +0900 Subject: [PATCH 11/14] split out the deleted packgaes to a separate file --- .bazelrc | 5 ++-- .bazelrc.deleted_packages | 45 ++++++++++++++++++++++++++++++++ tools/update_deleted_packages.sh | 12 ++++----- 3 files changed, 53 insertions(+), 9 deletions(-) create mode 100644 .bazelrc.deleted_packages diff --git a/.bazelrc b/.bazelrc index e93baff4b8..f30f00e306 100644 --- a/.bazelrc +++ b/.bazelrc @@ -2,9 +2,8 @@ # Trick bazel into treating BUILD files under examples/* as being regular files # This lets us glob() up all the files inside the examples to make them inputs to tests # (Note, we cannot use `common --deleted_packages` because the bazel version command doesn't support it) -# To update these lines, execute -# `./tools/update_deleted_packages.sh` -common --deleted_packages=examples/build_file_generation,examples/build_file_generation/random_number_generator,examples/bzlmod,examples/bzlmod/entry_points,examples/bzlmod/entry_points/tests,examples/bzlmod/libs/my_lib,examples/bzlmod/other_module,examples/bzlmod/other_module/other_module/pkg,examples/bzlmod/patches,examples/bzlmod/py_proto_library,examples/bzlmod/py_proto_library/example.com/another_proto,examples/bzlmod/py_proto_library/example.com/proto,examples/bzlmod/py_proto_library/foo_external,examples/bzlmod/runfiles,examples/bzlmod/tests,examples/bzlmod/tests/other_module,examples/bzlmod/whl_mods,examples/multi_python_versions/libs/my_lib,examples/multi_python_versions/requirements,examples/multi_python_versions/tests,examples/pip_parse,examples/pip_parse_vendored,examples/pip_repository_annotations,examples/py_proto_library,examples/py_proto_library/example.com/another_proto,examples/py_proto_library/example.com/proto,tests/integration/compile_pip_requirements,tests/integration/compile_pip_requirements_test_from_external_repo,tests/integration/custom_commands,tests/integration/local_toolchains,tests/integration/pip_parse,tests/integration/pip_parse/empty,tests/integration/py_cc_toolchain_registered,tests/modules/another_module,tests/modules/other,tests/modules/other/nspkg_delta,tests/modules/other/nspkg_gamma,tests/modules/other/nspkg_single,tests/modules/other/simple_v1,tests/modules/other/simple_v2,tests/modules/other/with_external_data +# To update the file, execute +import .bazelrc.deleted_packages test --test_output=errors diff --git a/.bazelrc.deleted_packages b/.bazelrc.deleted_packages new file mode 100644 index 0000000000..131c1cb868 --- /dev/null +++ b/.bazelrc.deleted_packages @@ -0,0 +1,45 @@ +# Generated via './tools/update_deleted_packages.sh' +common --deleted_packages=examples/build_file_generation +common --deleted_packages=examples/build_file_generation/random_number_generator +common --deleted_packages=examples/bzlmod +common --deleted_packages=examples/bzlmod/entry_points +common --deleted_packages=examples/bzlmod/entry_points/tests +common --deleted_packages=examples/bzlmod/libs/my_lib +common --deleted_packages=examples/bzlmod/other_module +common --deleted_packages=examples/bzlmod/other_module/other_module/pkg +common --deleted_packages=examples/bzlmod/patches +common --deleted_packages=examples/bzlmod/py_proto_library +common --deleted_packages=examples/bzlmod/py_proto_library/example.com/another_proto +common --deleted_packages=examples/bzlmod/py_proto_library/example.com/proto +common --deleted_packages=examples/bzlmod/py_proto_library/foo_external +common --deleted_packages=examples/bzlmod/runfiles +common --deleted_packages=examples/bzlmod/tests +common --deleted_packages=examples/bzlmod/tests/other_module +common --deleted_packages=examples/bzlmod/whl_mods +common --deleted_packages=examples/multi_python_versions/libs/my_lib +common --deleted_packages=examples/multi_python_versions/requirements +common --deleted_packages=examples/multi_python_versions/tests +common --deleted_packages=examples/pip_parse +common --deleted_packages=examples/pip_parse_vendored +common --deleted_packages=examples/pip_repository_annotations +common --deleted_packages=examples/py_proto_library +common --deleted_packages=examples/py_proto_library/example.com/another_proto +common --deleted_packages=examples/py_proto_library/example.com/proto +common --deleted_packages=gazelle/examples/bzlmod_build_file_generation +common --deleted_packages=gazelle/examples/bzlmod_build_file_generation/other_module/other_module/pkg +common --deleted_packages=gazelle/examples/bzlmod_build_file_generation/runfiles +common --deleted_packages=tests/integration/compile_pip_requirements +common --deleted_packages=tests/integration/compile_pip_requirements_test_from_external_repo +common --deleted_packages=tests/integration/custom_commands +common --deleted_packages=tests/integration/local_toolchains +common --deleted_packages=tests/integration/pip_parse +common --deleted_packages=tests/integration/pip_parse/empty +common --deleted_packages=tests/integration/py_cc_toolchain_registered +common --deleted_packages=tests/modules/another_module +common --deleted_packages=tests/modules/other +common --deleted_packages=tests/modules/other/nspkg_delta +common --deleted_packages=tests/modules/other/nspkg_gamma +common --deleted_packages=tests/modules/other/nspkg_single +common --deleted_packages=tests/modules/other/simple_v1 +common --deleted_packages=tests/modules/other/simple_v2 +common --deleted_packages=tests/modules/other/with_external_data diff --git a/tools/update_deleted_packages.sh b/tools/update_deleted_packages.sh index 6333776afd..ab7c4e2f2b 100755 --- a/tools/update_deleted_packages.sh +++ b/tools/update_deleted_packages.sh @@ -29,12 +29,12 @@ DIR="$(dirname $0)/.." cd $DIR # The sed -i.bak pattern is compatible between macos and linux -sed -i.bak "/^[^#].*--deleted_packages/s#=.*#=$(\ - find examples/*/* tests/*/* \( -name WORKSPACE -or -name MODULE.bazel \) | +{ + echo "# Generated via './tools/update_deleted_packages.sh'" + find examples/*/* tests/*/* gazelle/examples/*/* \( -name WORKSPACE -or -name MODULE.bazel \) | xargs -n 1 dirname | - xargs -n 1 -I{} find {} \( -name BUILD -or -name BUILD.bazel \) | + xargs -I{} find {} \( -name BUILD -or -name BUILD.bazel \) | xargs -n 1 dirname | sort -u | - grep -v 'gazelle/docs' | - paste -sd, -\ -)#" $DIR/.bazelrc && rm .bazelrc.bak + sed 's/^/common --deleted_packages=/g' +} > "$DIR"/.bazelrc.deleted_packages From ef19ae8091b42dbcac8a0f649a72dbb12a86181f Mon Sep 17 00:00:00 2001 From: Ignas Anikevicius <240938+aignas@users.noreply.github.com> Date: Sat, 22 Nov 2025 15:02:41 +0900 Subject: [PATCH 12/14] fix gazelle package deletion --- .bazelrc.deleted_packages | 9 +++++++++ tools/update_deleted_packages.sh | 7 ++++--- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/.bazelrc.deleted_packages b/.bazelrc.deleted_packages index 131c1cb868..d11f96d664 100644 --- a/.bazelrc.deleted_packages +++ b/.bazelrc.deleted_packages @@ -25,9 +25,18 @@ common --deleted_packages=examples/pip_repository_annotations common --deleted_packages=examples/py_proto_library common --deleted_packages=examples/py_proto_library/example.com/another_proto common --deleted_packages=examples/py_proto_library/example.com/proto +common --deleted_packages=gazelle common --deleted_packages=gazelle/examples/bzlmod_build_file_generation common --deleted_packages=gazelle/examples/bzlmod_build_file_generation/other_module/other_module/pkg common --deleted_packages=gazelle/examples/bzlmod_build_file_generation/runfiles +common --deleted_packages=gazelle/manifest +common --deleted_packages=gazelle/manifest/generate +common --deleted_packages=gazelle/manifest/hasher +common --deleted_packages=gazelle/manifest/test +common --deleted_packages=gazelle/modules_mapping +common --deleted_packages=gazelle/python +common --deleted_packages=gazelle/pythonconfig +common --deleted_packages=gazelle/python/private common --deleted_packages=tests/integration/compile_pip_requirements common --deleted_packages=tests/integration/compile_pip_requirements_test_from_external_repo common --deleted_packages=tests/integration/custom_commands diff --git a/tools/update_deleted_packages.sh b/tools/update_deleted_packages.sh index ab7c4e2f2b..4e5c6d65a9 100755 --- a/tools/update_deleted_packages.sh +++ b/tools/update_deleted_packages.sh @@ -23,7 +23,7 @@ # 2. For each of the directories, get all directories that contains a BUILD.bazel file. # 3. Sort and remove duplicates. -set -euo pipefail +set -euxo pipefail DIR="$(dirname $0)/.." cd $DIR @@ -31,10 +31,11 @@ cd $DIR # The sed -i.bak pattern is compatible between macos and linux { echo "# Generated via './tools/update_deleted_packages.sh'" - find examples/*/* tests/*/* gazelle/examples/*/* \( -name WORKSPACE -or -name MODULE.bazel \) | + find examples tests gazelle \( -name WORKSPACE -or -name MODULE.bazel \) | xargs -n 1 dirname | xargs -I{} find {} \( -name BUILD -or -name BUILD.bazel \) | xargs -n 1 dirname | + grep -v "gazelle/docs" | sort -u | sed 's/^/common --deleted_packages=/g' -} > "$DIR"/.bazelrc.deleted_packages +} | tee "$DIR"/.bazelrc.deleted_packages From f1c91a3fcccd4bdbd2da959f12e956a729734862 Mon Sep 17 00:00:00 2001 From: Ignas Anikevicius <240938+aignas@users.noreply.github.com> Date: Sat, 22 Nov 2025 15:02:56 +0900 Subject: [PATCH 13/14] less verbosity --- tools/update_deleted_packages.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/update_deleted_packages.sh b/tools/update_deleted_packages.sh index 4e5c6d65a9..83bed91d16 100755 --- a/tools/update_deleted_packages.sh +++ b/tools/update_deleted_packages.sh @@ -23,7 +23,7 @@ # 2. For each of the directories, get all directories that contains a BUILD.bazel file. # 3. Sort and remove duplicates. -set -euxo pipefail +set -euo pipefail DIR="$(dirname $0)/.." cd $DIR From 39e064fb855e3f9a7992a55a10c6650c0b0a051d Mon Sep 17 00:00:00 2001 From: Ignas Anikevicius <240938+aignas@users.noreply.github.com> Date: Sat, 22 Nov 2025 21:00:39 +0900 Subject: [PATCH 14/14] fixup --- .bazelrc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.bazelrc b/.bazelrc index f30f00e306..73035548af 100644 --- a/.bazelrc +++ b/.bazelrc @@ -3,7 +3,7 @@ # This lets us glob() up all the files inside the examples to make them inputs to tests # (Note, we cannot use `common --deleted_packages` because the bazel version command doesn't support it) # To update the file, execute -import .bazelrc.deleted_packages +import %workspace%/.bazelrc.deleted_packages test --test_output=errors