//python/private/pypi:config_settings.bzl
The config_settings macro is used to create the config setting targets
that can be used in the pkg_aliases macro for selecting the compatible
repositories.
Bazel’s selects work by selecting the most-specialized configuration setting that matches the target platform, which is further described in bazel documentation. We can leverage this fact to ensure that the most specialized matches are used by default with the users being able to configure string_flag values to select the less specialized ones.
The config settings in the order from the least specialized to the most specialized is as follows:
:is_cp3<minor_version><suffix>:is_cp3<minor_version>_sdist<suffix>:is_cp3<minor_version>_py_none_any<suffix>:is_cp3<minor_version>_py3_none_any<suffix>:is_cp3<minor_version>_py3_abi3_any<suffix>:is_cp3<minor_version>_none_any<suffix>:is_cp3<minor_version>_any_any<suffix>:is_cp3<minor_version>_cp3<minor_version>_any<suffix>and:is_cp3<minor_version>_cp3<minor_version>t_any<suffix>:is_cp3<minor_version>_py_none_<platform_suffix>:is_cp3<minor_version>_py3_none_<platform_suffix>:is_cp3<minor_version>_py3_abi3_<platform_suffix>:is_cp3<minor_version>_none_<platform_suffix>:is_cp3<minor_version>_abi3_<platform_suffix>:is_cp3<minor_version>_cp3<minor_version>_<platform_suffix>and:is_cp3<minor_version>_cp3<minor_version>t_<platform_suffix>
The specialization of free-threaded vs non-free-threaded wheels is the same as
they are just variants of each other. The same goes for the specialization of
musllinux vs manylinux.
The goal of this macro is to provide config settings that provide unambigous
matches if any pair of them is used together for any target configuration
setting. We achieve this by using dummy internal flag_values keys to force the
items further down the list to appear to be more specialized than the ones above.
What is more, the names of the config settings are as similar to the platform wheel
specification as possible. How the wheel names map to the config setting names defined
in here is described in pkg_aliases documentation.
Note
Right now the specialization of adjacent config settings where one is with
constraint_values and one is without is ambiguous. I.e. py_none_any and
sdist_linux_x86_64 have the same specialization from bazel point of view
because one has one flag_value entry and constraint_values and the
other has 2 flag_value entries. And unfortunately there is no way to disambiguate
it, because we are essentially in two dimensions here (flag_values and
constraint_values). Hence, when using the config_settings from here,
either have all of them with empty suffix or all of them with a non-empty
suffix.
- config_settings(python_versions=[], glibc_versions=[], muslc_versions=[], osx_versions=[], target_platforms=[], name=None, **kwargs)
Generate all of the pip config settings.
- Args:
python_versions– (default [])The list of python versions to configure config settings for.
glibc_versions– (default [])The list of glibc version of the wheels to configure config settings for.
muslc_versions– (default [])The list of musl version of the wheels to configure config settings for.
osx_versions– (default [])The list of OSX OS versions to configure config settings for.
target_platforms– (default [])The list of “{os}_{cpu}” for deriving constraint values for each condition.
name– (default None)Currently unused.
kwargs– Other args passed to the underlying implementations, such asnative.