Skip to content

fix(py_console_script_binary): only create _script_gen for the exec cfg - #4219

Open
robinlinden wants to merge 1 commit into
bazel-contrib:mainfrom
robinlinden:fix-py-console-script-gen-exec-config
Open

robinlinden wants to merge 1 commit into
bazel-contrib:mainfrom
robinlinden:fix-py-console-script-gen-exec-config

Conversation

@robinlinden

Copy link
Copy Markdown
Contributor

Without this, py_console_script_gen exists for both the target and exec config which causes issues when cross-compiling.

I use py_console_script_binary for glad2 which I pass as a tool to a genrule, but starting with rules_python 2.0.0 I get the following error when e.g. cross-compiling to wasm:

DEBUG: /home/runner/.cache/bazel/_bazel_runner/a9f0723b1e9e47cd91eaa9d5188be59d/external/rules_python+/python/private/config_settings.bzl:248:14: The current configuration rules_python config flags is:
    @@rules_python+//python/config_settings:pip_whl_osx_version: ""
    @@rules_python+//python/config_settings:py_freethreaded: "no"
    @@rules_python+//python/config_settings:py_linux_libc: "glibc"
    @@rules_python+//python/config_settings:python_version: "3.14"

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/runner/.cache/bazel/_bazel_runner/a9f0723b1e9e47cd91eaa9d5188be59d/external/rules_python++pip+hastur_pypi/glad2/BUILD.bazel:6:12: configurable attribute "actual" in @@rules_python++pip+hastur_pypi//glad2:_no_matching_repository doesn't match this configuration: No matching wheel for current configuration's Python version and platform.

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_cp314_linux_x86_64

As configured by the `pip.parse.target_platforms` attribute. Note that
`requirements_by_platform` only affects the Bazel host platform unless
`target_platforms` is also set.

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:
    --@@rules_python+//python/config_settings:current_config=fail

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


This instance of @@rules_python++pip+hastur_pypi//glad2:_no_matching_repository has configuration identifier 98696d4. To inspect its configuration, run: bazel config 98696d4.

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

With this change, Bazel seems happy to only run the py_console_script_gen bits for the exec config and my cross-compilation works again.

Without this, `py_console_script_gen` exists for both the target and
exec config which causes issues when cross-compiling.
@robinlinden

robinlinden commented Oct 5, 2026 •

Copy link
Copy Markdown
Contributor Author

The test failures in buildkite look relevant to this change. Never mind, they're failing in other PRs as well.

@robinlinden
robinlinden marked this pull request as ready for review October 5, 2026 19:34

This branch has not been deployed

No deployments
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.

1 participant