-
Notifications
You must be signed in to change notification settings - Fork 543
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(gazelle): pure golang helper #1895
Conversation
edbbe93
to
15f80a4
Compare
08b3a7a
to
b7080bc
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This change is very exciting, so thank you very much for working on this.
Could you change the PR description to remove the words "pain in the ass", please? This will become a commit message and I would love to keep the git commit messages more formal.
gazelle/def.bzl
Outdated
downloaded_file_path = "3.11.txt", | ||
) | ||
|
||
non_module_deps = module_extension(implementation = non_module_deps_impl) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you use bazel-skylib
1.6.1 you could use the same as was done in #1892.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
gazelle/python/BUILD.bazel
Outdated
# | ||
# See following for more info: | ||
# https://github.com/bazelbuild/bazel-gazelle/issues/1513 | ||
embedsrcs = [":helper.zip"], # keep | ||
embedsrcs = ["stdlib_list.txt"], # keep |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we include more lists and switch based on a value in the gazelle manifest?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not a simple matter. Because there may be multiple python version in monorepo, this may require a new directive. I suggest keeping the status quo in this pr and using stdlist of 3.11.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
SGTM, could you please create an issue in the backlog to add this feature? I agree that having a directive or solving this issue in some way would be useful.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM in general, a few minor additions.
@dougthor42, @linzhp, could you please test this PR in your repos? Does this speed things up? Does it slow things down? Since you two have bigger repos, it would be nice to use them as tests to ensure there are no hidden edge cases. |
Very excited to see this! I will test it in Uber later this week if that's ok. |
Oh this looks really great! Let's see how it does... /cc @ssmall, another Googler who will be using this. SummaryThis branch causes Gazelle to take ~35% of the time, a savings of 40s for me. Hot damn that's awesome!
Background info:
Test:
Before this PR:Commit 55f31a3 $ hyperfine --warmup 1 --runs 5 'bazel run //:gazelle'
Benchmark 1: bazel run //:gazelle
Time (mean ± σ): 60.756 s ± 0.867 s [User: 53.651 s, System: 7.891 s]
Range (min … max): 60.018 s … 61.873 s 5 runs After this PR:Commit f6a190a $ hyperfine --warmup 1 --runs 5 'bazel run //:gazelle'
Benchmark 1: bazel run //:gazelle
Time (mean ± σ): 21.190 s ± 0.174 s [User: 27.083 s, System: 2.679 s]
Range (min … max): 20.964 s … 21.392 s 5 runs |
0272c96
to
7a107e7
Compare
gazelle/python/python_test.go
Outdated
@@ -42,9 +41,10 @@ const ( | |||
gazelleBinaryName = "gazelle_binary" | |||
) | |||
|
|||
var gazellePath = mustFindGazelle() | |||
var gazellePath string |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this necessary? Since this is a global variable, it may be better to set it in TestMain
or as it was done previously?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
var gazellePath = mustFindGazelle()
will make go test .
failed. Although this will not affect bazel test.
I simply modified it, and no longer use global variables. There is no need for global variables here.
gazelle/def.bzl
Outdated
GAZELLE_PYTHON_RUNTIME_DEPS = [ | ||
] | ||
|
||
non_module_deps = modules.as_extension( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you please move this into gazelle/python/private:extensions.bzl
? please? The modules.as_extension
is something that is not our external API within the gazelle plugin, so it should not be a part of def.bzl
.
e0cf1d6
to
78aec8f
Compare
This works in Uber |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thank you so much for this contribution!
This reverts commit 7fc7962. Fixes bazelbuild#1913
Remove gazelle plugin's python deps and make it hermetic. No more relying on the system interpreter.
Use TreeSitter to parse Python code and use https://github.com/pypi/stdlib-list to determine whether a module is in std lib.
Fixes #1825
Fixes #1599
Related #1315