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

refactor(pypi): A better error message when the wheel select hits no_match #2519

Merged
merged 6 commits into from
Dec 23, 2024

Conversation

aignas
Copy link
Collaborator

@aignas aignas commented Dec 22, 2024

With this change we get the current values of the python configuration
values printed in addition to the message printed previously. This
should help us advise users who don't have their builds configured
correctly.

We are adding an extra build_setting which we can set in order to get
an error message instead of a DEBUG warning. This has been documented
as part of our config settings and in the no_match_error in the
select statement.

Example output now

$ bazel cquery --@rules_python//python/config_settings:python_version=3.12 @dev_pip//sphinx
DEBUG: /home/aignas/src/github/aignas/rules_python/python/private/config_settings.bzl:200:14: The current build configuration's rules_python flag values are:
    @@//python/config_settings:pip_whl: "auto"
    @@//python/config_settings:pip_whl_glibc_version: ""
    @@//python/config_settings:pip_whl_muslc_version: ""
    @@//python/config_settings:pip_whl_osx_arch: "arch"
    @@//python/config_settings:pip_whl_osx_version: ""
    @@//python/config_settings:py_freethreaded: "no"
    @@//python/config_settings:py_linux_libc: "glibc"
    @@//python/config_settings:python_version: "3.12"

See documentation:
https://rules-python.readthedocs.io/en/latest/api/rules_python/python/config_settings
ERROR: /home/aignas/.cache/bazel/_bazel_aignas/6f0de8c9128ee8d5dbf27ba6dcc48bdd/external/+pip+dev_pip/sphinx/BUILD.bazel:6:12: configurable attribute "actual" in @@+pip+dev_pip//sphinx:_no_match_error doesn't match this configuration: No matching wheel for current configuration's Python version.

The current build configuration's settings do not match any of the Python wheels available for this distribution. This distribution supports the following configuration settings:
    //_config:is_cp3.11_py3_none_any
    //_config:is_cp3.13_py3_none_any

To determine the current build configuration flag values, see the debug message above or re-run the build with:
    --@@//python/config_settings:current_config=fail

For other configuration, run:
    `bazel config <config id>` (shown further below)

This instance of @@+pip+dev_pip//sphinx:_no_match_error has configuration identifier 29ffcf8. To inspect its configuration, run: bazel config 29ffcf8.

For more help, see https://bazel.build/docs/configurable-attributes#faq-select-choose-condition.

ERROR: Analysis of target '@@+pip+dev_pip//sphinx:sphinx' failed; build aborted: Analysis failed
INFO: Elapsed time: 0.100s
INFO: 0 processes.
ERROR: Build did NOT complete successfully

Fixes #2466

With this change we get the current values of the python configuration
values printed in addition to the message printed previously. This
should help us advise users who don't have their builds configured
correctly.

We are adding an extra `build_setting` which we can set in order to get
an error message instead of a `DEBUG` warning. This has been documented
as part of our config settings and in the `no_match_error` in the
`select` statement.

Example output now
```console
$ bazel cquery --@rules_python//python/config_settings:python_version=3.12 @dev_pip//sphinx
DEBUG: /home/aignas/src/github/aignas/rules_python/python/private/config_settings.bzl:193:14: The current configuration rules_python config flags is:
    @@//python/config_settings:pip_whl: "auto"
    @@//python/config_settings:pip_whl_glibc_version: ""
    @@//python/config_settings:pip_whl_muslc_version: ""
    @@//python/config_settings:pip_whl_osx_arch: "arch"
    @@//python/config_settings:pip_whl_osx_version: ""
    @@//python/config_settings:py_freethreaded: "no"
    @@//python/config_settings:py_linux_libc: "glibc"
    @@//python/config_settings:python_version: "3.12"

If the value is missing, then the default value is being used, see documentation:
https://rules-python.readthedocs.io/en/latest/api/rules_python/python/config_settings
ERROR: /home/aignas/.cache/bazel/_bazel_aignas/6f0de8c9128ee8d5dbf27ba6dcc48bdd/external/+pip+dev_pip/sphinx/BUILD.bazel:6:12: configurable attribute "actual" in @@+pip+dev_pip//sphinx:_no_matching_repository doesn't match this configuration: 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 distribution. This distribution supports the following Python
configuration settings:
    //_config:is_cp3.11_py3_none_any
    //_config:is_cp3.13_py3_none_any

To determine the current configuration's Python version, run:
    `bazel config <config id>` (shown further below)

For the current configuration value see the debug message above that is
printing the current flag values. If you can't see the message, then re-run the
build to make it a failure instead by running the build with:
    --@@//python/config_settings:current_config=fail

However, the command above will hide the `bazel config <config id>` message.

This instance of @@+pip+dev_pip//sphinx:_no_matching_repository has configuration identifier 29ffcf8. To inspect its configuration, run: bazel config 29ffcf8.

For more help, see https://bazel.build/docs/configurable-attributes#faq-select-choose-condition.

ERROR: Analysis of target '@@+pip+dev_pip//sphinx:sphinx' failed; build aborted: Analysis failed
INFO: Elapsed time: 0.112s
INFO: 0 processes.
ERROR: Build did NOT complete successfully
```

Fixes bazelbuild#2466
@rickeylev rickeylev changed the title doc(pypi): A better error message when the wheel select hits no_match refactor(pypi): A better error message when the wheel select hits no_match Dec 23, 2024
docs/api/rules_python/python/config_settings/index.md Outdated Show resolved Hide resolved
python/private/config_settings.bzl Outdated Show resolved Hide resolved
python/private/config_settings.bzl Show resolved Hide resolved
Copy link
Collaborator

@rickeylev rickeylev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM after the discussed changes (add manual tag, revert python_version_flag being public)

python/private/config_settings.bzl Show resolved Hide resolved
python/private/config_settings.bzl Outdated Show resolved Hide resolved
@aignas aignas enabled auto-merge December 23, 2024 12:30
@aignas aignas added this pull request to the merge queue Dec 23, 2024
Merged via the queue into bazelbuild:main with commit be950f9 Dec 23, 2024
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

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