//python/api:api.bzl

Public, analysis phase APIs for Python rules.

To use the analyis-time API, add the attributes to your rule, then use py_common.get() to get the api object:

load("@rules_python//python/api:api.bzl", "py_common")

def _impl(ctx):
    py_api = py_common.get(ctx)

myrule = rule(
    implementation = _impl,
    attrs = {...} | py_common.API_ATTRS
)

Added in version 0.37.0.

typedef py_common

Typedef for py_common.

py_common.API_ATTRS: dict[str, Attribute]

The attributes that rules must have for py_common.get() to work.

py_common.get(ctx)

Get the py_common API instance.

NOTE: to use this function, the rule must have added py_common.API_ATTRS to its attributes.

Args:
  • ctx(ctx)

    current rule ctx

Returns:

PyCommonApi