From c92c0776be58855acecd82a172cebe61a83cdb40 Mon Sep 17 00:00:00 2001 From: Richard Levasseur Date: Tue, 25 Nov 2025 20:03:30 -0800 Subject: [PATCH 1/2] refactor: uncouple gazelle plugin from rules_python itself --- BUILD.bazel | 2 +- MODULE.bazel | 12 +++++----- tests/integration/BUILD.bazel | 44 +++++++++++++++++------------------ 3 files changed, 29 insertions(+), 29 deletions(-) diff --git a/BUILD.bazel b/BUILD.bazel index 5e85c27b3c..b1411c4381 100644 --- a/BUILD.bazel +++ b/BUILD.bazel @@ -45,7 +45,7 @@ filegroup( "version.bzl", "//python:distribution", "//tools:distribution", - "@rules_python_gazelle_plugin//:distribution", + ##"@rules_python_gazelle_plugin//:distribution", ], visibility = [ "//:__subpackages__", diff --git a/MODULE.bazel b/MODULE.bazel index 6e9b725c53..8c6167a15b 100644 --- a/MODULE.bazel +++ b/MODULE.bazel @@ -227,8 +227,8 @@ bazel_dep(name = "another_module", version = "0", dev_dependency = True) # Extra gazelle plugin deps so that WORKSPACE.bzlmod can continue including it for e2e tests. # We use `WORKSPACE.bzlmod` because it is impossible to have dev-only local overrides. bazel_dep(name = "rules_go", version = "0.41.0", dev_dependency = True, repo_name = "io_bazel_rules_go") -bazel_dep(name = "rules_python_gazelle_plugin", version = "0", dev_dependency = True) -bazel_dep(name = "gazelle", version = "0.40.0", dev_dependency = True, repo_name = "bazel_gazelle") +##bazel_dep(name = "rules_python_gazelle_plugin", version = "0", dev_dependency = True) +##bazel_dep(name = "gazelle", version = "0.40.0", dev_dependency = True, repo_name = "bazel_gazelle") internal_dev_deps = use_extension( "//python/private:internal_dev_deps.bzl", @@ -260,10 +260,10 @@ dev_rules_python_config.add_transition_setting( # Add gazelle plugin so that we can run the gazelle example as an e2e integration # test and include the distribution files. -local_path_override( - module_name = "rules_python_gazelle_plugin", - path = "gazelle", -) +##local_path_override( +## module_name = "rules_python_gazelle_plugin", +## path = "gazelle", +##) local_path_override( module_name = "other", diff --git a/tests/integration/BUILD.bazel b/tests/integration/BUILD.bazel index 673312903d..c3585e2a0d 100644 --- a/tests/integration/BUILD.bazel +++ b/tests/integration/BUILD.bazel @@ -23,13 +23,13 @@ _WORKSPACE_FLAGS = [ "--enable_workspace", ] -_WORKSPACE_GAZELLE_PLUGIN_FLAGS = [ - "--override_repository=rules_python_gazelle_plugin=../../../rules_python_gazelle_plugin", -] +##_WORKSPACE_GAZELLE_PLUGIN_FLAGS = [ +## "--override_repository=rules_python_gazelle_plugin=../../../rules_python_gazelle_plugin", +##] -_GAZELLE_PLUGIN_FLAGS = [ - "--override_module=rules_python_gazelle_plugin=../../../rules_python_gazelle_plugin", -] +##_GAZELLE_PLUGIN_FLAGS = [ +## "--override_module=rules_python_gazelle_plugin=../../../rules_python_gazelle_plugin", +##] default_test_runner( name = "workspace_test_runner", @@ -40,28 +40,28 @@ default_test_runner( visibility = ["//visibility:public"], ) -default_test_runner( - name = "workspace_test_runner_gazelle_plugin", - bazel_cmds = [ - "info {}".format(" ".join(_WORKSPACE_FLAGS + _WORKSPACE_GAZELLE_PLUGIN_FLAGS)), - "test {} //...".format(" ".join(_WORKSPACE_FLAGS + _WORKSPACE_GAZELLE_PLUGIN_FLAGS)), - ], - visibility = ["//visibility:public"], -) +##default_test_runner( +## name = "workspace_test_runner_gazelle_plugin", +## bazel_cmds = [ +## "info {}".format(" ".join(_WORKSPACE_FLAGS + _WORKSPACE_GAZELLE_PLUGIN_FLAGS)), +## "test {} //...".format(" ".join(_WORKSPACE_FLAGS + _WORKSPACE_GAZELLE_PLUGIN_FLAGS)), +## ], +## visibility = ["//visibility:public"], +##) default_test_runner( name = "test_runner", visibility = ["//visibility:public"], ) -default_test_runner( - name = "test_runner_gazelle_plugin", - bazel_cmds = [ - "info {}".format(" ".join(_GAZELLE_PLUGIN_FLAGS)), - "test {} //...".format(" ".join(_GAZELLE_PLUGIN_FLAGS)), - ], - visibility = ["//visibility:public"], -) +##default_test_runner( +## name = "test_runner_gazelle_plugin", +## bazel_cmds = [ +## "info {}".format(" ".join(_GAZELLE_PLUGIN_FLAGS)), +## "test {} //...".format(" ".join(_GAZELLE_PLUGIN_FLAGS)), +## ], +## visibility = ["//visibility:public"], +##) # TODO: add compile_pip_requirements_test_from_external_repo From 9c1e83714eff14f04d4affe012cc3ec0e4327290 Mon Sep 17 00:00:00 2001 From: Richard Levasseur Date: Tue, 25 Nov 2025 23:21:13 -0800 Subject: [PATCH 2/2] remove code --- BUILD.bazel | 1 - MODULE.bazel | 9 --------- tests/integration/BUILD.bazel | 28 -------------------------- tests/integration/integration_test.bzl | 11 ++-------- 4 files changed, 2 insertions(+), 47 deletions(-) diff --git a/BUILD.bazel b/BUILD.bazel index b1411c4381..aa2642d43f 100644 --- a/BUILD.bazel +++ b/BUILD.bazel @@ -45,7 +45,6 @@ filegroup( "version.bzl", "//python:distribution", "//tools:distribution", - ##"@rules_python_gazelle_plugin//:distribution", ], visibility = [ "//:__subpackages__", diff --git a/MODULE.bazel b/MODULE.bazel index 8c6167a15b..b909124d11 100644 --- a/MODULE.bazel +++ b/MODULE.bazel @@ -227,8 +227,6 @@ bazel_dep(name = "another_module", version = "0", dev_dependency = True) # Extra gazelle plugin deps so that WORKSPACE.bzlmod can continue including it for e2e tests. # We use `WORKSPACE.bzlmod` because it is impossible to have dev-only local overrides. bazel_dep(name = "rules_go", version = "0.41.0", dev_dependency = True, repo_name = "io_bazel_rules_go") -##bazel_dep(name = "rules_python_gazelle_plugin", version = "0", dev_dependency = True) -##bazel_dep(name = "gazelle", version = "0.40.0", dev_dependency = True, repo_name = "bazel_gazelle") internal_dev_deps = use_extension( "//python/private:internal_dev_deps.bzl", @@ -258,13 +256,6 @@ dev_rules_python_config.add_transition_setting( setting = "//tests/multi_pypi:external_deps_name", ) -# Add gazelle plugin so that we can run the gazelle example as an e2e integration -# test and include the distribution files. -##local_path_override( -## module_name = "rules_python_gazelle_plugin", -## path = "gazelle", -##) - local_path_override( module_name = "other", path = "tests/modules/other", diff --git a/tests/integration/BUILD.bazel b/tests/integration/BUILD.bazel index c3585e2a0d..f0f58daa3a 100644 --- a/tests/integration/BUILD.bazel +++ b/tests/integration/BUILD.bazel @@ -23,14 +23,6 @@ _WORKSPACE_FLAGS = [ "--enable_workspace", ] -##_WORKSPACE_GAZELLE_PLUGIN_FLAGS = [ -## "--override_repository=rules_python_gazelle_plugin=../../../rules_python_gazelle_plugin", -##] - -##_GAZELLE_PLUGIN_FLAGS = [ -## "--override_module=rules_python_gazelle_plugin=../../../rules_python_gazelle_plugin", -##] - default_test_runner( name = "workspace_test_runner", bazel_cmds = [ @@ -40,31 +32,11 @@ default_test_runner( visibility = ["//visibility:public"], ) -##default_test_runner( -## name = "workspace_test_runner_gazelle_plugin", -## bazel_cmds = [ -## "info {}".format(" ".join(_WORKSPACE_FLAGS + _WORKSPACE_GAZELLE_PLUGIN_FLAGS)), -## "test {} //...".format(" ".join(_WORKSPACE_FLAGS + _WORKSPACE_GAZELLE_PLUGIN_FLAGS)), -## ], -## visibility = ["//visibility:public"], -##) - default_test_runner( name = "test_runner", visibility = ["//visibility:public"], ) -##default_test_runner( -## name = "test_runner_gazelle_plugin", -## bazel_cmds = [ -## "info {}".format(" ".join(_GAZELLE_PLUGIN_FLAGS)), -## "test {} //...".format(" ".join(_GAZELLE_PLUGIN_FLAGS)), -## ], -## visibility = ["//visibility:public"], -##) - -# TODO: add compile_pip_requirements_test_from_external_repo - rules_python_integration_test( name = "compile_pip_requirements_test", ) diff --git a/tests/integration/integration_test.bzl b/tests/integration/integration_test.bzl index 90cc4a3fb7..771976d037 100644 --- a/tests/integration/integration_test.bzl +++ b/tests/integration/integration_test.bzl @@ -21,7 +21,7 @@ load( ) load("//python:py_test.bzl", "py_test") -def _test_runner(*, name, bazel_version, py_main, bzlmod, gazelle_plugin): +def _test_runner(*, name, bazel_version, py_main, bzlmod): if py_main: test_runner = "{}_bazel_{}_py_runner".format(name, bazel_version) py_test( @@ -35,12 +35,8 @@ def _test_runner(*, name, bazel_version, py_main, bzlmod, gazelle_plugin): ) return test_runner - if bzlmod and gazelle_plugin: - return "//tests/integration:test_runner_gazelle_plugin" - elif bzlmod: + if bzlmod: return "//tests/integration:test_runner" - elif gazelle_plugin: - return "//tests/integration:workspace_test_runner_gazelle_plugin" else: return "//tests/integration:workspace_test_runner" @@ -48,7 +44,6 @@ def rules_python_integration_test( name, workspace_path = None, bzlmod = True, - gazelle_plugin = False, tags = None, py_main = None, bazel_versions = None, @@ -61,7 +56,6 @@ def rules_python_integration_test( `_test` suffix. bzlmod: bool, default True. If true, run with bzlmod enabled, otherwise disable bzlmod. - gazelle_plugin: Whether the test uses the gazelle plugin. tags: Test tags. py_main: Optional `.py` file to run tests using. When specified, a python based test runner is used, and this source file is the main @@ -98,7 +92,6 @@ def rules_python_integration_test( bazel_version = bazel_version, py_main = py_main, bzlmod = bzlmod, - gazelle_plugin = gazelle_plugin, ) bazel_integration_test( name = "{}_bazel_{}".format(name, bazel_version),