feat(gazelle)!: Move the plugin to a separate workspace (#972)
feat!(gazelle): Move the plugin to a separate workspace
Summary:
* Move go.mod to gazelle.
* Move gazelle definition.
* Fix file distribution for the gazelle module.
* Update the example test.
* Include rules_python_gazelle_plugin during integration tests
* Update ignored packages
* Update CI configuration
diff --git a/.bazelci/presubmit.yml b/.bazelci/presubmit.yml
index 41c75b7..085a873 100644
--- a/.bazelci/presubmit.yml
+++ b/.bazelci/presubmit.yml
@@ -10,17 +10,11 @@
# As a regression test for #225, check that wheel targets still build when
# their package path is qualified with the repo name.
- "@rules_python//examples/wheel/..."
- - "-//gazelle/..."
build_flags:
- "--keep_going"
test_targets:
- "--"
- "..."
- # The gazelle tests are not compatible with Windows, so we only test them
- # on Linux. The build file generation, which uses this Gazelle extension,
- # runs on all platforms, and is asserted by the build_file_generation
- # integration tests below.
- - "-//gazelle/..."
test_flags:
- "--test_tag_filters=-integration-test"
.reusable_build_test_all: &reusable_build_test_all
@@ -30,8 +24,9 @@
gazelle_extension:
name: Test the Gazelle extension
platform: ubuntu2004
- build_targets: ["//gazelle/..."]
- test_targets: ["//gazelle/..."]
+ build_targets: ["//..."]
+ test_targets: ["//..."]
+ working_directory: gazelle
ubuntu:
<<: *reusable_config
name: Default test on Ubuntu
diff --git a/.github/workflows/workspace_snippet.sh b/.github/workflows/workspace_snippet.sh
index 4837f73..843be7a 100755
--- a/.github/workflows/workspace_snippet.sh
+++ b/.github/workflows/workspace_snippet.sh
@@ -40,7 +40,7 @@
)
\`\`\`
-## Using WORKSPACE:
+## Using WORKSPACE
Paste this snippet into your \`WORKSPACE\` file:
@@ -58,4 +58,18 @@
py_repositories()
\`\`\`
+
+### Gazelle plugin
+
+Paste this snippet into your \`WORKSPACE\` file:
+
+\`\`\`starlark
+load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
+http_archive(
+ name = "rules_python_gazelle_plugin",
+ sha256 = "${SHA}",
+ strip_prefix = "${PREFIX}/gazelle",
+ url = "https://github.com/bazelbuild/rules_python/archive/refs/tags/${TAG}.tar.gz",
+)
+\`\`\`
EOF
diff --git a/.gitignore b/.gitignore
index a68c6f0..bf901e2 100644
--- a/.gitignore
+++ b/.gitignore
@@ -43,10 +43,5 @@
*.swp
*.swo
-# Go/Gazelle files
-# These otherwise match patterns above
-!go.mod
-!BUILD.out
-
# Python cache
**/__pycache__/
diff --git a/BUILD.bazel b/BUILD.bazel
index 5e9b592..fc95328 100644
--- a/BUILD.bazel
+++ b/BUILD.bazel
@@ -12,7 +12,6 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-load("@bazel_gazelle//:def.bzl", "gazelle")
load(":version.bzl", "BAZEL_VERSION")
package(default_visibility = ["//visibility:public"])
@@ -32,10 +31,10 @@
"WORKSPACE",
"internal_deps.bzl",
"internal_setup.bzl",
- "//gazelle:distribution",
"//python:distribution",
"//python/pip_install:distribution",
"//tools:distribution",
+ "@rules_python_gazelle_plugin//:distribution",
],
visibility = [
"//examples:__pkg__",
@@ -61,23 +60,6 @@
visibility = ["//visibility:public"],
)
-# Gazelle configuration options.
-# See https://github.com/bazelbuild/bazel-gazelle#running-gazelle-with-bazel
-# gazelle:prefix github.com/bazelbuild/rules_python
-# gazelle:exclude bazel-out
-# gazelle:exclude examples/**
-gazelle(name = "gazelle")
-
-gazelle(
- name = "gazelle_update_repos",
- args = [
- "-from_file=go.mod",
- "-to_macro=gazelle/deps.bzl%gazelle_deps",
- "-prune",
- ],
- command = "update-repos",
-)
-
genrule(
name = "assert_bazelversion",
srcs = [".bazelversion"],
diff --git a/WORKSPACE b/WORKSPACE
index 1d9d5e4..b7059b6 100644
--- a/WORKSPACE
+++ b/WORKSPACE
@@ -34,11 +34,6 @@
python_versions = MINOR_MAPPING.values(),
)
-load("//gazelle:deps.bzl", "gazelle_deps")
-
-# gazelle:repository_macro gazelle/deps.bzl%gazelle_deps
-gazelle_deps()
-
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
# Used for Bazel CI
@@ -58,3 +53,17 @@
name = "buildkite_config",
toolchain = "ubuntu1804-bazel-java11",
)
+
+local_repository(
+ name = "rules_python_gazelle_plugin",
+ path = "gazelle",
+)
+
+# The rules_python gazelle extension has some third-party go dependencies
+# which we need to fetch in order to compile it.
+load("@rules_python_gazelle_plugin//:deps.bzl", _py_gazelle_deps = "gazelle_deps")
+
+# See: https://github.com/bazelbuild/rules_python/blob/main/gazelle/README.md
+# This rule loads and compiles various go dependencies that running gazelle
+# for python requirements.
+_py_gazelle_deps()
diff --git a/examples/build_file_generation/BUILD.bazel b/examples/build_file_generation/BUILD.bazel
index 6bd1a92..6419ef2 100644
--- a/examples/build_file_generation/BUILD.bazel
+++ b/examples/build_file_generation/BUILD.bazel
@@ -4,11 +4,11 @@
# ruleset. When the symbol is loaded you can use the rule.
load("@bazel_gazelle//:def.bzl", "gazelle")
load("@pip//:requirements.bzl", "all_whl_requirements")
-load("@rules_python//gazelle:def.bzl", "GAZELLE_PYTHON_RUNTIME_DEPS")
-load("@rules_python//gazelle/manifest:defs.bzl", "gazelle_python_manifest")
-load("@rules_python//gazelle/modules_mapping:def.bzl", "modules_mapping")
load("@rules_python//python:defs.bzl", "py_binary", "py_library", "py_test")
load("@rules_python//python:pip.bzl", "compile_pip_requirements")
+load("@rules_python_gazelle_plugin//:def.bzl", "GAZELLE_PYTHON_RUNTIME_DEPS")
+load("@rules_python_gazelle_plugin//manifest:defs.bzl", "gazelle_python_manifest")
+load("@rules_python_gazelle_plugin//modules_mapping:def.bzl", "modules_mapping")
compile_pip_requirements(
name = "requirements",
@@ -53,7 +53,7 @@
gazelle(
name = "gazelle",
data = GAZELLE_PYTHON_RUNTIME_DEPS,
- gazelle = "@rules_python//gazelle:gazelle_python_binary",
+ gazelle = "@rules_python_gazelle_plugin//python:gazelle_binary",
)
# This rule is auto-generated and managed by Gazelle,
diff --git a/examples/build_file_generation/WORKSPACE b/examples/build_file_generation/WORKSPACE
index 1f411d6..674b9eb 100644
--- a/examples/build_file_generation/WORKSPACE
+++ b/examples/build_file_generation/WORKSPACE
@@ -82,6 +82,22 @@
# url = "https://github.com/bazelbuild/rules_python/archive/refs/tags/0.16.1.tar.gz",
# )
+# We import the repository-local rules_python_gazelle_plugin version in order to
+# be able to test development changes to the plugin.
+local_repository(
+ name = "rules_python_gazelle_plugin",
+ path = "../../gazelle",
+)
+
+# When loading the gazelle plugin outside this repo, use the http_archive rule as follows:
+#
+#http_archive(
+# name = "rules_python_gazelle_plugin",
+# sha256 = "497ca47374f48c8b067d786b512ac10a276211810f4a580178ee9b9ad139323a",
+# strip_prefix = "rules_python-0.16.1/gazelle",
+# url = "https://github.com/bazelbuild/rules_python/archive/refs/tags/0.16.1.tar.gz",
+#)
+
# Next we load the toolchain from rules_python.
load("@rules_python//python:repositories.bzl", "python_register_toolchains")
@@ -124,7 +140,7 @@
# The rules_python gazelle extension has some third-party go dependencies
# which we need to fetch in order to compile it.
-load("@rules_python//gazelle:deps.bzl", _py_gazelle_deps = "gazelle_deps")
+load("@rules_python_gazelle_plugin//:deps.bzl", _py_gazelle_deps = "gazelle_deps")
# See: https://github.com/bazelbuild/rules_python/blob/main/gazelle/README.md
# This rule loads and compiles various go dependencies that running gazelle
diff --git a/examples/build_file_generation/gazelle_python.yaml b/examples/build_file_generation/gazelle_python.yaml
index 0be959a..847d1ec 100644
--- a/examples/build_file_generation/gazelle_python.yaml
+++ b/examples/build_file_generation/gazelle_python.yaml
@@ -114,4 +114,4 @@
zipp.py310compat: zipp
pip_repository:
name: pip
-integrity: 4153df7683d64d7d6ad56c14ea1c7f7bec84a2ddf9ef8f075d1bb9313b8d11aa
+integrity: 2c84a3cabeaff134a1d045e5a173a3178086f236ab20f895ffbd7f3b7a6e5bb0
diff --git a/gazelle/.bazelrc b/gazelle/.bazelrc
new file mode 100644
index 0000000..f48d0a9
--- /dev/null
+++ b/gazelle/.bazelrc
@@ -0,0 +1,13 @@
+test --test_output=errors
+
+# 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,
+# excluding the repo root directory. With this flag set, we are responsible for
+# creating (possibly empty) __init__.py files and adding them to the srcs of
+# Python targets as required.
+build --incompatible_default_to_explicit_init_py
+
+# Windows makes use of runfiles for some rules
+build --enable_runfiles
+startup --windows_enable_symlinks
diff --git a/gazelle/.gitignore b/gazelle/.gitignore
new file mode 100644
index 0000000..8481c96
--- /dev/null
+++ b/gazelle/.gitignore
@@ -0,0 +1,12 @@
+# Bazel directories
+/bazel-*
+/bazel-bin
+/bazel-genfiles
+/bazel-out
+/bazel-testlogs
+user.bazelrc
+
+# Go/Gazelle files
+# These otherwise match patterns above
+!go.mod
+!BUILD.out
diff --git a/gazelle/BUILD.bazel b/gazelle/BUILD.bazel
index 8a67e1a..6016145 100644
--- a/gazelle/BUILD.bazel
+++ b/gazelle/BUILD.bazel
@@ -1,22 +1,35 @@
-alias(
- name = "gazelle",
- actual = "//gazelle/python",
- visibility = ["//visibility:public"],
-)
+load("@bazel_gazelle//:def.bzl", "gazelle")
-alias(
- name = "gazelle_python_binary",
- actual = "//gazelle/python:gazelle_binary",
- visibility = ["//visibility:public"],
+# Gazelle configuration options.
+# See https://github.com/bazelbuild/bazel-gazelle#running-gazelle-with-bazel
+# gazelle:prefix github.com/bazelbuild/rules_python/gazelle
+# gazelle:exclude bazel-out
+gazelle(name = "gazelle")
+
+gazelle(
+ name = "gazelle_update_repos",
+ args = [
+ "-from_file=go.mod",
+ "-to_macro=deps.bzl%gazelle_deps",
+ "-prune",
+ ],
+ command = "update-repos",
)
filegroup(
name = "distribution",
- srcs = glob(["**"]) + [
- "//gazelle/manifest:distribution",
- "//gazelle/modules_mapping:distribution",
- "//gazelle/python:distribution",
- "//gazelle/pythonconfig:distribution",
+ srcs = [
+ ":BUILD.bazel",
+ ":README.md",
+ ":WORKSPACE",
+ ":def.bzl",
+ ":deps.bzl",
+ ":go.mod",
+ ":go.sum",
+ "//manifest:distribution",
+ "//modules_mapping:distribution",
+ "//python:distribution",
+ "//pythonconfig:distribution",
],
- visibility = ["//:__pkg__"],
+ visibility = ["@rules_python//:__pkg__"],
)
diff --git a/gazelle/README.md b/gazelle/README.md
index a54db64..a76ac59 100644
--- a/gazelle/README.md
+++ b/gazelle/README.md
@@ -17,9 +17,17 @@
Add this to your `WORKSPACE`:
```starlark
+http_archive(
+ name = "rules_python_gazelle_plugin",
+ sha256 = "",
+ strip_prefix = "rules_python-0.17.0/gazelle",
+ url = "https://github.com/bazelbuild/rules_python/archive/refs/tags/0.17.0.tar.gz",
+)
+
# To compile the rules_python gazelle extension from source,
# we must fetch some third-party go dependencies that it uses.
-load("@rules_python//gazelle:deps.bzl", _py_gazelle_deps = "gazelle_deps")
+
+load("@rules_python_gazelle_plugin//:deps.bzl", _py_gazelle_deps = "gazelle_deps")
_py_gazelle_deps()
```
@@ -40,8 +48,8 @@
```starlark
load("@pip//:requirements.bzl", "all_whl_requirements")
-load("@rules_python//gazelle/manifest:defs.bzl", "gazelle_python_manifest")
-load("@rules_python//gazelle/modules_mapping:def.bzl", "modules_mapping")
+load("@rules_python_gazelle_plugin//manifest:defs.bzl", "gazelle_python_manifest")
+load("@rules_python_gazelle_plugin//modules_mapping:def.bzl", "modules_mapping")
# This rule fetches the metadata for python packages we depend on. That data is
# required for the gazelle_python_manifest rule to update our manifest file.
@@ -75,7 +83,7 @@
```
load("@bazel_gazelle//:def.bzl", "gazelle")
-load("@rules_python//gazelle:def.bzl", "GAZELLE_PYTHON_RUNTIME_DEPS")
+load("@rules_python_gazelle_plugin//:def.bzl", "GAZELLE_PYTHON_RUNTIME_DEPS")
# Our gazelle target points to the python gazelle binary.
# This is the simple case where we only need one language supported.
@@ -85,7 +93,7 @@
gazelle(
name = "gazelle",
data = GAZELLE_PYTHON_RUNTIME_DEPS,
- gazelle = "@rules_python//gazelle:gazelle_python_binary",
+ gazelle = "@rules_python_gazelle_plugin//python:gazelle_binary",
)
```
diff --git a/gazelle/WORKSPACE b/gazelle/WORKSPACE
new file mode 100644
index 0000000..55cf1b0
--- /dev/null
+++ b/gazelle/WORKSPACE
@@ -0,0 +1,47 @@
+workspace(name = "rules_python_gazelle_plugin")
+
+load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
+
+http_archive(
+ name = "io_bazel_rules_go",
+ sha256 = "099a9fb96a376ccbbb7d291ed4ecbdfd42f6bc822ab77ae6f1b5cb9e914e94fa",
+ urls = [
+ "https://mirror.bazel.build/github.com/bazelbuild/rules_go/releases/download/v0.35.0/rules_go-v0.35.0.zip",
+ "https://github.com/bazelbuild/rules_go/releases/download/v0.35.0/rules_go-v0.35.0.zip",
+ ],
+)
+
+http_archive(
+ name = "bazel_gazelle",
+ sha256 = "448e37e0dbf61d6fa8f00aaa12d191745e14f07c31cabfa731f0c8e8a4f41b97",
+ urls = [
+ "https://mirror.bazel.build/github.com/bazelbuild/bazel-gazelle/releases/download/v0.28.0/bazel-gazelle-v0.28.0.tar.gz",
+ "https://github.com/bazelbuild/bazel-gazelle/releases/download/v0.28.0/bazel-gazelle-v0.28.0.tar.gz",
+ ],
+)
+
+load("@bazel_gazelle//:deps.bzl", "gazelle_dependencies")
+load("@io_bazel_rules_go//go:deps.bzl", "go_register_toolchains", "go_rules_dependencies")
+
+go_rules_dependencies()
+
+go_register_toolchains(version = "1.19.4")
+
+gazelle_dependencies()
+
+local_repository(
+ name = "rules_python",
+ path = "..",
+)
+
+load("@rules_python//python:repositories.bzl", "python_register_toolchains")
+
+python_register_toolchains(
+ name = "python39",
+ python_version = "3.9",
+)
+
+load("//:deps.bzl", _py_gazelle_deps = "gazelle_deps")
+
+# gazelle:repository_macro deps.bzl%gazelle_deps
+_py_gazelle_deps()
diff --git a/gazelle/def.bzl b/gazelle/def.bzl
index aa6c23e..bb53c30 100644
--- a/gazelle/def.bzl
+++ b/gazelle/def.bzl
@@ -2,6 +2,6 @@
"""
GAZELLE_PYTHON_RUNTIME_DEPS = [
- "@rules_python//gazelle/python:parse",
- "@rules_python//gazelle/python:std_modules",
+ "@rules_python_gazelle_plugin//python:parse",
+ "@rules_python_gazelle_plugin//python:std_modules",
]
diff --git a/go.mod b/gazelle/go.mod
similarity index 90%
rename from go.mod
rename to gazelle/go.mod
index 0afdf52..322cf0d 100644
--- a/go.mod
+++ b/gazelle/go.mod
@@ -1,4 +1,4 @@
-module github.com/bazelbuild/rules_python
+module github.com/bazelbuild/rules_python/gazelle
go 1.19
diff --git a/go.sum b/gazelle/go.sum
similarity index 100%
rename from go.sum
rename to gazelle/go.sum
diff --git a/gazelle/manifest/BUILD.bazel b/gazelle/manifest/BUILD.bazel
index a769d0d..fc7fa09 100644
--- a/gazelle/manifest/BUILD.bazel
+++ b/gazelle/manifest/BUILD.bazel
@@ -21,8 +21,9 @@
filegroup(
name = "distribution",
srcs = glob(["**"]) + [
- "//gazelle/manifest/generate:distribution",
- "//gazelle/manifest/test:distribution",
+ "//manifest/generate:distribution",
+ "//manifest/hasher:distribution",
+ "//manifest/test:distribution",
],
- visibility = ["//gazelle:__pkg__"],
+ visibility = ["//:__pkg__"],
)
diff --git a/gazelle/manifest/defs.bzl b/gazelle/manifest/defs.bzl
index 57f52f9..3bbcf99 100644
--- a/gazelle/manifest/defs.bzl
+++ b/gazelle/manifest/defs.bzl
@@ -36,7 +36,7 @@
update_target = "{}.update".format(name)
update_target_label = "//{}:{}".format(native.package_name(), update_target)
- manifest_generator_hash = Label("//gazelle/manifest/generate:generate_lib_sources_hash")
+ manifest_generator_hash = Label("//manifest/generate:generate_lib_sources_hash")
update_args = [
"--manifest-generator-hash",
@@ -55,7 +55,7 @@
go_binary(
name = update_target,
- embed = [Label("//gazelle/manifest/generate:generate_lib")],
+ embed = [Label("//manifest/generate:generate_lib")],
data = [
manifest,
modules_mapping,
@@ -71,13 +71,13 @@
go_binary(
name = test_binary,
- embed = [Label("//gazelle/manifest/test:test_lib")],
+ embed = [Label("//manifest/test:test_lib")],
visibility = ["//visibility:private"],
)
native.sh_test(
name = "{}.test".format(name),
- srcs = [Label("//gazelle/manifest/test:run.sh")],
+ srcs = [Label("//manifest/test:run.sh")],
data = [
":{}".format(test_binary),
manifest,
@@ -104,7 +104,7 @@
# buildifier: disable=provider-params
AllSourcesInfo = provider(fields = {"all_srcs": "All sources collected from the target and dependencies."})
-_rules_python_workspace = Label("//:WORKSPACE")
+_rules_python_workspace = Label("@rules_python//:WORKSPACE")
def _get_all_sources_impl(target, ctx):
is_rules_python = target.label.workspace_name == _rules_python_workspace.workspace_name
@@ -148,7 +148,7 @@
),
"_hasher": attr.label(
cfg = "exec",
- default = Label("//gazelle/manifest/hasher"),
+ default = Label("//manifest/hasher"),
executable = True,
),
},
diff --git a/gazelle/manifest/generate/BUILD.bazel b/gazelle/manifest/generate/BUILD.bazel
index 7a5d27f..96248f4 100644
--- a/gazelle/manifest/generate/BUILD.bazel
+++ b/gazelle/manifest/generate/BUILD.bazel
@@ -1,12 +1,12 @@
load("@io_bazel_rules_go//go:def.bzl", "go_binary", "go_library")
-load("//gazelle/manifest:defs.bzl", "sources_hash")
+load("//manifest:defs.bzl", "sources_hash")
go_library(
name = "generate_lib",
srcs = ["generate.go"],
importpath = "github.com/bazelbuild/rules_python/gazelle/manifest/generate",
visibility = ["//visibility:public"],
- deps = ["//gazelle/manifest"],
+ deps = ["//manifest"],
)
sources_hash(
@@ -24,5 +24,5 @@
filegroup(
name = "distribution",
srcs = glob(["**"]),
- visibility = ["//gazelle/manifest:__pkg__"],
+ visibility = ["//manifest:__pkg__"],
)
diff --git a/gazelle/manifest/hasher/BUILD.bazel b/gazelle/manifest/hasher/BUILD.bazel
index 5e67b2f..2e7b125 100644
--- a/gazelle/manifest/hasher/BUILD.bazel
+++ b/gazelle/manifest/hasher/BUILD.bazel
@@ -12,3 +12,9 @@
embed = [":hasher_lib"],
visibility = ["//visibility:public"],
)
+
+filegroup(
+ name = "distribution",
+ srcs = glob(["**"]),
+ visibility = ["//manifest:__pkg__"],
+)
diff --git a/gazelle/manifest/test/BUILD.bazel b/gazelle/manifest/test/BUILD.bazel
index 3f4a535..c8b2828 100644
--- a/gazelle/manifest/test/BUILD.bazel
+++ b/gazelle/manifest/test/BUILD.bazel
@@ -5,7 +5,7 @@
srcs = ["test.go"],
importpath = "github.com/bazelbuild/rules_python/gazelle/manifest/test",
visibility = ["//visibility:public"],
- deps = ["//gazelle/manifest"],
+ deps = ["//manifest"],
)
go_binary(
@@ -19,5 +19,5 @@
filegroup(
name = "distribution",
srcs = glob(["**"]),
- visibility = ["//gazelle/manifest:__pkg__"],
+ visibility = ["//manifest:__pkg__"],
)
diff --git a/gazelle/modules_mapping/BUILD.bazel b/gazelle/modules_mapping/BUILD.bazel
index d4b35c8..1855551 100644
--- a/gazelle/modules_mapping/BUILD.bazel
+++ b/gazelle/modules_mapping/BUILD.bazel
@@ -9,5 +9,5 @@
filegroup(
name = "distribution",
srcs = glob(["**"]),
- visibility = ["//gazelle:__pkg__"],
+ visibility = ["//:__pkg__"],
)
diff --git a/gazelle/modules_mapping/def.bzl b/gazelle/modules_mapping/def.bzl
index 9b1352c..8cffb31 100644
--- a/gazelle/modules_mapping/def.bzl
+++ b/gazelle/modules_mapping/def.bzl
@@ -44,7 +44,7 @@
),
"_generator": attr.label(
cfg = "exec",
- default = "//gazelle/modules_mapping:generator",
+ default = "//modules_mapping:generator",
executable = True,
),
},
diff --git a/gazelle/python/BUILD.bazel b/gazelle/python/BUILD.bazel
index 659f6eb..a2bfb27 100644
--- a/gazelle/python/BUILD.bazel
+++ b/gazelle/python/BUILD.bazel
@@ -22,8 +22,8 @@
importpath = "github.com/bazelbuild/rules_python/gazelle/python",
visibility = ["//visibility:public"],
deps = [
- "//gazelle/manifest",
- "//gazelle/pythonconfig",
+ "//manifest",
+ "//pythonconfig",
"@bazel_gazelle//config:go_default_library",
"@bazel_gazelle//label:go_default_library",
"@bazel_gazelle//language:go_default_library",
@@ -77,5 +77,5 @@
filegroup(
name = "distribution",
srcs = glob(["**"]),
- visibility = ["//gazelle:__pkg__"],
+ visibility = ["//:__pkg__"],
)
diff --git a/gazelle/python/parser.go b/gazelle/python/parser.go
index df4a0fc..fdb34f7 100644
--- a/gazelle/python/parser.go
+++ b/gazelle/python/parser.go
@@ -25,7 +25,7 @@
)
func init() {
- parseScriptRunfile, err := bazel.Runfile("gazelle/python/parse")
+ parseScriptRunfile, err := bazel.Runfile("python/parse")
if err != nil {
log.Printf("failed to initialize parser: %v\n", err)
os.Exit(1)
diff --git a/gazelle/python/python_test.go b/gazelle/python/python_test.go
index 6622bcb..e8edf89 100644
--- a/gazelle/python/python_test.go
+++ b/gazelle/python/python_test.go
@@ -38,7 +38,7 @@
)
const (
- extensionDir = "gazelle" + string(os.PathSeparator) + "python" + string(os.PathSeparator)
+ extensionDir = "python" + string(os.PathSeparator)
testDataPath = extensionDir + "testdata" + string(os.PathSeparator)
gazelleBinaryName = "gazelle_binary"
)
diff --git a/gazelle/python/std_modules.go b/gazelle/python/std_modules.go
index 9ef1ecb..5f4df63 100644
--- a/gazelle/python/std_modules.go
+++ b/gazelle/python/std_modules.go
@@ -26,7 +26,7 @@
func init() {
stdModulesSeen = make(map[string]struct{})
- stdModulesScriptRunfile, err := bazel.Runfile("gazelle/python/std_modules")
+ stdModulesScriptRunfile, err := bazel.Runfile("python/std_modules")
if err != nil {
log.Printf("failed to initialize std_modules: %v\n", err)
os.Exit(1)
diff --git a/gazelle/pythonconfig/BUILD.bazel b/gazelle/pythonconfig/BUILD.bazel
index 9472fd4..79b5121 100644
--- a/gazelle/pythonconfig/BUILD.bazel
+++ b/gazelle/pythonconfig/BUILD.bazel
@@ -9,7 +9,7 @@
importpath = "github.com/bazelbuild/rules_python/gazelle/pythonconfig",
visibility = ["//visibility:public"],
deps = [
- "//gazelle/manifest",
+ "//manifest",
"@bazel_gazelle//label:go_default_library",
"@com_github_emirpasic_gods//lists/singlylinkedlist",
],
@@ -18,5 +18,5 @@
filegroup(
name = "distribution",
srcs = glob(["**"]),
- visibility = ["//gazelle:__pkg__"],
+ visibility = ["//:__pkg__"],
)
diff --git a/internal_deps.bzl b/internal_deps.bzl
index 942a872..15a4f62 100644
--- a/internal_deps.bzl
+++ b/internal_deps.bzl
@@ -34,6 +34,8 @@
strip_prefix = "stardoc-6f274e903009158504a9d9130d7f7d5f3e9421ed",
)
+ # The below two deps are required for the integration test with bazel
+ # gazelle. Maybe the test should be moved to the `gazelle` workspace?
maybe(
http_archive,
name = "io_bazel_rules_go",
diff --git a/internal_setup.bzl b/internal_setup.bzl
index 57eecc2..c3a7ad4 100644
--- a/internal_setup.bzl
+++ b/internal_setup.bzl
@@ -14,14 +14,11 @@
"""Setup for rules_python tests and tools."""
-load("@bazel_gazelle//:deps.bzl", "gazelle_dependencies")
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("@io_bazel_rules_go//go:deps.bzl", "go_register_toolchains", "go_rules_dependencies")
load("@rules_proto//proto:repositories.bzl", "rules_proto_dependencies", "rules_proto_toolchains")
load("//:version.bzl", "SUPPORTED_BAZEL_VERSIONS")
-load("//gazelle:deps.bzl", _go_repositories = "gazelle_deps")
load("//python/pip_install:repositories.bzl", "pip_install_dependencies")
def rules_python_internal_setup():
@@ -35,15 +32,6 @@
bazel_skylib_workspace()
- # gazelle:repository_macro gazelle/deps.bzl%gazelle_deps
- _go_repositories()
-
- go_rules_dependencies()
-
- go_register_toolchains(version = "1.19.2")
-
- gazelle_dependencies()
-
rules_proto_dependencies()
rules_proto_toolchains()
diff --git a/tools/bazel_integration_test/test_runner.py b/tools/bazel_integration_test/test_runner.py
index fbc27e4..27abf1f 100644
--- a/tools/bazel_integration_test/test_runner.py
+++ b/tools/bazel_integration_test/test_runner.py
@@ -52,6 +52,10 @@
"--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