-
Notifications
You must be signed in to change notification settings - Fork 541
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
Error trying to use a py_library with requirements from another module #1824
Comments
This is working as designed, kind of... Right now you define in your module1 python 3.10 dependencies but you do not set the default toolchain there. What is more setting the default would not do much because only the root module can configure the default toolchains. Anyway, what you have in module 3.10 is a target that will correctly resolve the dependencies when the toolchain is 3.10 and when your build configuration is defining 3.10 as the default. Your module2 sh_binary does not set this python configuration value, so python library does not know what do, because the dependencies are only registered for python 3.10. If you were using the python version aware py_binary in module2 I suspect that this error would go away. Another way would be to specify the default python version via the .bazelrc. What is your usecase far sharing the modules? |
I'm writing a ruleset for markdown. Internally, parts of the ruleset are implemented in python. But that's an implementation detail - the public API of the module is a bzl file that doesn't mention python at all. Users of the module won't be writing python code, and shouldn't have to know that python is being used internally. The actual WIP code is on the 'bazel-test' branch at https://github.com/calliecameron/markdown-makefile. Specifically:
Users of the module depend on the module as here and call md_document as here. When I add pydantic as a dependency to 'metadata' using 'requirement', the md_document in the user module fails to build.
How do I do this? - what do I need to set? This is fine as a workaround, but it would be nice if it wasn't needed, e.g. by having a versioned version of py_library, like we have for py_binary and py_test. |
Is there a reason why the See the |
I think what you are doing in py_binary is correct, but it seems that the configuration might be getting dropped. Maybe you should add `cfg = exec` where you use the version target as the default of the attribute.
…On 25 March 2024 19:04:12 GMT+09:00, Callie Cameron ***@***.***> wrote:
The py_binary is versioned, or at least it's supposed to be:
- usage [here](https://github.com/calliecameron/markdown-makefile/blob/46d0dcafe95d8a30c373c93fe7cc3b94260d6506/markdown/core/BUILD#L59) using the wrapper loaded [here](https://github.com/calliecameron/markdown-makefile/blob/46d0dcafe95d8a30c373c93fe7cc3b94260d6506/markdown/core/BUILD#L2)
- wrapper definition calls the real py_binary [here](https://github.com/calliecameron/markdown-makefile/blob/46d0dcafe95d8a30c373c93fe7cc3b94260d6506/markdown/support/python/defs.bzl#L25), which is the versioned version loaded [here](https://github.com/calliecameron/markdown-makefile/blob/46d0dcafe95d8a30c373c93fe7cc3b94260d6506/markdown/support/python/defs.bzl#L5)
Or am I doing something wrong here?
--
Reply to this email directly or view it on GitHub:
#1824 (comment)
You are receiving this because you commented.
Message ID: ***@***.***>
|
I tried that (and also added |
FWIW, I asked about this on bazel Slack and the transitions should work correctly in this case. i am not sure why they are not working. |
Could you please see if this is still not working as expected with 0.32.1? |
It works now. |
Re: bazelbuild/rules_python#1824 and the BCR failure in bazelbuild/bazel-central-registry#2545
🐞 bug report
Affected Rule
py_library
Description
With a
py_library
defined in one module usingrequirement
, depending on the library from another module causes a build error.🔬 Minimal Reproduction
Note that module2 doesn't use rules_python itself; it's depending on a library from module1 that uses rules_python.
🔥 Exception or Error
Preparation:
The error:
🌍 Your Environment
Operating System:
Ubuntu 22.04
Output of
bazel version
:7.0.2
Rules_python version:
0.31.0
Anything else relevant?
The example is a bit contrived (having an sh_binary with a data dep on a py_library) but is the simplest case that causes the error. In practice, I've got a py_library, used by a py_binary, used in an action in a rule, all defined in one module - and the rule being instantiated in another module. Since the py_binary is defined using the versioned rule from the python extension, I'd expect the library it calls to use that version even when used in another module.
The text was updated successfully, but these errors were encountered: