-
Notifications
You must be signed in to change notification settings - Fork 25
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
Compatibility with rules_python_gazelle_plugin
#100
Comments
I provided some of my thoughts about the layout here. The other issue you'll run into is dashes vs. underscores. A few options:
I think 1 is the best option, but I don't know anything about its feasibility. 2 may be useful for other aspects of peoples' migrations. 3 I think is the most straightforward and self-contained option, and I'd probably start there. |
I extended jq(
name = "gazelle.metadata",
srcs = [":__gazelle.metadata"],
filter = 'with_entries(.value |= ":\\(. | gsub(\"[-_.]+\"; \"-\") | ascii_downcase)")',
) and
but > bazel run //:gazelle.check
--- app/BUILD.bazel 1970-01-01 00:00:00.000000001 +0000
+++ app/BUILD.bazel 1970-01-01 00:00:00.000000001 +0000
@@ -6,6 +6,7 @@
visibility = ["//:__subpackages__"],
deps = [
"@pip//:flask",
+ "@pip//:python_dateutil",
],
) Which is very sad :( Update: found the place where this happens. |
After a discussion in bazelbuild/rules_python#1939, I contributed some directives that can change Gazelle plugin's label conventions and it works with Until then, Bazel 7.2.0+ users can use the plugin revision from PR's repo: bazel_dep(name = "rules_python_gazelle_plugin", version = "0.0.0")
git_override(
module_name = "rules_python_gazelle_plugin",
commit = "1cc0168b57fb88faa97711081edb071c6bd23260",
remote = "https://github.com/wingsofovnia/rules_python",
strip_prefix = "gazelle", # New to Bazel 7.2.0+
) and apply in your # gazelle:python_label_convention :$distribution_name$
# gazelle:python_label_normalization pep503 I've also updated the example mentioned in the post to use this plugin's revision if anyone is interested: |
Thanks for working on that! |
Very nice |
Hi @wingsofovnia, can this be closed now? |
Yes, this has been resolved. Shall I update the README.md with a Gazelle how-to? |
That would be great, thanks! |
I'm failing to get gazelle to work as advertised. I get errors like
|
From the stack trace it doesn't look like a gazelle problem. The error seems to come from poetry resolver. Can you run |
I am currently replacing rules_python in a rules_python + rules_python_gazelle_plugin + rules_py setup with rules_pycross and found some challenges in making
rules_python_gazelle_plugin
work with rules_pycross.all_whl_requirements
needed formodules_mapping
, a Python Gazelle - related rule to generate metadata needed for creating Gazelle mappingWith this improvement, pycross can be plugged in into Gazelle.
MODULE.bazel
BUILD.bazel
The missing piece is that rules_pycross has whl targets structured differently than ones in rules_python, expected by Gazelle plugin.
There was an attempt to align pycross whl targets with ones in rules_python which was declined (for a good reason):
Essentially, we need to prefix with
:
. I was able to workaround this by simply putting a genrule in the middle doing exactly that:This might be a very optimistic look at that and only work with a small set of dependencies I tested in a PoC project. See the working example: https://github.com/wingsofovnia/bazel-pycross-poetry-gazelle-example
I decided to start this issue to outline issues, some workarounds and gather feedback on possible directions to improve the setup.
@ewianda for viz as you've been probably trying to achieve similar goal.
The text was updated successfully, but these errors were encountered: