-
Notifications
You must be signed in to change notification settings - Fork 84
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 toolchain is inhermetic: Uses user site packages #153
Comments
A possible workaround is described in the upstream issue: #153. Defining a Python wrapper in Nix that always sets |
@aherrmann Did you mean to link another issue? #153 is this issue.
genrule(
name = "gen",
outs =
["out"],
cmd =
("ln -s python `dirname $(location @python39//:bin/python)`/python3;" +
" PATH=`dirname $(location @python39//:bin/python)`:$$PATH $(location :foo)"),
tools =
[
":foo",
"@python39//:bin/python",
],
) Edit: Nevermind, I forgot to pass in the |
Oops, yes that must have been a clipboard failure. It's been a while, so I don't remember, but I guess I was referring to this one: bazelbuild/bazel#4939 (comment) I see that since then someone also suggested this approach: bazelbuild/bazel#4939 (comment)
Hmm, at least at the time I was able to reproduce it on Linux. It's possible that the work on setting |
@aherrmann I have been trying to reproduce the issue (accordingly to step provided in the description). Setups on which I have tested:
Excerpt of the generated py_runtime (by rules_nixpkgs python toolchain):
The nix-provided python interpreter seems not to be so eager to look into user site packages. However, the issue largely remains on python provided "as-is" by Bazel by default. Hope this helps! |
Describe the bug
A rules_nixpkgs provided Python toolchain will look for Python modules in user site packages, if present, e.g.
~/.local/lib/python3.6/site-packages
. This is an inhermeticity: The contents of user site packages are neither pinned by Bazel nor by Nix.To Reproduce
tests/BUILD.bazel
tests/foo.py
bazel build //tests:gen
cat bazel-bin/tests/out
Expected behavior
Python should not inspect user site packages.
Environment
Additional context
This is an instance of the following upstream issue: bazelbuild/bazel#4939
Thanks @guibou for reporting this.
The text was updated successfully, but these errors were encountered: