-
Notifications
You must be signed in to change notification settings - Fork 4.1k
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
Python rules ignore "imports" provider passed in from Starlark-defined rules #7054
Comments
The rewritten test is non-Bazel specific and directly checks the sandwich use case. There's a slight loss in coverage that will be addressed with bazelbuild#7054. Work towards bazelbuild#1446. RELNOTES: None PiperOrigin-RevId: 230002328
Hi guys, I am in dire need of a fix for this right now. The fact that the imports attribute was being silently ignored, coupled with the transitionary state of the py provider docs, has already lead to much hair pulling in my proposed migration to Bazel. Is there any chance you can prioritize it, even if that means making it PyInfo-only ("modern-only") ** ? I really don't know how to make imports work properly otherwise. A py_library wrapper seems like a non-starter because of the other transitive information we need to propagate. Best, Edit: to clarify, a world in which PyInfo.imports works but "py".imports doesn't still seems much better than a world in which neither works. So we don't have to wait until the disallow_legacy is default, I think. Or am I misunderstanding and PyInfo.imports will work in 0.23? |
When I was refactoring how Looking over the rule logic again, it seems that this is simpler than I remember. (Refactorings have that effect after all...) Given the ease of the fix vs the benefit, I'll prioritize this. Should appear in 0.24 (the release after the current RC). |
Thanks Jon! I appreciate the quick response and offer to fix. I wish it was sooner than 0.24 though... any chance it's simple enough (as well as being pure forward progress) to be in .23? I also look forward to the py provider matching the others. Once this is done, I'll probably contribute a nice chunk of Starlark (for interop with ROS) back to the community, so this is good karma all around. |
Unfortunately the baseline for 0.23 has already been cut, and we tend not to cherry pick feature requests in, as opposed to bug fixes. In the meantime you can try it out with bazel built at head. Watch this bug to see when the fix is in. |
Also, you should still be able to add imports using the regular old py_library rule. Maybe you can combine that with your rule in a macro to hack around this bug in the meantime. |
Fix is in if you wanted to grab a dev build. |
From what I can tell from reading the code and some quick experimentation, it looks like we pull the imports from the native
PythonImportsProvider
and fromBazelPythonSemantics#getImports
(which reads theimports
attribute), but not from theimports
field of apy
provider struct of a dependency. This is a simple fix, but we can probably combine it with a cleanup that removesPythonImportsProvider
altogether. Won't address until after we deprecate thepy
legacy struct provider.The text was updated successfully, but these errors were encountered: