//python/private/pypi:pkg_aliases.bzl

pkg_aliases is a macro to generate aliases for selecting the right wheel for the right target platform.

If you see an error where the distribution selection error indicates the config setting names this page may help to describe the naming convention and relationship between various flags and options in rules_python and the error message contents.

Definitions:

minor_version:

Python interpreter minor version that the distributions are compatible with.

suffix:

Can be either empty or _<os>_<suffix>, which is usually used to distinguish multiple versions used for different target platforms.

os:

OS identifier that exists in @platforms//os:<os>.

cpu:

CPU architecture identifier that exists in @platforms//cpu:<cpu>.

All of the config settings used by this macro are generated by config_settings, for more detailed documentation on what each config setting maps to and their precedence, refer to documentation on that page.

//_config:is_cp3<minor_version><suffix> is used to select any target platforms.

get_config_settings(target_platforms, python_version)

Get the filename config settings.

Exposed only for unit tests.

Args:
  • target_platforms – list[str], target platforms in “{abi}{os}{cpu}” format.

  • python_version – the python version to generate the config_settings for.

Returns:

A tuple:

  • A list of config settings that are generated by ./pip_config_settings.bzl

  • The list of default version settings.

multiplatform_whl_aliases(aliases=[])

convert a list of aliases from filename to config_setting ones.

Exposed only for unit tests.

Args:
  • aliases(str | dict[struct | str, str]) (default [])

    : The aliases to process. Any aliases that have the filename set will be converted to a dict of config settings to repo names. The struct is created by .

Returns:

A dict with of config setting labels to repo names or the repo name itself.

pkg_aliases(name, actual, group_name=None, extra_aliases=None, **kwargs)

Create aliases for an actual package.

Exposed only to be used from the hub repositories created by rules_python.

Args:
  • name(str)

    The name of the package.

  • actual(dict[Label | tuple, str] | str)

    The name of the repo the aliases point to, or a dict of select conditions to repo names for the aliases to point to mapping to repositories. The keys are passed to bazel skylib’s selects.with_or, so they can be tuples as well.

  • group_name(str) (default None)

    The group name that the pkg belongs to.

  • extra_aliases(list[str]) (default None)

    The extra aliases to be created.

  • kwargs – extra kwargs to pass to get_config_settings.