-
Notifications
You must be signed in to change notification settings - Fork 542
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
Implement hermetic toolchain with bzlmod - toolchain not configurable work on different platforms #1161
Comments
Paging @alexeagle, @kormide, and @aignas to see if anyone has ideas on how to do this. |
I have verified this problem on both Linux and Windows. I am getting the error:
When I don't have a python binary installed. |
This is not implemented yet. See bazelbuild/rules_rust#1528 for how rust implemented the functionality |
Just curious: would this be the reason why |
@gferon it allows you to have 3.10 installed on the host but use 3.9 in the repo for example. It also allows you to register an OS specific toolchain. |
Here is what I have discovered. The pip extension does not have the capability to have the tool chain set dynamically. A use case that you would want the tool chain set dynamically is when you would have developers or the project built on different operating systems. There are multiple factors in considering this support.
I have started to assess these features in #1155 From that PR I have added a parameter to the pip arguments that allows a user to configure a toolchain. The user rights an extension and a rule which creates a text file which contains the name of the Label for the interpreter. Not happy with the elegance of the solution, but it works. The challenge is also we have a call to load the toolchain for every OS that the project supports. Bazel as of 6.2 will have the support of dynamically adding “use_repo” statements, so a user code write a rule to do this dynamically. But imo is a lot for the user to do. All of this was supported previous to bzlmod, but now bzlmod does not have support for native.register_tooclhain. As designed. Options Other rules have added support for bzlmod in a hub spoke manner where they are confirguring the toolchain for the user bazelbuild/rules_rust#1528 But this may not work for us, with our multiple python version support. What I recommend initially is that we move more of the grunt work for a user. The work in my PR can move inside our extension and the user tells the tule to do it. Once blzmod supports dynamically adding “use_repos” we then do that. |
#1155 starts the work. We may have to have an extension in the user's module because the interpreter label is not set. We might be able to do it internally, but I do not know where. |
🚀 feature request
Relevant Rules
Existing rules with bzlmod
Description
I am working on the bzlmod example and running into a problem. I will update the documentation and also add this to the example.
When using bzlmod the toolchain registration does not download a hermetic version of Python. When using an extension and
MODULES.bzl
, the extension code cannot register a native toolchain because it runs in a different thread by design.But how do we do this? I am getting an error that tells me to register a toolchain in the
BUILD.bazel
file when I try to use the extension to download a hermetic version of Python.So I am trying:
I am using the example for bzlmod and have added a file that uses
native.register_toolchains
.In the BUILD.bazel file, I am loading this function and using it.
But I am getting "Error: no native function or rule 'register_toolchains'".
Describe the solution you'd like
I will document the solution.
Describe alternatives you've considered
Use the BUILD files, but it is not working. I would rather not use a WORKSPACE.bzl file, which seems to defeat the purpose of using a
MODULES.bzl
file and bzlmod.History
So when
extensions.bzl
was added, we have the comment:rules_python/python/extensions.bzl
Line 30 in b80b8fd
I don't understand the comment.
Previously when using a
WORKSPACE
file the methodpython_register_toolchains
is where a hermetic version of Python is downloaded. When you have:Now we have:
Which does not download Python.
The text was updated successfully, but these errors were encountered: