feat: allow registering arbitrary settings for py_binary transitions (#3248) This implements the ability for users to add additional settings that py_binary, py_test, and py_wheel can transition on. There were three main use cases motivating this feature: 1. Making it easier to have multiple pypi dependency closures and shared dependencies. 2. Making it easier to override flags for `py_wheel`. 3. Making it easier to have per-target setting of things like bootstrap_impl, venv site packages, etc. It also adds most of our config settings to the the transition inputs/outputs for those rules, which allows users to per-target force particular settings without having to use e.g. `with_cfg` to wrap a target with the desired transition settings. It also lets use avoid adding dozens of attributes (one per setting); today there are about 17 flags. Under the hood, this works by having a bzlmod api that users can pass labels to. These labels are put into a generated bzl file, which the rules load and add to their list of transition inputs/outputs. On the target level, the `config_settings` attribute, which is a `dict[label, str]`, can be set to change the particular flags of interest. Along the way... * Create a common_labels.bzl file for the shared label strings * Remove the defunct py_reconfig code in sh_py_run_test. --------- Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
This repository is the home of the core Python rules -- py_library, py_binary, py_test, py_proto_library, and related symbols that provide the basis for Python support in Bazel. It also contains package installation rules for integrating with PyPI and other indices.
Documentation for rules_python is at https://rules-python.readthedocs.io and in the Bazel Build Encyclopedia.
Examples live in the examples directory.
The core rules are stable. Their implementation is subject to Bazel's backward compatibility policy. This repository aims to follow semantic versioning.
The Bazel community maintains this repository. Neither Google nor the Bazel team provides support for the code. However, this repository is part of the test suite used to vet new Bazel releases. See How to contribute page for information on our development workflow.
For detailed documentation, see https://rules-python.readthedocs.io
See Bzlmod support for more details.