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

No matching toolchains when using current_py_cc_headers with WORKSPACE. #1669

Closed
lalten opened this issue Jan 5, 2024 · 1 comment · Fixed by #1670
Closed

No matching toolchains when using current_py_cc_headers with WORKSPACE. #1669

lalten opened this issue Jan 5, 2024 · 1 comment · Fixed by #1670
Labels
type: bug type: toolchain Related to the toolchains provided by rules_python

Comments

@lalten
Copy link
Contributor

lalten commented Jan 5, 2024

🐞 bug report

Description

Can not use @rules_python//python/cc:current_py_cc_headers in WORKSPACE mode because the toolchain fails to resolve. The WORKSPACE file is setting up a hermetic interpreter via python_register_toolchains.

Note that the target works as expected when using a MODULE.bazel.

🔬 Minimal Reproduction

See repro repo: https://github.com/lalten/current_py_cc_headers

🔥 Exception or Error

@@rules_python//python/cc:current_py_cc_headers (5b7f3da): No matching toolchains found for types @@rules_python//python/cc:toolchain_type.

🌍 Your Environment

Operating System: ubuntu-latest
Output of bazel version: 7.0.0
Rules_python version: 0.27.1

@rickeylev
Copy link
Contributor

Ah, i think what's happening is the workspace code path registers a specific target instead of :all (which is what bzlmod does). https://github.com/bazelbuild/rules_python/blob/main/python/repositories.bzl#L583

Should be a simple fix to have it register the additional toolchain.

In the meantime, you can work around this by adding native.register_toolchain() to your workspace. Something like @<name>_toolchains//:all, where <name> is the name of the python runtime repo that was used (usually @python or @python_3_11). Or register the specific platforms you're interested by doing using @<name>_toolchains//<platform>_toolchain, where<platform> would be e.g. linux_x86_64

rickeylev added a commit to rickeylev/rules_python that referenced this issue Jan 7, 2024
The workspace `python_register_toolchains()` only registered the plain
Python toolchain by its specific name. The py cc toolchain wasn't also
being named. This meant things like `//python/cc:current_py_cc_headers`
couldn't find their toolchain. Bzlmod doesn't have this problem because
it uses the `:all` pattern to register everything.

To fix, also register the py cc toolchain where the plain Python
toolchain is registered, which makes it available.

Fixes bazelbuild#1669
rickeylev added a commit to rickeylev/rules_python that referenced this issue Jan 7, 2024
The workspace `python_register_toolchains()` only registered the plain
Python toolchain by its specific name. The py cc toolchain wasn't also
being named. This meant things like `//python/cc:current_py_cc_headers`
couldn't find their toolchain. Bzlmod doesn't have this problem because
it uses the `:all` pattern to register everything.

To fix, also register the py cc toolchain where the plain Python
toolchain is registered, which makes it available.

Fixes bazelbuild#1669
rickeylev added a commit to rickeylev/rules_python that referenced this issue Jan 7, 2024
The workspace `python_register_toolchains()` only registered the plain
Python toolchain by its specific name. The py cc toolchain wasn't also
being named. This meant things like `//python/cc:current_py_cc_headers`
couldn't find their toolchain. Bzlmod doesn't have this problem because
it uses the `:all` pattern to register everything.

To fix, also register the py cc toolchain where the plain Python
toolchain is registered, which makes it available.

Fixes bazelbuild#1669
github-merge-queue bot pushed a commit that referenced this issue Jan 7, 2024
The workspace `python_register_toolchains()` function only registered
the plain Python toolchain by its specific name. The py cc toolchain
wasn't also being named. This meant things like
`//python/cc:current_py_cc_headers` couldn't find their toolchain.
Bzlmod doesn't have this problem because it uses the `:all` pattern to
register everything.

To fix, also register the py cc toolchain where the plain Python
toolchain is registered, which makes it available.

Fixes #1669
@rickeylev rickeylev added type: bug type: toolchain Related to the toolchains provided by rules_python labels Jan 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug type: toolchain Related to the toolchains provided by rules_python
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants