-
-
Notifications
You must be signed in to change notification settings - Fork 588
User site-packages directory should be ignored #1059
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
Comments
Can you expand a bit on the rationale/motivation for this idea? It's utility isn't obvious to me, though it's still an interesting idea. |
General configurability of the toolchain. For example, this issue itself. Other examples could include Obviously, these could also be set for all actions through |
This one bit me recently. A user had some packages installed in their user site packages dir ( edit: I can reliably reproduce this with the |
Interesting. For us, the following in our .bazelrc shields us just fine. I verified by deleting some deps from my test target. The tests pass if I don't set PYTHONNOUSERSITE, or if I restore the deps.
Note that your Python version needs to support the env var. |
This issue has been automatically marked as stale because it has not had any activity for 180 days. It will be closed if no further activity occurs in 30 days. |
I think this issue is still relevant. |
I think this is already fixed in https://github.com/aspect-build/rules_py because we run the interpreter in isolated mode. |
I was not able to get rules_py to work because of aspect-build/rules_py#159. |
@siddharthab, I think some parts of the isolation are present when running under Python 3.11 or newer. Is your issue related to #382, or is it that you need the hermeticity to be a part of build actions? |
The latter. I want bazel tests to not consider the packages the user has installed in their home directory. The other issue you reference is about PYTHONSAFEPATH env var. This issue is about a different env var. A general solution to have env vars be part of the toolchain configuration will be helpful in many contexts. |
This issue has been automatically marked as stale because it has not had any activity for 180 days. It will be closed if no further activity occurs in 30 days. |
This issue was automatically closed because it went 30 days without a reply since it was labeled "Can Close?" |
We have been using |
🚀 feature request
Relevant Rules
py_{library,binary,test}
Description
When running builds and tests, the user site-packages directory is not ignored, which makes the build less hermetic.Describe the solution you'd like
The registered toolchains could set an env var `PYTHONNOUSERSITE=1` every time they are run. This env var is already set for gazelle runs. More generally, the toolchains could also allow the user to set other environment variables for the toolchain.Describe alternatives you've considered
I have currently set `--action_env= PYTHONNOUSERSITE=1` to all bazel build steps, but it is less clean because actions that have nothing to do with Python don't need this env var.The text was updated successfully, but these errors were encountered: