//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 thispage may help to describe the naming convention and relationship between various flags and optionsinrules_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 byconfig_settings, for more detailed documentation on what each configsetting 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 aliasesto process. Any aliases that have the filename set will beconverted to a dict of config settings to repo names. Thestruct 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 byrules_python.

Args:
  • name(str)

    The name of the package.

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

    The name of the repo thealiases point to, or a dict of select conditions to repo names forthe aliases to point to mapping to repositories. The keys are passedto bazel skylib’sselects.with_or, so they can be tuples as well.

  • group_name(str)(defaultNone)

    The group name that the pkg belongs to.

  • extra_aliases(list[str])(defaultNone)

    The extra aliases to be created.

  • kwargs – extra kwargs to pass toget_config_settings.