Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

doc: improve alias error msg in pip hubs #2458

Merged
merged 1 commit into from
Nov 30, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 17 additions & 7 deletions python/private/pypi/pkg_aliases.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -36,22 +36,31 @@ load(":whl_target_platforms.bzl", "whl_target_platforms")
# it. It is more of an internal consistency check.
_VERSION_NONE = (0, 0)

_CONFIG_SETTINGS_PKG = str(Label("//python/config_settings:BUILD.bazel")).partition(":")[0]

_NO_MATCH_ERROR_TEMPLATE = """\
No matching wheel for current configuration's Python version.

The current build configuration's Python version doesn't match any of the Python
wheels available for this wheel. This wheel supports the following Python
wheels available for this distribution. This distribution supports the following Python
configuration settings:
{config_settings}

To determine the current configuration's Python version, run:
`bazel config <config id>` (shown further below)
and look for
{rules_python}//python/config_settings:python_version

If the value is missing, then the "default" Python version is being used,
which has a "null" version value and will not match version constraints.
"""
and look for one of:
{settings_pkg}:python_version
{settings_pkg}:pip_whl
{settings_pkg}:pip_whl_glibc_version
{settings_pkg}:pip_whl_muslc_version
{settings_pkg}:pip_whl_osx_arch
{settings_pkg}:pip_whl_osx_version
{settings_pkg}:py_freethreaded
{settings_pkg}:py_linux_libc

If the value is missing, then the default value is being used, see documentation:
{docs_url}/python/config_settings"""

def _no_match_error(actual):
if type(actual) != type({}):
Expand All @@ -68,7 +77,8 @@ def _no_match_error(actual):
for value in (key if type(key) == "tuple" else [key])
])),
).lstrip(),
rules_python = "rules_python",
settings_pkg = _CONFIG_SETTINGS_PKG,
docs_url = "https://rules-python.readthedocs.io/en/latest/api/rules_python",
)

def pkg_aliases(
Expand Down