Skip to content

[doc] Print a better error message when the hub repo aliases do not match config settings #2466

Closed

Description

@aignas

Followup from #2458

The general design would be to create our own no_match_rule which could be instantiated as follows:

def compatible_settings(settings):
    """Return a list of strings"""
    ret = []
    for setting in settings:
        ret += select({setting: [setting], "//conditions:default": []})

    return ret

no_match(
    name = "no_match",
    compatible_settings = compatible_settings(ALL_SETTINGS),
    # The flags that we use for selecting the wheels
    python_version = "@rules_python//python/config_settings:python_version",
    ...
)

The impl of the rule could be as simple as:

def _impl(ctx):
    flags = {
        name: getattr(ctx.attr, name)[Provider].value
        for name in ALL_FLAG_NAMES
    }
    msg = _TEMPLATE.format(
        compatible_settings = render.indent("\n".join(ctx.attr.compatible_settings))
        flags = render.indent("\n".join(flags))
    )
    fail(msg)

And it is wired inside the pkg_aliases rule by doing:

        actual = {
            "//conditions:default": "//_config:no_match"
        }

This would trigger the _impl rule implementation above and it would fail building the target.

Definition of done:

  • We can see compatible config settings with the current configuration.
  • We can see the flag values of the current configuration.
  • If we do bazel build //_config/..., the build should not fail. Add a build_test in the //tests/pypi/integration.
  • We have an analysis test that checks the failure and (bonus points) checks that the error message is templated with the correct compatible settings. Add an analysis test in //tests/pypi/pkg_aliases.

Part of #260.

Activity

  1. added
    Good first issueA good first issue for people looking to contribute
    on Dec 3, 2024
  2. added a commit that references this issue on Dec 22, 2024
    866ab7d
  3. self-assigned this
    on Dec 22, 2024
  4. added a commit that references this issue on Dec 23, 2024
    be950f9
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Good first issueA good first issue for people looking to contribute

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions