-
Notifications
You must be signed in to change notification settings - Fork 543
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
Packages imported with pip/requirements infrastructure cause import issues #14
Comments
With zero context, I suspect this is caused by this issue, but can TAL to confirm after lunch. Thank you for the repro! |
Interestingly that does not seem like the same issue. @duggelz the repro prints out |
So, my initial guess is that since multiple packages contain a A solution could be to combine all of the requirements-installed python packages into a single dist-packages-style folder, but that's a little bit scary... I'm hoping y'all have better ideas. 😸 |
@cpatrick Yeah, that would be trouble if that's what's going on. If that's truly what's going on, yes we might be able to work around it in the pip rules, but it still represents a somewhat fundamental problem with how the Perhaps we need a better solution for declaring a library to be a part of the top-level namespace than Thinking out loud... |
Ah, thanks for the pointer and explanation. Yeah, I think that's what happens. the Blending in runfiles as pip/setuptools does in site-packages feels like the option most consistent with the standard way of doing this. Looking at my virtualenv for the project that I'm bazel-ifying (or from the requirements in my repro-case) that's what you get--a single tree with |
The google package is complicated. Basically every package like google.cloud.foo, or google.protobuf, or google.tonsofotherstuff, defines its own "google" package, and the first one wins. So every package has to carefully construct its "google" package which does the right thing if it happens to be the "winner", which can easily change based on almost anything. This doesn't always happen. We don't have a central "owns the google package" authority unfortunately. So, either 1) subpar doesn't support the right pkg_resources and pkgutil calls, which is completely possible, or 2) the "winning" google package happens to be one of the ones that doesn't correctly initialize itself in the maximally friendly way. I'll look into it further. |
Here it is just |
Hi folks. Any update on this? Let me know if there's anything I can do to help reproduce or even contribute to fixing the issue. |
Any workarounds for this? |
@damienmg Anyone from the Bazel/Python side we can include here? |
Afraid not, cc @lberki just in case.
…On Wed, Oct 18, 2017, 4:28 AM Matt Moore ***@***.***> wrote:
@damienmg <https://github.com/damienmg> Anyone from the Bazel/Python side
we can include here?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#14 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/ADjHf5a27xX46fdkpfkj6RBlFyM88ZOkks5stWI-gaJpZM4Pfqjm>
.
|
The issue appears to be linked to the presence of empty By modifying the runfiles after the build (specifically, replacing those files with this one) I could get the google modules to import (although it still fails with The empty |
This appears to fix bazelbuild#14, but I haven't tested extensively to see if it breaks anything else.
- workaround bazelbuild/rules_python#14 in rules_python - workaround bazelbuild/rules_python#30 by installing `futures` - update deps to fix an incompatibility in google.cloud.exceptions
I was able to work around the issue in 5f78b4a, which generates The bit I like least is hardcoding that googleapis-common-protos' empty drigz/minimal_bazel_python_bug_repro@9644328 shows the changes necessary to use this, if anyone else is interested in trying it out. |
My description above was actually somewhat incorrect, since the namespace packages are handled in a different way than I thought. I'm experimenting with a solution. |
This appears to fix bazelbuild#14, but I haven't tested extensively to see if it breaks anything else.
I haven't forgotten about this, but it's a little tricky. |
No problem, I've been getting on OK with the workaround. I'm curious; what approach are you trying? Will it link/copy the files into a single site-packages style tree? |
in order to address Issue bazelbuild#14
Copied from hutchk@10d8f0f This is a hack and should be superseded with whatever real solution people come up with for bazelbuild#14
Copied from hutchk/rules_python@10d8f0f This is a hack and should be superseded with whatever real solution people come up with for bazelbuild#14
@duggelz Would you like me to create a pull request with my workaround? Looks like a couple of users have cherry-picked it. |
I found this issue in the google group thread here https://groups.google.com/forum/#!topic/bazel-discuss/NMO6KPyPKh4 but isn't this related to this issue #55? (sorry didn't see this issue before I created mine) but there I describe what's the root cause and what we can do about it, I also have a workaround there too. |
This appears to fix bazelbuild#14, but I haven't tested extensively to see if it breaks anything else.
What's the current status on this? Between all the activity here and on #55, I'm kind of lost. However, it does appear to still be a problem for some situations. I managed to work around it with a combination of My specific problem is with zope-interface, which doesn't have a |
@brian-peloton My (incomplete) understanding is that this will be resolved as part of Operation Purple Boa but a near-term solution is not planned. https://github.com/TriggerMail/rules_pyz offers an alternative set of rules that may work better for you than the current rules_python. #55 has more information (especially on the importance of |
Adding @brandjon, the new proud owner of our Python support. |
using |
This appears to fix bazelbuild#14, but I haven't tested extensively to see if it breaks anything else.
So, just to be clear, there's no current support for using protobuf and google-cloud packages with these rules? |
@rodrigoaliste seems so |
Issue documenting problem: bazelbuild#14 Workaround patch source: https://github.com/AppliedIntuition/rules_python/commit/77f6258cd7ea027c281bf774305b8515800a5eb9
This appears to fix bazelbuild#14, but I haven't tested extensively to see if it breaks anything else.
…-improvement-2-21jan2020
rules_python 0.1.0 has been released which upstreams the rules_python_external repo. Please switch from |
@alexeagle chances there is an example of that switch? I am new to bazel and am having issue solving this. |
Yeah look at examples in this repo. Sorry no one has had time to write a migration guide. Maybe @AutomatedTester can help |
I can maybe have a look at docs next week but @MushuEE but SeleniumHQ/selenium@40689b3 is my commit that moved us to 0.1.0 rules to get you moving sooner |
For example, import
google.auth
blocksgoogle.storage
blocksgoogle.bigquery
, etc.Here's a minimal reproduction: https://github.com/cpatrick/minimal_bazel_python_bug_repro.
Maybe I'm misunderstanding a feature or option I could be using?
The text was updated successfully, but these errors were encountered: