cleanup(dev): remove remnants of old bazel_integration_test code (#1668)

The tests have been deleted, so the supporting code is now unused.

Moves the update_deleted_packages script to tools, since it isn't
specific to the bazel_integration_test code.
diff --git a/.bazelrc b/.bazelrc
index 6dc7b87..8f5a80e 100644
--- a/.bazelrc
+++ b/.bazelrc
@@ -2,7 +2,7 @@
 # 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, run tools/bazel_integration_test/update_deleted_packages.sh
+# To update these lines, run tools/update_deleted_packages.sh
 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/dupe_requirements,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/ignore_root_user_error,tests/integration/pip_repository_entry_points
 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/dupe_requirements,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/ignore_root_user_error,tests/integration/pip_repository_entry_points
 
diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml
index e501053..52925a2 100644
--- a/.pre-commit-config.yaml
+++ b/.pre-commit-config.yaml
@@ -42,6 +42,6 @@
       - id: update-deleted-packages
         name: Update deleted packages
         language: script
-        entry: ./tools/bazel_integration_test/update_deleted_packages.sh
-        files: ^((examples|tests)/*/(MODULE.bazel|WORKSPACE|WORKSPACE.bzlmod|BUILD.bazel)|.bazelrc|tools/bazel_integration_test/update_deleted_packages.sh)$
+        entry: ./tools/update_deleted_packages.sh
+        files: ^((examples|tests)/*/(MODULE.bazel|WORKSPACE|WORKSPACE.bzlmod|BUILD.bazel)|.bazelrc|tools/update_deleted_packages.sh)$
         pass_filenames: false
diff --git a/internal_deps.bzl b/internal_deps.bzl
index 72c3986..3044e11 100644
--- a/internal_deps.bzl
+++ b/internal_deps.bzl
@@ -157,15 +157,6 @@
     )
 
     http_archive(
-        name = "build_bazel_integration_testing",
-        urls = [
-            "https://github.com/bazelbuild/bazel-integration-testing/archive/165440b2dbda885f8d1ccb8d0f417e6cf8c54f17.zip",
-        ],
-        strip_prefix = "bazel-integration-testing-165440b2dbda885f8d1ccb8d0f417e6cf8c54f17",
-        sha256 = "2401b1369ef44cc42f91dc94443ef491208dbd06da1e1e10b702d8c189f098e3",
-    )
-
-    http_archive(
         name = "rules_proto",
         sha256 = "dc3fb206a2cb3441b485eb1e423165b231235a1ea9b031b4433cf7bc1fa460dd",
         strip_prefix = "rules_proto-5.3.0-21.7",
diff --git a/internal_setup.bzl b/internal_setup.bzl
index 0c9d6c4..9c6b080 100644
--- a/internal_setup.bzl
+++ b/internal_setup.bzl
@@ -15,10 +15,8 @@
 """Setup for rules_python tests and tools."""
 
 load("@bazel_skylib//:workspace.bzl", "bazel_skylib_workspace")
-load("@build_bazel_integration_testing//tools:repositories.bzl", "bazel_binaries")
 load("@com_google_protobuf//:protobuf_deps.bzl", "protobuf_deps")
 load("@rules_proto//proto:repositories.bzl", "rules_proto_dependencies", "rules_proto_toolchains")
-load("//:version.bzl", "SUPPORTED_BAZEL_VERSIONS")
 load("//python/pip_install:repositories.bzl", "pip_install_dependencies")
 load("//python/private:internal_config_repo.bzl", "internal_config_repo")  # buildifier: disable=bzl-visibility
 
@@ -30,9 +28,6 @@
     # Because we don't use the pip_install rule, we have to call this to fetch its deps
     pip_install_dependencies()
 
-    # Depend on the Bazel binaries for running bazel-in-bazel tests
-    bazel_binaries(versions = SUPPORTED_BAZEL_VERSIONS)
-
     bazel_skylib_workspace()
 
     rules_proto_dependencies()
diff --git a/tools/bazel_integration_test/BUILD.bazel b/tools/bazel_integration_test/BUILD.bazel
deleted file mode 100644
index 10566c4..0000000
--- a/tools/bazel_integration_test/BUILD.bazel
+++ /dev/null
@@ -1 +0,0 @@
-exports_files(["test_runner.py"])
diff --git a/tools/bazel_integration_test/bazel_integration_test.bzl b/tools/bazel_integration_test/bazel_integration_test.bzl
deleted file mode 100644
index c016551..0000000
--- a/tools/bazel_integration_test/bazel_integration_test.bzl
+++ /dev/null
@@ -1,134 +0,0 @@
-# Copyright 2023 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.
-
-"Define a rule for running bazel test under Bazel"
-
-load("//:version.bzl", "SUPPORTED_BAZEL_VERSIONS", "bazel_version_to_binary_label")
-load("//python:defs.bzl", "py_test")
-
-BAZEL_BINARY = bazel_version_to_binary_label(SUPPORTED_BAZEL_VERSIONS[0])
-
-_ATTRS = {
-    "bazel_binary": attr.label(
-        default = BAZEL_BINARY,
-        doc = """The bazel binary files to test against.
-
-It is assumed by the test runner that the bazel binary is found at label_workspace/bazel (wksp/bazel.exe on Windows)""",
-    ),
-    "bazel_commands": attr.string_list(
-        default = ["info", "test --test_output=errors ..."],
-        doc = """The list of bazel commands to run.
-
-Note that if a command contains a bare `--` argument, the --test_arg passed to Bazel will appear before it.
-""",
-    ),
-    "bzlmod": attr.bool(
-        default = False,
-        doc = """Whether the test uses bzlmod.""",
-    ),
-    "workspace_files": attr.label(
-        doc = """A filegroup of all files in the workspace-under-test necessary to run the test.""",
-    ),
-}
-
-def _config_impl(ctx):
-    if len(SUPPORTED_BAZEL_VERSIONS) > 1:
-        fail("""
-        bazel_integration_test doesn't support multiple Bazel versions to test against yet.
-        """)
-    if len(ctx.files.workspace_files) == 0:
-        fail("""
-No files were found to run under integration testing. See comment in /.bazelrc.
-You probably need to run 
-    tools/bazel_integration_test/update_deleted_packages.sh
-""")
-
-    # Serialize configuration file for test runner
-    config = ctx.actions.declare_file("%s.json" % ctx.attr.name)
-    ctx.actions.write(
-        output = config,
-        content = """
-{{
-    "workspaceRoot": "{TMPL_workspace_root}",
-    "bazelBinaryWorkspace": "{TMPL_bazel_binary_workspace}",
-    "bazelCommands": [ {TMPL_bazel_commands} ],
-    "bzlmod": {TMPL_bzlmod}
-}}
-""".format(
-            TMPL_workspace_root = ctx.files.workspace_files[0].dirname,
-            TMPL_bazel_binary_workspace = ctx.attr.bazel_binary.label.workspace_name,
-            TMPL_bazel_commands = ", ".join(["\"%s\"" % s for s in ctx.attr.bazel_commands]),
-            TMPL_bzlmod = str(ctx.attr.bzlmod).lower(),
-        ),
-    )
-
-    return [DefaultInfo(
-        files = depset([config]),
-        runfiles = ctx.runfiles(files = [config]),
-    )]
-
-_config = rule(
-    implementation = _config_impl,
-    doc = "Configures an integration test that runs a specified version of bazel against an external workspace.",
-    attrs = _ATTRS,
-)
-
-def bazel_integration_test(name, override_bazel_version = None, bzlmod = False, dirname = None, **kwargs):
-    """Wrapper macro to set default srcs and run a py_test with config
-
-    Args:
-        name: name of the resulting py_test
-        override_bazel_version: bazel version to use in test
-        bzlmod: whether the test uses bzlmod
-        dirname: the directory name of the test. Defaults to value of `name` after trimming the `_example` suffix.
-        **kwargs: additional attributes like timeout and visibility
-    """
-
-    # By default, we assume sources for "pip_example" are in examples/pip/**/*
-    dirname = dirname or name[:-len("_example")]
-    native.filegroup(
-        name = "_%s_sources" % name,
-        srcs = native.glob(
-            ["%s/**/*" % dirname],
-            exclude = ["%s/bazel-*/**" % dirname],
-        ),
-    )
-    workspace_files = kwargs.pop("workspace_files", "_%s_sources" % name)
-
-    bazel_binary = BAZEL_BINARY if not override_bazel_version else bazel_version_to_binary_label(override_bazel_version)
-    _config(
-        name = "_%s_config" % name,
-        workspace_files = workspace_files,
-        bazel_binary = bazel_binary,
-        bzlmod = bzlmod,
-    )
-
-    tags = kwargs.pop("tags", [])
-    tags.append("integration-test")
-
-    py_test(
-        name = name,
-        srcs = [Label("//tools/bazel_integration_test:test_runner.py")],
-        main = "test_runner.py",
-        args = [native.package_name() + "/_%s_config.json" % name],
-        deps = [Label("//python/runfiles")],
-        data = [
-            bazel_binary,
-            "//:distribution",
-            "_%s_config" % name,
-            workspace_files,
-        ],
-        tags = tags,
-        **kwargs
-    )
diff --git a/tools/bazel_integration_test/test_runner.py b/tools/bazel_integration_test/test_runner.py
deleted file mode 100644
index 3940e87..0000000
--- a/tools/bazel_integration_test/test_runner.py
+++ /dev/null
@@ -1,111 +0,0 @@
-# Copyright 2023 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 os
-import platform
-import re
-import shutil
-import sys
-import tempfile
-import textwrap
-from pathlib import Path
-from subprocess import Popen
-
-from rules_python.python.runfiles import runfiles
-
-r = runfiles.Create()
-
-
-def main(conf_file):
-    with open(conf_file) as j:
-        config = json.load(j)
-
-    isWindows = platform.system() == "Windows"
-    bazelBinary = r.Rlocation(
-        os.path.join(
-            config["bazelBinaryWorkspace"], "bazel.exe" if isWindows else "bazel"
-        )
-    )
-
-    workspacePath = config["workspaceRoot"]
-    # Canonicalize bazel external/some_repo/foo
-    if workspacePath.startswith("external/"):
-        workspacePath = ".." + workspacePath[len("external") :]
-
-    with tempfile.TemporaryDirectory(dir=os.environ["TEST_TMPDIR"]) as tmp_homedir:
-        home_bazel_rc = Path(tmp_homedir) / ".bazelrc"
-        home_bazel_rc.write_text(
-            textwrap.dedent(
-                """\
-                startup --max_idle_secs=1
-                common --announce_rc
-                """
-            )
-        )
-
-        with tempfile.TemporaryDirectory(dir=os.environ["TEST_TMPDIR"]) as tmpdir:
-            workdir = os.path.join(tmpdir, "wksp")
-            print("copying workspace under test %s to %s" % (workspacePath, workdir))
-            shutil.copytree(workspacePath, workdir)
-
-            for command in config["bazelCommands"]:
-                bazel_args = command.split(" ")
-                bazel_args.append(
-                    "--override_repository=rules_python=%s/rules_python"
-                    % os.environ["TEST_SRCDIR"]
-                )
-                bazel_args.append(
-                    "--override_repository=rules_python_gazelle_plugin=%s/rules_python_gazelle_plugin"
-                    % os.environ["TEST_SRCDIR"]
-                )
-
-                # TODO: --override_module isn't supported in the current BAZEL_VERSION (5.2.0)
-                # This condition and attribute can be removed when bazel is updated for
-                # the rest of rules_python.
-                if config["bzlmod"]:
-                    bazel_args.append(
-                        "--override_module=rules_python=%s/rules_python"
-                        % os.environ["TEST_SRCDIR"]
-                    )
-                    bazel_args.append("--enable_bzlmod")
-
-                # Bazel's wrapper script needs this or you get
-                # 2020/07/13 21:58:11 could not get the user's cache directory: $HOME is not defined
-                os.environ["HOME"] = str(tmp_homedir)
-
-                bazel_args.insert(0, bazelBinary)
-                bazel_process = Popen(bazel_args, cwd=workdir)
-                bazel_process.wait()
-                error = bazel_process.returncode != 0
-
-                if platform.system() == "Windows":
-                    # Cleanup any bazel files
-                    bazel_process = Popen([bazelBinary, "clean"], cwd=workdir)
-                    bazel_process.wait()
-                    error |= bazel_process.returncode != 0
-
-                    # Shutdown the bazel instance to avoid issues cleaning up the workspace
-                    bazel_process = Popen([bazelBinary, "shutdown"], cwd=workdir)
-                    bazel_process.wait()
-                    error |= bazel_process.returncode != 0
-
-                if error != 0:
-                    # Test failure in Bazel is exit 3
-                    # https://github.com/bazelbuild/bazel/blob/486206012a664ecb20bdb196a681efc9a9825049/src/main/java/com/google/devtools/build/lib/util/ExitCode.java#L44
-                    sys.exit(3)
-
-
-if __name__ == "__main__":
-    main(sys.argv[1])
diff --git a/tools/bazel_integration_test/update_deleted_packages.sh b/tools/update_deleted_packages.sh
similarity index 97%
rename from tools/bazel_integration_test/update_deleted_packages.sh
rename to tools/update_deleted_packages.sh
index 54db026..17e33d1 100755
--- a/tools/bazel_integration_test/update_deleted_packages.sh
+++ b/tools/update_deleted_packages.sh
@@ -25,7 +25,7 @@
 
 set -euxo pipefail
 
-DIR="$(dirname $0)/../.."
+DIR="$(dirname $0)/.."
 cd $DIR
 
 # The sed -i.bak pattern is compatible between macos and linux