fix(bzlmod): let workspace-invoked python_register_toolchains to register toolchains #2289
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
While migrating to bzlmod, users may have a hybrid build where WORKSPACE contains
python_register_toolchain() calls. Because these calls originate from WORKSPACE files,
the
native.register_toolchain
APIs are still available. At the same time, we stilldetect that bzlmod is enabled, and thus disable calling those functions. The net
effect is, users aren't able to register toolchains in such a hybrid setup. At the
same time, because the code path is shared, we can't have the bzlmod toolchain code
try to call them, as it'll fail.
To accomodate both cases, have the bzlmod toolchain code pass a special arg so that
python_register_toolchains
knows to skip parts that don't apply to the bzlmod toolchaininvocation.
This was all unwound by some users and pointed out in a Slack thread. A few people are
manually carrying an equivalent patch for a working hybrid mode.
Fixes #1675