-
Notifications
You must be signed in to change notification settings - Fork 563
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
Allow python_register_toolchains.name
to be the resolved interpreter repo
#656
Conversation
I don't like this, but I'll let others chime in. Without the |
Thanks for the quick response! I mostly don't like the feeling that the only repository rule I'll generally interact with is magically created for me. In most cases, I'm not married to this change though but do think it's less burden-of-knowledge, which I like. |
I do agree with @UebelAndre that this breaks Bazel user expectations about repository rules:
Currently the rule doesn't produce a |
This goes all the way back to the template I don't see a good reason why that macro doesn't include the given name in its expansion, like the macro style guide indicates. Naming the "default" repository as the thing most users want to use makes sense to me. In many cases users don't think about the nuances of host/target/exec platforms anyway. More sophisticated users who do care about that will likely be able to read documentation explaining that the default repository is the one that toolchain selection would pick for the host. |
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.
personally find it much more intuitive ...
Yeah, I generally agree with this sentiment, and the thing the user cares about is the "resolved" version, not strictly the toolchain (which is kinda abstracted anyway).
An alternative is to add further alias
targets manually, eg //python:default
to be the interpreter etc.
eg at one client we have multiple interpreter versions in a single graph, so //python:default
, //python:py37
etc are all aliased to the interpreter bin, and can create a more intuitive bazel run
statement.
Generally it's a bad practice that the user calls a repository rule (nodejs_register_toolchains) with a name, and this doesn't result in a repository with that name. Leave the old _host variant around to make this a non-breaking change. We did the same fix in python: bazelbuild/rules_python#656 Fixes #3375
Generally it's a bad practice that the user calls a repository rule (nodejs_register_toolchains) with a name, and this doesn't result in a repository with that name. Leave the old _host variant around to make this a non-breaking change. We did the same fix in python: bazelbuild/rules_python#656 Fixes #3375
Generally it's a bad practice that the user calls a repository rule (nodejs_register_toolchains) with a name, and this doesn't result in a repository with that name. Leave the old _host variant around to make this a non-breaking change. We did the same fix in python: bazelbuild/rules_python#656 Fixes #3375
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?
Currently documentation suggests that users write the following in their WORKSPACE file to produce a python toolchain
This then creates a "magic" repository called
python3_9_resolved_interpreter
, which is based on thename
value. I call it magic because it's generally the next thing users want to use in their workspaces (needing to load dependencies viapip_repository
rules) but will need to read docs to find the_resolved_interpreter
name. I personally find it much more intuitive to allow anything that's called in a WORKSPACE and has aname
parameter to actually create a repository matching that name. This makes things more discoverable and easier to maintain.Issue Number: N/A
What is the new behavior?
This change introduces a second
resolved_interpreter_os_alias
rule which just uses thename
attribute as it's name instead. This has the added benefit of allowing users to wrap the macro inmaybe
to avoid redundant calls to these repository rules.Does this PR introduce a breaking change?
Other information