//python/extensions:config.bzl

Extension for configuring global settings of rules_python.

module ext config

Global settings for rules_python.

Added in version 1.7.0.

config.add_transition_setting(setting=None)

Specify a build setting that terminal rules transition on by default.

Terminal rules are rules such as py_binary, py_test, py_wheel, or similar rules that represent some deployable unit. Settings added here can then be used a keys with the config_settings attribute.

Note

This adds the label as a dependency of the Python rules. Take care to not refer to repositories that are expensive to create or invalidate frequently.

Attributes:
  • setting(label) (default None)

    The build setting to add.

    optional

config.explicit_init_py(default)

Require explicit __init__.py files in this module.

Disables the legacy __init__.py generation for all py_* targets in this module, requiring all Python targets to explicitly provide __init__.py files when they’re needed.

To override this at a per-target level, set legacy_create_init on applicable py_binary or py_test targets:

py_binary(
    name = "hello_python",
    # ...
    # This Binary still relies on legacy behavior, so
    # enable the legacy behavior as an exceptional case.
    legacy_create_init = 1,
)

Note

In the future, this will be enabled by default.

Added in version 2.3.0.

Attributes:
  • default(bool)

    Whether explicit init.py files are required by default.

    mandatory