Skip to content

Commit 3bd96a9

Browse files
committed
Revert "feat(gazelle): pure golang helper (bazel-contrib#1895)"
This reverts commit 7fc7962. Fixes bazel-contrib#1913
1 parent c84cdf5 commit 3bd96a9

24 files changed

+592
-748
lines changed

CHANGELOG.md

-4
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,6 @@ A brief description of the categories of changes:
3131
marked as `reproducible` and will not include any lock file entries from now
3232
on.
3333

34-
* (gazelle): Remove gazelle plugin's python deps and make it hermetic.
35-
Introduced a new Go-based helper leveraging tree-sitter for syntax analysis.
36-
Implemented the use of `pypi/stdlib-list` for standard library module verification.
37-
3834
### Fixed
3935
* (gazelle) Remove `visibility` from `NonEmptyAttr`.
4036
Now empty(have no `deps/main/srcs/imports` attr) `py_library/test/binary` rules will

gazelle/BUILD.bazel

+8-2
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,24 @@
1-
load("@bazel_gazelle//:def.bzl", "gazelle")
1+
load("@bazel_gazelle//:def.bzl", "DEFAULT_LANGUAGES", "gazelle", "gazelle_binary")
22

33
# Gazelle configuration options.
44
# See https://github.com/bazelbuild/bazel-gazelle#running-gazelle-with-bazel
55
# gazelle:prefix github.com/bazelbuild/rules_python/gazelle
66
# gazelle:exclude bazel-out
77
gazelle(
88
name = "gazelle",
9+
gazelle = ":gazelle_binary",
10+
)
11+
12+
gazelle_binary(
13+
name = "gazelle_binary",
14+
languages = DEFAULT_LANGUAGES + ["//python"],
915
)
1016

1117
gazelle(
1218
name = "gazelle_update_repos",
1319
args = [
1420
"-from_file=go.mod",
15-
"-to_macro=deps.bzl%go_deps",
21+
"-to_macro=deps.bzl%gazelle_deps",
1622
"-prune",
1723
],
1824
command = "update-repos",

gazelle/MODULE.bazel

-18
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,6 @@ bazel_dep(name = "rules_python", version = "0.18.0")
99
bazel_dep(name = "rules_go", version = "0.41.0", repo_name = "io_bazel_rules_go")
1010
bazel_dep(name = "gazelle", version = "0.33.0", repo_name = "bazel_gazelle")
1111

12-
local_path_override(
13-
module_name = "rules_python",
14-
path = "..",
15-
)
16-
1712
go_deps = use_extension("@bazel_gazelle//:extensions.bzl", "go_deps")
1813
go_deps.from_file(go_mod = "//:go.mod")
1914
use_repo(
@@ -22,18 +17,5 @@ use_repo(
2217
"com_github_bmatcuk_doublestar_v4",
2318
"com_github_emirpasic_gods",
2419
"com_github_ghodss_yaml",
25-
"com_github_smacker_go_tree_sitter",
26-
"com_github_stretchr_testify",
2720
"in_gopkg_yaml_v2",
28-
"org_golang_x_sync",
29-
)
30-
31-
python_stdlib_list = use_extension("//python:extensions.bzl", "python_stdlib_list")
32-
use_repo(
33-
python_stdlib_list,
34-
"python_stdlib_list_3_10",
35-
"python_stdlib_list_3_11",
36-
"python_stdlib_list_3_12",
37-
"python_stdlib_list_3_8",
38-
"python_stdlib_list_3_9",
3921
)

gazelle/WORKSPACE

+7-2
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,16 @@ local_repository(
3434
path = "..",
3535
)
3636

37-
load("@rules_python//python:repositories.bzl", "py_repositories")
37+
load("@rules_python//python:repositories.bzl", "py_repositories", "python_register_toolchains")
3838

3939
py_repositories()
4040

41+
python_register_toolchains(
42+
name = "python_3_11",
43+
python_version = "3.11",
44+
)
45+
4146
load("//:deps.bzl", _py_gazelle_deps = "gazelle_deps")
4247

43-
# gazelle:repository_macro deps.bzl%go_deps
48+
# gazelle:repository_macro deps.bzl%gazelle_deps
4449
_py_gazelle_deps()

gazelle/deps.bzl

+23-121
Original file line numberDiff line numberDiff line change
@@ -14,80 +14,27 @@
1414

1515
"This file managed by `bazel run //:gazelle_update_repos`"
1616

17-
load(
18-
"@bazel_gazelle//:deps.bzl",
19-
_go_repository = "go_repository",
20-
)
21-
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_file")
17+
load("@bazel_gazelle//:deps.bzl", _go_repository = "go_repository")
2218

2319
def go_repository(name, **kwargs):
2420
if name not in native.existing_rules():
2521
_go_repository(name = name, **kwargs)
2622

27-
def python_stdlib_list_deps():
28-
"Fetch python stdlib list dependencies"
29-
http_file(
30-
name = "python_stdlib_list_3_8",
31-
sha256 = "ee6dc367011ff298b906dbaab408940aa57086d5f8f47278f4b7523b9aa13ae3",
32-
url = "https://raw.githubusercontent.com/pypi/stdlib-list/8cbc2067a4a0f9eee57fb541e4cd7727724b7db4/stdlib_list/lists/3.8.txt",
33-
downloaded_file_path = "3.8.txt",
34-
)
35-
http_file(
36-
name = "python_stdlib_list_3_9",
37-
sha256 = "a4340e5ffe2e75bb18f548028cef6e6ac15384c44ae0a776e04dd869da1d1fd7",
38-
url = "https://raw.githubusercontent.com/pypi/stdlib-list/8cbc2067a4a0f9eee57fb541e4cd7727724b7db4/stdlib_list/lists/3.9.txt",
39-
downloaded_file_path = "3.9.txt",
40-
)
41-
http_file(
42-
name = "python_stdlib_list_3_10",
43-
sha256 = "0b867738b78ac98944237de2600093a1c6ef259d1810017e46f01a29f3d199e7",
44-
url = "https://raw.githubusercontent.com/pypi/stdlib-list/8cbc2067a4a0f9eee57fb541e4cd7727724b7db4/stdlib_list/lists/3.10.txt",
45-
downloaded_file_path = "3.10.txt",
46-
)
47-
http_file(
48-
name = "python_stdlib_list_3_11",
49-
sha256 = "3c1dbf991b17178d6ed3772f4fa8f64302feaf9c3385fef328a0c7ab736a79b1",
50-
url = "https://raw.githubusercontent.com/pypi/stdlib-list/8cbc2067a4a0f9eee57fb541e4cd7727724b7db4/stdlib_list/lists/3.11.txt",
51-
downloaded_file_path = "3.11.txt",
52-
)
53-
http_file(
54-
name = "python_stdlib_list_3_12",
55-
sha256 = "6d3d53194218b43ee1d04bf9a4f0b6a9309bb59cdcaddede7d9cfe8b6835d34a",
56-
url = "https://raw.githubusercontent.com/pypi/stdlib-list/8cbc2067a4a0f9eee57fb541e4cd7727724b7db4/stdlib_list/lists/3.12.txt",
57-
downloaded_file_path = "3.12.txt",
58-
)
59-
6023
def gazelle_deps():
61-
go_deps()
62-
python_stdlib_list_deps()
63-
64-
def go_deps():
6524
"Fetch go dependencies"
6625
go_repository(
6726
name = "co_honnef_go_tools",
6827
importpath = "honnef.co/go/tools",
6928
sum = "h1:/hemPrYIhOhy8zYrNj+069zDB68us2sMGsfkFJO0iZs=",
7029
version = "v0.0.0-20190523083050-ea95bdfd59fc",
7130
)
72-
go_repository(
73-
name = "com_github_bazelbuild_bazel_gazelle",
74-
importpath = "github.com/bazelbuild/bazel-gazelle",
75-
sum = "h1:ROyUyUHzoEdvoOs1e0haxJx1l5EjZX6AOqiKdVlaBbg=",
76-
version = "v0.31.1",
77-
)
7831

7932
go_repository(
8033
name = "com_github_bazelbuild_buildtools",
8134
build_naming_convention = "go_default_library",
8235
importpath = "github.com/bazelbuild/buildtools",
83-
sum = "h1:HTepWP/jhtWTC1gvK0RnvKCgjh4gLqiwaOwGozAXcbw=",
84-
version = "v0.0.0-20231103205921-433ea8554e82",
85-
)
86-
go_repository(
87-
name = "com_github_bazelbuild_rules_go",
88-
importpath = "github.com/bazelbuild/rules_go",
89-
sum = "h1:JzlRxsFNhlX+g4drDRPhIaU5H5LnI978wdMJ0vK4I+k=",
90-
version = "v0.41.0",
36+
sum = "h1:jhiMzJ+8unnLRtV8rpbWBFE9pFNzIqgUTyZU5aA++w8=",
37+
version = "v0.0.0-20221004120235-7186f635531b",
9138
)
9239

9340
go_repository(
@@ -133,13 +80,6 @@ def go_deps():
13380
sum = "h1:ta993UF76GwbvJcIo3Y68y/M3WxlpEHPWIGDkJYwzJI=",
13481
version = "v0.3.4",
13582
)
136-
go_repository(
137-
name = "com_github_davecgh_go_spew",
138-
importpath = "github.com/davecgh/go-spew",
139-
sum = "h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=",
140-
version = "v1.1.1",
141-
)
142-
14383
go_repository(
14484
name = "com_github_emirpasic_gods",
14585
importpath = "github.com/emirpasic/gods",
@@ -158,12 +98,6 @@ def go_deps():
15898
sum = "h1:EQciDnbrYxy13PgWoY8AqoxGiPrpgBZ1R8UNe3ddc+A=",
15999
version = "v0.1.0",
160100
)
161-
go_repository(
162-
name = "com_github_fsnotify_fsnotify",
163-
importpath = "github.com/fsnotify/fsnotify",
164-
sum = "h1:n+5WquG0fcWoWp6xPWfHdbskMCQaFnG6PfBrh1Ky4HY=",
165-
version = "v1.6.0",
166-
)
167101

168102
go_repository(
169103
name = "com_github_ghodss_yaml",
@@ -180,53 +114,28 @@ def go_deps():
180114
go_repository(
181115
name = "com_github_golang_mock",
182116
importpath = "github.com/golang/mock",
183-
sum = "h1:ErTB+efbowRARo13NNdxyJji2egdxLGQhRaY+DUumQc=",
184-
version = "v1.6.0",
117+
sum = "h1:G5FRp8JnTd7RQH5kemVNlMeyXQAztQ3mOWV95KxsXH8=",
118+
version = "v1.1.1",
185119
)
186120
go_repository(
187121
name = "com_github_golang_protobuf",
188122
importpath = "github.com/golang/protobuf",
189-
sum = "h1:ROPKBNFfQgOUMifHyP+KYbvpjbdoFNs+aK7DXlji0Tw=",
190-
version = "v1.5.2",
123+
sum = "h1:JjCZWpVbqXDqFVmTfYWEVTMIYrL/NPdPSCHPJ0T/raM=",
124+
version = "v1.4.3",
191125
)
192126
go_repository(
193127
name = "com_github_google_go_cmp",
194128
importpath = "github.com/google/go-cmp",
195129
sum = "h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38=",
196130
version = "v0.5.9",
197131
)
198-
go_repository(
199-
name = "com_github_pmezard_go_difflib",
200-
importpath = "github.com/pmezard/go-difflib",
201-
sum = "h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=",
202-
version = "v1.0.0",
203-
)
204132

205133
go_repository(
206134
name = "com_github_prometheus_client_model",
207135
importpath = "github.com/prometheus/client_model",
208136
sum = "h1:gQz4mCbXsO+nc9n1hCxHcGA3Zx3Eo+UHZoInFGUIXNM=",
209137
version = "v0.0.0-20190812154241-14fe0d1b01d4",
210138
)
211-
go_repository(
212-
name = "com_github_smacker_go_tree_sitter",
213-
importpath = "github.com/smacker/go-tree-sitter",
214-
sum = "h1:7QZKUmQfnxncZIJGyvX8M8YeMfn8kM10j3J/2KwVTN4=",
215-
version = "v0.0.0-20240422154435-0628b34cbf9c",
216-
)
217-
go_repository(
218-
name = "com_github_stretchr_objx",
219-
importpath = "github.com/stretchr/objx",
220-
sum = "h1:xuMeJ0Sdp5ZMRXx/aWO6RZxdr3beISkG5/G/aIRr3pY=",
221-
version = "v0.5.2",
222-
)
223-
go_repository(
224-
name = "com_github_stretchr_testify",
225-
importpath = "github.com/stretchr/testify",
226-
sum = "h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg=",
227-
version = "v1.9.0",
228-
)
229-
230139
go_repository(
231140
name = "com_github_yuin_goldmark",
232141
importpath = "github.com/yuin/goldmark",
@@ -251,13 +160,6 @@ def go_deps():
251160
sum = "h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY=",
252161
version = "v2.4.0",
253162
)
254-
go_repository(
255-
name = "in_gopkg_yaml_v3",
256-
importpath = "gopkg.in/yaml.v3",
257-
sum = "h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=",
258-
version = "v3.0.1",
259-
)
260-
261163
go_repository(
262164
name = "net_starlark_go",
263165
importpath = "go.starlark.net",
@@ -279,14 +181,14 @@ def go_deps():
279181
go_repository(
280182
name = "org_golang_google_grpc",
281183
importpath = "google.golang.org/grpc",
282-
sum = "h1:fPVVDxY9w++VjTZsYvXWqEf9Rqar/e+9zYfxKK+W+YU=",
283-
version = "v1.50.0",
184+
sum = "h1:rRYRFMVgRv6E0D70Skyfsr28tDXIuuPZyWGMPdMcnXg=",
185+
version = "v1.27.0",
284186
)
285187
go_repository(
286188
name = "org_golang_google_protobuf",
287189
importpath = "google.golang.org/protobuf",
288-
sum = "h1:w43yiav+6bVFTBQFZX0r7ipe9JQ1QsbMgHwbBziscLw=",
289-
version = "v1.28.0",
190+
sum = "h1:Ejskq+SyPohKW+1uil0JJMtmHCgJPJ/qWTxr8qp+R4c=",
191+
version = "v1.25.0",
290192
)
291193
go_repository(
292194
name = "org_golang_x_crypto",
@@ -309,14 +211,14 @@ def go_deps():
309211
go_repository(
310212
name = "org_golang_x_mod",
311213
importpath = "golang.org/x/mod",
312-
sum = "h1:lFO9qtOdlre5W1jxS3r/4szv2/6iXxScdzjoBMXNhYk=",
313-
version = "v0.10.0",
214+
sum = "h1:6zppjxzCulZykYSLyVDYbneBfbaBIQPYMevg0bEwv2s=",
215+
version = "v0.6.0-dev.0.20220419223038-86c51ed26bb4",
314216
)
315217
go_repository(
316218
name = "org_golang_x_net",
317219
importpath = "golang.org/x/net",
318-
sum = "h1:X2//UzNDwYmtCLn7To6G58Wr6f5ahEAQgKNzv9Y951M=",
319-
version = "v0.10.0",
220+
sum = "h1:PxfKdU9lEEDYjdIzOtC4qFWgkU2rGHdKlKowJSMN9h0=",
221+
version = "v0.0.0-20220722155237-a158d28d115b",
320222
)
321223
go_repository(
322224
name = "org_golang_x_oauth2",
@@ -327,29 +229,29 @@ def go_deps():
327229
go_repository(
328230
name = "org_golang_x_sync",
329231
importpath = "golang.org/x/sync",
330-
sum = "h1:PUR+T4wwASmuSTYdKjYHI5TD22Wy5ogLU5qZCOLxBrI=",
331-
version = "v0.2.0",
232+
sum = "h1:uVc8UZUe6tr40fFVnUP5Oj+veunVezqYl9z7DYw9xzw=",
233+
version = "v0.0.0-20220722155255-886fb9371eb4",
332234
)
333235
go_repository(
334236
name = "org_golang_x_sys",
335237
importpath = "golang.org/x/sys",
336-
sum = "h1:EBmGv8NaZBZTWvrbjNoL6HVt+IVy3QDQpJs7VRIw3tU=",
337-
version = "v0.8.0",
238+
sum = "h1:k5II8e6QD8mITdi+okbbmR/cIyEbeXLBhy5Ha4nevyc=",
239+
version = "v0.0.0-20221010170243-090e33056c14",
338240
)
339241
go_repository(
340242
name = "org_golang_x_text",
341243
importpath = "golang.org/x/text",
342-
sum = "h1:cokOdA+Jmi5PJGXLlLllQSgYigAEfHXJAERHVMaCc2k=",
343-
version = "v0.3.3",
244+
sum = "h1:olpwvP2KacW1ZWvsR7uQhoyTYvKAupfQrRGBFM352Gk=",
245+
version = "v0.3.7",
344246
)
345247
go_repository(
346248
name = "org_golang_x_tools",
347249
build_directives = [
348250
"gazelle:exclude **/testdata/**/*",
349251
],
350252
importpath = "golang.org/x/tools",
351-
sum = "h1:8WMNJAz3zrtPmnYC7ISf5dEn3MT0gY7jBJfw27yrrLo=",
352-
version = "v0.9.1",
253+
sum = "h1:VveCTK38A2rkS8ZqFY25HIDFscX5X9OoEhJd3quQmXU=",
254+
version = "v0.1.12",
353255
)
354256
go_repository(
355257
name = "org_golang_x_xerrors",

gazelle/go.mod

+1-7
Original file line numberDiff line numberDiff line change
@@ -4,23 +4,17 @@ go 1.19
44

55
require (
66
github.com/bazelbuild/bazel-gazelle v0.31.1
7-
github.com/bazelbuild/buildtools v0.0.0-20231103205921-433ea8554e82
7+
github.com/bazelbuild/buildtools v0.0.0-20230510134650-37bd1811516d
88
github.com/bazelbuild/rules_go v0.41.0
99
github.com/bmatcuk/doublestar/v4 v4.6.1
1010
github.com/emirpasic/gods v1.18.1
1111
github.com/ghodss/yaml v1.0.0
12-
github.com/smacker/go-tree-sitter v0.0.0-20240422154435-0628b34cbf9c
13-
github.com/stretchr/testify v1.9.0
14-
golang.org/x/sync v0.2.0
1512
gopkg.in/yaml.v2 v2.4.0
1613
)
1714

1815
require (
19-
github.com/davecgh/go-spew v1.1.1 // indirect
2016
github.com/google/go-cmp v0.5.9 // indirect
21-
github.com/pmezard/go-difflib v1.0.0 // indirect
2217
golang.org/x/mod v0.10.0 // indirect
2318
golang.org/x/sys v0.8.0 // indirect
2419
golang.org/x/tools v0.9.1 // indirect
25-
gopkg.in/yaml.v3 v3.0.1 // indirect
2620
)

0 commit comments

Comments
 (0)