Skip to content

--incompatible_remove_ctx_py_fragment #27079

@gregestren

Description

@gregestren

Motivation

Part of Starlarkify native Bazel flags: move language flags out of Bazel and into the rule's .bzl definitions. This gives rules owners more ownership over their logic.

This Starlarkifies https://github.com/bazel-contrib/rules_python flags.

This removes ctx.fragments.py. See #27080 for similar flag for ctx.fragments.bazel_py.

Description

When flipped, ctx.fragments.py no longer exists. A new rules_python release uses that as signal to read its flags from Starlark definitions in the rules_python repo.

This is meant to be a user no-op. But there are some small differences meriting an incompatible flip:

  1. $ bazel build //foo --flag value no longer works. You must now set $ bazel build //foo --flag=value.
  2. Your repo must load rules_python for Python flags to resolve. This should already be true for Python builds, but maybe not, e.g., for a genrule thet select()s on a Python flag. It might also be true universally so this might not be a real effect.
  3. If you have your own .bzl code that reads ctx.fragments.py, you need to change it to read equivalent rules_python-defined Starlark flags. Comment here for details.
  4. $ bazel help flags-as-proto no longer shows Python flags.

This only affects Bazel 9+. Older Bazel continue to work with any version of rules_python (both old and new).

Incompatible Flag

--incompatible_remove_ctx_py_fragment

Migration Guide

If using Bazel 9.0+: update to a recent rules_python version that supports Starlark-based flags. Release info TBD.

If using Bazel <9.0: no action needed.

In which Bazel LTS version will this incompatible change be enabled?

Bazel 9

TODO List

  • Prepare rules_python release that supports Starlark flags
  • Flip flag

Metadata

Metadata

Assignees

Labels

breaking-change-9.0Incompatible flags to be flipped in Bazel 9.0incompatible-changeIncompatible/breaking changeteam-Configurabilityplatforms, toolchains, cquery, select(), config transitions

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions