-
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
An unusual issue arising from the manner in which rules_python manages namespace packages. #1886
Comments
I wrote about this in https://anikevicius.lt/blog/python-lazy-loading-and-namespace-pkgs/ and I am not sure if there is a good way to solve this other than have a single folder where we install all of the packages as part of a build action. I know that @mattem is working a lot in this direction within My initial thinking would be to start looking into ways to make |
The adding of Yes, this behavior is annoying and causes issues like the one described. We'd like to change this behavior, but it's a fairly large breaking change (the global flag is a large hammer that will work; the binary-level attribute works until another binary triggers the behavior), and haven't come up with a more incremental strategy.
Sort of. It's mostly from how Bazel works internally at Google (adding empty files to every directory is tedious and gets mixed reception), and related to how to properly model |
I've hit something like this, using nvidia's omniverse and isaac sim libraries, enable_implicit_namespace_pkgs and seems to break the package. I've also found that I need to explicitly move the unpacked packages based on the contents of top_level.txt, and then mess with the sandbox. I'm on an older version of rules_python but I suspect things wouldn't be much different on a newer one. |
@gedalia I patched the method of the dependent library to avoid looking at the init.py, it's because of extra init.py , ignore it. try looking for the flag that controls adding the init.py |
I'm going to close this issue since it appears that the original poster has a workaround or solution. For posterity, the bazel flag that @rickeylev mentions is: Given that this issue relates to a third-party distribution package (PyQT5), it might actually be caused by the treatment that the rules_python whl_installer does to convert namespace packages to pkgutil namespaces. See https://github.com/bazelbuild/rules_python/blob/main/python/private/pypi/whl_installer/namespace_pkgs.py#L74 I think we might find that there are fewer issues with namespace packages if a |
🐞 bug report
Affected Rule
The issue is caused by the rule:Is this a regression?
Yes, the previous version in which this bug was not present was: ....Description
A clear and concise description of the problem...Hi,
I'm relatively new to Bazel and have only started using it a few days ago. I've gone through some introductory documentation.
In rules_python, I've noticed that it adds init.py files to every namespace package. I assume this is done to convert Python packages into Bazel packages with a BUILD file. However, I'm puzzled as to why it adds init.py to namespace package.
Recently, I encountered an issue where an unnecessary init.py file was added. Specifically, it was added to python_local_deps_pyqt5/site-packages/PyQt5/uic/widget-plugins. I'm not sure why this was done, as it doesn't seem necessary.
PyQt5 dynamically loads these plugins at runtime using Python's exec API, which assumes a certain structure. Because of this, You can't simply add the init.py file without proper justification.
It seems that rules_python adds init.py files primarily to include a path variable. However, I believe rules_python should only add init.py files when converting a package into a Bazel package.
If you have any insights into why rules_python behaves this way or how I can resolve the issue with the unnecessary init.py file, I would greatly appreciate your input. (I guess only way is to avoid adding init.py or i need to patch the load_plugin method of pyqt5 library)
🔬 Minimal Reproduction
Install PyQt5 as an external dependency using rules_python. Then, attempt to load a .ui file using uic. This process will require loading a plugin, which may result in an error.
🔥 Exception or Error
🌍 Your Environment
Operating System:
Output of
bazel version
:Rules_python version:
Anything else relevant?
The text was updated successfully, but these errors were encountered: