-
Notifications
You must be signed in to change notification settings - Fork 541
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
feat(bzlmod): python.override for toolchain customization #2151
Conversation
c0a6152
to
0a88a6e
Compare
Overall, I think its pretty promising. All the override APIs need is_root checks, though -- letting intermediate modules override would cause quite a headache. Did you look at some of the other use cases in #2081 ? Some cases that seem relevant to this api are:
Though, I'm not sure if it makes sense to override entirely vs register an additional toolchain with an additional constraint. I guess overriding provides an escape hatch. Part of me thinks that it might make more sense to push those cases into "register your own toolchain, here's some helpers to make it easier for you" -- it feels like, if you're overriding things such that they no longer resemble the python-build-standalone tars that get extracted and processed, then you're probably better off not trying to override the machinery that expects such a tar file. |
Forgot one comment: in theory, can we use these APIs ourselves to register everything? i.e. replace versions.bzl with a series of calls in MODULE.bazel? I'm not suggesting we do that, but if we can, then that's pretty cool, and I think points to the API being in the right direction. |
Right now everything is under
I haven't thought about the local toolchain yet.
Three of the above could be modelled as target platform with different config settings:
Exactly my thoughts.
Yeah, I think we should do that. The refactor I mentioned above is to allow for that. This idea came to me when I was looking how I was constructing and overriding the |
This is a bit too big to easily review, will split it up. |
Before this PR the users could not override how the hermetic toolchain is downloaded when in `bzlmod`. However, the same APIs would be available to users using `WORKSPACE`. With this we also allow root modules to restrict which toolchain versions the non-root modules, which may be helpful when optimizing the CI runtimes so that we don't waste time downloading multiple `micro` versions of the same `3.X` python version, which most of the times have identical behavior. Whilst at it, tweak the `semver` implementation to allow for testing of absence of values in the original input. Work towards #2081 and this should be one of the last items that are blocking #1361 from the API point of view. Replaces #2151. --------- Co-authored-by: Richard Levasseur <richardlev@gmail.com>
Before the PR users would not be able to override various things configured by
rules_python
when it comes to downloading toolchains. In the WORKSPACE world,they would be able to do this and there could be users of
rules_python
whomight not be able to migrate to
bzlmod
due to the lack of such capability.This PR refactors the internal
register_all_versions
tag class and adds ageneric way to override how python toolchains are registered and how they are
downloaded. In this way users can add extra toolchains, remove existing ones
or do anything they can do in
WORKSPACE
builds.Fixes #1172
Work towards #2081