-
-
Notifications
You must be signed in to change notification settings - Fork 591
Fix recursive use of maybe
in pip_repository
rules.
#612
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
Conversation
maybe
.maybe
in pip_repository
rules.
python/pip_install/repositories.bzl
Outdated
type = "zip", | ||
build_file_content = _GENERIC_WHEEL, | ||
) | ||
if not native.existing_rule(name): |
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.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 😄
So you're attempting to do: maybe(
pip_install,
"<name>",
**kwargs,
) is that right? What's the use case? |
I have a repository I'm sharing between different workspaces which uses python. In each workspace loading it, I want the |
@thundergolfer @hrfuller friendly ping 😄 |
@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 |
This is a totally different scenario since
My only goal is to be able to use |
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 |
I don't think users should need to directly use |
Thinking more about |
As one mitigation here, in #531 I'm adding stardoc for the |
@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_parse
orpip_install
with maybe will run into a failure for attempting to use the rule recursively. This can be fixed by avoidingmaybe
in these macro repository rules.Issue Number: N/A
What is the new behavior?
maybe can now be used with
pip_parse
andpip_install
.Does this PR introduce a breaking change?
Other information