-
Notifications
You must be signed in to change notification settings - Fork 4.3k
New incompatible flags disable ctx.fragments.py, ctx.fragments.bazel_py #27056
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
Conversation
|
Checking |
Good call. Where does I just see one (unaffected) |
For example, https://github.com/bazel-contrib/rules_python/pull/3280/files removed a |
|
Oh nice, there was just that one configuration_field() call that you removed. So that's taken care of. What about The attrs_builders and rule_builders code are just wrappers around the attr.XXX functions. e.g. attrb.LabelList is a wrapper around attr.label_list. |
…unction (#3290) This lets Python logic support either Starlark- or native-defined flags, based on Bazel support: - Pre-Bazel 9.0: always use native flags - Bazel 9.0+: use Starlark flags if [incompatible change](bazelbuild/bazel#27056) that disables `ctx.fragments.py` and `ctx.fragments.bazel_py` is set - Include a developer override to trigger Starlark versions while testing Starlarkification. Developers enable this by updating .bzl code in their local workspace. This can be removed as soon as Starlarkification is complete Also check in a Starlark version of `--experimental_python_import_all_repositories` for testing. **This is a no-op. New flag sources of truth don't take effect without a supporting bazel version that sets appropriate incompatible flags.** **Caveats:** - May not work with `configuration_field` as implemented. We can loosen the incompatible flag lockdown if that's an issue. For #3252 TODO list * [ ] Add docs to docs/api/rules_python/python/config_settings/index.md for starlarkified flags
That's fine. I checked the Bazel code and also did some manual testing.
So as long as |
--incompatible_remove_ctx_py_fragmentremovesctx.fragments.py.--incompatible_remove_ctx_bazel_py_fragmentremovesctx.fragments.bazel_py.rules_pythoncan use this to determine if it should read Python flags from Starlark definitions or Bazel-native:For bazel-contrib/rules_python#3252.
Caveats:
This approach has the downside that it's all-or-nothing: removing an entire fragment doesn't permit partial Starlarkification. Which is hypothetically an issue if we have to keep certain flags native because of strange inner Bazel dependencies.
I think for Python this isn't a huge risk. Worst-case we can redefine the flags to restrict fragment access instead of completely removing it.