Uh oh!
There was an error while loading. Please reload this page.
Fix recursive use of maybe in pip_repository rules. - #612
Conversation
maybe.maybe in pip_repository rules.| type = "zip", | ||
| build_file_content = _GENERIC_WHEEL, | ||
| ) | ||
| if not native.existing_rule(name): |
There was a problem hiding this comment.
FWIW bazel recommends not using native.existing_rule.
If possible, avoid using this function. It makes BUILD files brittle and order-dependent.
There was a problem hiding this comment.
Also
It seems rules_go has for many years used native.existing_rules to have a 'fake maybe' https://github.com/bazelbuild/rules_go/pull/782/files.
There was a problem hiding this comment.
I think that note is describing common issues in WORKSPACE management. I don't understand why maybe would be ok but not the native functions. One argument might be because maybe can't be used recursively but I think this situation is notably different in that users should be able to treat the pip_repository rules as normal repository rules, but there's some macro magic involved to inject the necessary dependencies. I think the use of these native functions here is fine but I'm also happy to learn better practices 😄
thundergolfer
commented
Feb 1, 2022
So you're attempting to do: maybe(
pip_install,
"<name>",
**kwargs,
)is that right? What's the use case? |
UebelAndre
commented
Feb 1, 2022
I have a repository I'm sharing between different workspaces which uses python. In each workspace loading it, I want the |
UebelAndre
commented
Feb 11, 2022
@thundergolfer@hrfuller friendly ping 😄 |
UebelAndre
commented
Feb 22, 2022
@thundergolfer@hrfuller another ping, would love to get this in 🙏 |
@UebelAndre Still feel uneasy about this. I went on another code search to learn about the use of If the https://github.com/bazelbuild/rules_python/blob/main/python/pip.bzl#L183 |
UebelAndre
commented
Mar 1, 2022
This is a totally different scenario since
My only goal is to be able to use |
thundergolfer
commented
Mar 17, 2022
It's mostly just #612 (comment) Unless we're solving a critical case, opting into functionality the Bazel devs have explicitly advised against seems bad practice. So while you do have a valid case, solving for it might be 'one step forward two steps back' If you opted out of the |
UebelAndre
commented
Mar 17, 2022
I don't think users should need to directly use |
UebelAndre
commented
Mar 17, 2022
Thinking more about |
alexeagle
commented
Apr 22, 2022
As one mitigation here, in #531 I'm adding stardoc for the |
UebelAndre
commented
Apr 22, 2022
@alexeagle I think this change is still useful. I commented on that PR: #531 (comment) |
PR Checklist
Please check if your PR fulfills the following requirements:
PR Type
What kind of change does this PR introduce?
What is the current behavior?
Users trying to wrap
pip_parseorpip_installwith maybe will run into a failure for attempting to use the rule recursively. This can be fixed by avoidingmaybein these macro repository rules.Issue Number: N/A
What is the new behavior?
maybe can now be used with
pip_parseandpip_install.Does this PR introduce a breaking change?
Other information