-
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 are not hermetic #890
Comments
I found a particularly difficult effect of this. If the environment has google-auth (or possibly other packages that use setuptools's namespaces) installed as a system or user site- or dist-package, then Python 2.7 will load a
The only workaround I could find is to delete either uninstall the site package or delete the .pth file. I believe it is also possibly to work around this by activating an empty virtualenv before invoking Bazel, but I haven't tried. |
I've heard about issues with the google namespace package before. Not sure where the canonical thread for that is. About hermetic python: In order to not rely on the system python interpreter, the interpreter would have to somehow be part of the workspace, either vendored into the main repo or else referred to as an external repo from the WORKSPACE file. The former option would be undertaken by the user. I suppose the latter option would imply that we either upstream BUILD files into CPython, or else maintain a canonical Python-in-Bazel repo somewhere. |
Re: namespace packages: bazelbuild/rules_python#14 but if I remember correctly, that's about a different implementation of namespace packages to the .pth files mentioned above. |
This thread discusses two separate issues that can be dupped against other bugs, so I'll go ahead and close it. For the hermeticity issue: It's standard practice that Bazel can invoke either system tools (non-hermetically) or tools vendored into the workspace. Follow #7375 for the feature work needed to give better control over what runtime the Python rules use. For the imports issue: Name clashes happen in Python, and I don't think Bazel is in a position to avoid them when two separate projects insist on being called the same thing. But it sounds like the issue here is that a system library is conflicting with the name of a top-level package |
Having a locally installed google-auth Python package may cause bazel test to fail, a consequence of bazel's Python rules not being hermetic. Users following our how-to guides may run into this, as they are asked to pip install google-auth. See also: bazelbuild/bazel#890 (comment) Change-Id: Idc0d34ecc81b910b663bf380da14c3e7cf6d8415 GitOrigin-RevId: bec997c
the code is run by the system python, it seems, so it depends on what is installed.
It would be nice to only require bazel.
The text was updated successfully, but these errors were encountered: