-
Notifications
You must be signed in to change notification settings - Fork 528
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
Support gazelle plugin when using bzlmod #965
Comments
This changes the label strings that the users would get when loading the `all_requirements` and `all_whl_requirements` from the generated `requirements.bzl`. Previous labels were not really useable under bzlmod, because they would not be visible to the consumer. Work towards bazelbuild#965
Allow setting conventions for each part of the external repo labels. This is also useful when creating multi-platform alias targets when using an approach described in 2022 bazelcon [1]. [1]: https://www.youtube.com/watch?v=Bjaiu8tZZhs Work towards bazelbuild#965.
Work towards bazelbuild#965.
Some ideas that came from the comment in #970. Regarding the metadata for gazelle to consume from the
Thinking from outside-in, I'd like to use something like below in my BUILD.bazel files: # BUILD.bazel contents
load("@pip//:gazelle.bzl", "gazelle_python_manifest")
load("@gazelle//:def.bzl", "gazelle", "gazelle_binary")
load("@rules_python//gazelle:defs.bzl", "GAZELLE_PYTHON_RUNTIME_DEPS")
# This macro could read the metadata within the '@pip//:gazelle.bzl' which would have the
# following info:
# - The whl library list needed for gazelle.
# - The name of the pip repository.
# - The pip repo naming convention, thus eliminating the need for some of the
# PRs in the series.
# - The '//:requirements_lock.txt' could be also infered as we pass it to `pip_parse` anyway.
gazelle_python_manifest(
name = "gazelle_python_manifest",
extend_exclude_patterns = [
"(\\tests)+", # There are many packages on PyPI with tests in their wheels
],
)
gazelle_binary(
name = "gazelle_bin",
extend_languages = [
"@rules_python//gazelle",
],
)
gazelle(
name = "gazelle",
data = GAZELLE_PYTHON_RUNTIME_DEPS,
binary = ":gazelle_bin",
) I'll play around with the idea of having gazelle macro come from the output of |
For your #1, rules_python must not introduce a Go dependency for all users. The situation is the same as for bazel-skylib, which has a Gazelle extension for creating |
Thanks @alexeagle, will change the approach in #968. I was under an impression, that the dependencies will be lazy-fetched anyway, so there is no harm. |
Work towards bazelbuild#965
Work towards bazelbuild#965
This changes the label strings that the users would get when loading the `all_requirements` and `all_whl_requirements` from the generated `requirements.bzl`. Previous labels were not really useable under bzlmod, because they would not be visible to the consumer. Work towards bazelbuild#965
Work towards bazelbuild#965
This changes the label strings that the users would get when loading the `all_requirements` and `all_whl_requirements` from the generated `requirements.bzl`. Previous labels were not really useable under bzlmod, because they would not be visible to the consumer. Work towards bazelbuild#965
Work towards bazelbuild#965
@alexeagle, #972 moves |
It seems that the approach described in one of my first comments should be changed given that there is a tool for easily managing the
The changes in #971, #970, #967, #966 would be not needed if |
My understanding is that Instead gazelle should load through the |
This is in order to make bazelbuild#972 easier to review. This PR is only moving files and addressing a few small review comments made in the initial review of bazelbuild#972. Work towards bazelbuild#965.
This is in order to make bazelbuild#972 easier to review. This PR is only moving files and addressing a few small review comments made in the initial review of bazelbuild#972. Work towards bazelbuild#965.
This is in order to make bazelbuild#972 easier to review. This PR is only moving files and addressing a few small review comments made in the initial review of bazelbuild#972. Work towards bazelbuild#965.
This is in order to make bazelbuild#972 easier to review. This PR is only moving files and addressing a few small review comments made in the initial review of bazelbuild#972. Work towards bazelbuild#965.
This changes the label strings that the users would get when loading the `all_requirements` and `all_whl_requirements` from the generated `requirements.bzl`. Previous labels were not really useable under bzlmod, because they would not be visible to the consumer. Work towards bazelbuild#965
So given that #1043 has gone through a review process, I went ahead and created a POC gazelle support for bzlmod. It is currently in https://github.com/aignas/rules_python/tree/gazelle-bzlmod. Having a backwards compatible API is important and having 2 flags that can be passed to The whole architecture is:
The change is still a little big for my tastes, but not sure yet what would be the best way to split it for easy review.
|
🚀 feature request
Creating this issue to encompass all of the PRs related to this feature, as the single research PR (#961) got a little bit too big for easy review.
Relevant Rules
gazelle
Python plugin.Description
Currently the
gazelle
plugin does not work if usingbzlmod
withbazel >= 6.0.0
. This is due to:MODULE.bazel
ofrules_python
, which means that the plugin reference fails.all_whl_requirements
have labels, that do not work inbzlmod
due to repository remapping. Hence, themodules_mapping
rule fails unless we do something about it.bzlmod
due to repository remapping.Describe the solution you'd like
As researched in #961, we can fix these three issues separately:
all_whl_requirements
andall_requirements
based on wetherbzlmod
is used.@pip
repo that work with both,bzlmod
and classic gazelle. This might be similar to feat: add alias generation for pip parse #814, however this is not a requirement to make gazelle withbzlmod
work.Describe alternatives you've considered
Rejected alternatives:
gazelle_python.yaml
manifest, which would say that we are usingbzlmod
. The manifest should be the same irrespective of whether we are usingbzlmod
or not due to the same reason why we may want to have aliases in@pip
repo -- because we want to enable a smooth transition tobzlmod
as described in the migration guideThe text was updated successfully, but these errors were encountered: