-
Notifications
You must be signed in to change notification settings - Fork 549
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
rules_python bzlmod should register a default toolchain #1233
Comments
@rickeylev and I have discussed this a bunch, we are uncertain if we are going to do this. We need to have the rules register a toolchain, and usually not the user. But autoregistering may cause issues. |
This could also avoid problems like the following: [Bug]: rules_python@0.21.0 'python/extensions' is not a package. Because the rules_python repo changed faster than the bzlmod registry it seems we can't use the last bzlmod dep. Less config in the MODULE.bazel, the less problems we will have for updating rules_python. |
I came back to this issues today when thinking about what happens if the root module doesn't use Python, but a submodule does. For example, if I'm a JavaScript project and don't use Python myself, I shouldn't have to setup Python because a module I depend on happens to use Python. My basic conclusion is rules_python should register a default toolchain. The root module can, of course, still override it. Sub-modules still aren't allowed to establish a default, for the same reasons as before. That, plus I think it's easier to understand and manage "rules python sets the default" instead of "the first module that tries to use python in my module dependency graph sets the default". With the former, you just know exactly where the default is being set. If there's a problem, it's "Module A doesn't support Python version X", which is fairly straight forward. With the latter, you have to try and figure out where in your transitive module graph it might be coming from. Once you find it, the problem is "Module A wants Python version X, while module B wants Python version Y, and this combination isn't compatible", which is harder to solve. |
Another thing that has occurred to me: there's an interaction with pip here, too. A module calling So we'll need something like a way to make |
@rickeylev is this where you want now? |
We're close (requested toolchains are auto-registered), but rules_python isn't setting a default. |
This makes rules_python always provide a default toolchain. Work towards bazelbuild#1233
This makes rules_python always provide a default toolchain when using bzlmod. Note that, unlike workspace builds, the default is not the local system Python (`@bazel_tools//tools/python:autodetecting_toolchain`). Instead, the default is a hermetic runtime, but no guarantees are made about the particular version used. In practice, it will be the latest available Python version. Work towards bazelbuild#1233
This makes rules_python always provide a default toolchain when using bzlmod. Note that, unlike workspace builds, the default is not the local system Python (`@bazel_tools//tools/python:autodetecting_toolchain`). Instead, the default is a hermetic runtime, but no guarantees are made about the particular version used. In practice, it will be the latest available Python version. Work towards bazelbuild#1233
This makes rules_python always provide a default toolchain when using bzlmod. Note that, unlike workspace builds, the default is not the local system Python (`@bazel_tools//tools/python:autodetecting_toolchain`). Instead, the default is a hermetic runtime, but no guarantees are made about the particular version used. In practice, it will be the latest available Python version. Work towards bazelbuild#1233
This makes rules_python always provide a default toolchain when using bzlmod. Note that, unlike workspace builds, the default is not the local system Python (`@bazel_tools//tools/python:autodetecting_toolchain`). Instead, the default is a hermetic runtime, but no guarantees are made about the particular version used. In practice, it will be the latest available Python version. Work towards bazelbuild#1233
This makes rules_python always provide a default toolchain when using bzlmod. Note that, unlike workspace builds, the default is not the local system Python (`@bazel_tools//tools/python:autodetecting_toolchain`). Instead, the default is a hermetic runtime, but no guarantees are made about the particular version used. In practice, it will be the latest available Python version. Work towards bazelbuild#1233
This makes rules_python always provide a default toolchain when using bzlmod. Note that, unlike workspace builds, the default is not the local system Python (`@bazel_tools//tools/python:autodetecting_toolchain`). Instead, the default is a hermetic runtime, but no guarantees are made about the particular version used. In practice, it will be the latest available Python version. Work towards bazelbuild#1233
This makes rules_python always provide a default toolchain when using bzlmod. Note that, unlike workspace builds, the default is not the local system Python (`@bazel_tools//tools/python:autodetecting_toolchain`). Instead, the default is a hermetic runtime, but no guarantees are made about the particular version used. In practice, it will be the latest available Python version. Work towards #1233
@rickeylev Can we close this now? |
Yes. |
🚀 feature request
Well, sort of a feature-parity / bug report, too; see below.
Relevant Rules
bzlmod module
Description
Today, users must manually specify a toolchain and manually register it. This adds friction and causes problems for a few reasons:
It's also worth noting that WORKSPACE builds already register a default toolchain -- whatever is found on the local system (
@bazel_tools//tools/python:autodetecting_toolchain
). This toolchain is problematic for various reasons, but that is the existing WORKSPACE-based behavior.Describe the solution you'd like
Instead, rules_python should register a toolchain by default. This avoids the three issues above.
I propose that it register the most recent version of Python available. We should be clear that this is for convenience -- the default provided shouldn't be relied upon.
If a module needs a specific version, then it should use the multi-version rules.
The text was updated successfully, but these errors were encountered: