-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Mitigate python user site-packages #8476
Mitigate python user site-packages #8476
Conversation
+@soonho-tri for all review, please. Could you also test locally on macOS if possible? |
This can be tested using the repro in bazelbuild/bazel#4939. When bug is present the |
On macOS, I've checked that without this fix, Reviewed 1 of 1 files at r1. Comments from Reviewable |
For the simple example in the upstream issue, using But somehow, it's not the case for the Drake. This is what I did to test it:
which is expected. Review status: all files reviewed at latest revision, all discussions resolved, some commit checks failed. Comments from Reviewable |
Are there any cases where this breaks the macOS build? If not, then my proposal would be to rework it slightly to include macOS TODOs but then merge so at least Ubuntu is fixed (and leave the issue open). What do you think? Review status: all files reviewed at latest revision, all discussions resolved, some commit checks failed. Comments from Reviewable |
Our setup script will not install a PIP package if it already exists locally. Then Drake will not pick it up (if this PR get merged) and it will cause a problem. Review status: all files reviewed at latest revision, all discussions resolved, some commit checks failed. Comments from Reviewable |
FWIW I install everything with Review status: all files reviewed at latest revision, all discussions resolved, some commit checks failed. Comments from Reviewable |
@soonho-tri I am having trouble reconciling these two statements:
Maybe I will try some things on Review status: all files reviewed at latest revision, all discussions resolved, some commit checks failed. Comments from Reviewable |
It's about the current macOS issue that I have. I think it's a Drake-specific issue but I have no clues at the same time.
Even if we resolve my issue (macOS + Drake-specific?), I think we will have a problem because of this local python packages. I guess it's not macOS-specific. Review status: all files reviewed at latest revision, all discussions resolved, some commit checks failed. Comments from Reviewable |
Well, on Ubuntu we should not use I guess I buy that for macOS, if users have previously done Possibly mac's Review status: all files reviewed at latest revision, all discussions resolved, some commit checks failed. Comments from Reviewable |
FYI, it seems that we have the same problem on Ubuntu. Could you check? Review status: all files reviewed at latest revision, all discussions resolved, some commit checks failed. Comments from Reviewable |
Aha. So I guess jwnimmer@call-cc:~/jwnimmer-tri/drake$ git diff tools/vector_gen/vector_gen.bzl
diff --git a/tools/vector_gen/vector_gen.bzl b/tools/vector_gen/vector_gen.bzl
index c1ba33c..a7559c9 100644
--- a/tools/vector_gen/vector_gen.bzl
+++ b/tools/vector_gen/vector_gen.bzl
@@ -78,6 +78,7 @@ def _vector_gen_impl(ctx):
] + [
"--out=%s" % out.path for out in ctx.outputs.outs
],
+ env = {"PYTHONNOUSERSITE": "1"},
executable = ctx.executable.lcm_vector_gen,
)
return struct() I was testing with |
This really makes me think that the |
e013c8d
to
e6a94a1
Compare
I've pushed a revision that sets |
Now the negative testing (pyyaml installed locally) works as expected (FAIL) on mac and Ubuntu.
Correct. I just forget that we do not use PIP at all in those install scripts. @jamiesnape , can we have something like the following to warn mac users if they have installed the packages used by Drake using import pip
from os.path import expanduser
home = expanduser("~")
for item in pip.get_installed_distributions():
# Need to check if item is in the requirement list.
if item.location.startswith(home):
print(("Error: {} is installed locally (--user) "
"and Drake will ignore this package")
.format(item.project_name)) Reviewed 2 of 2 files at r2. Comments from Reviewable |
I am still pondering how best to support macOS users who do In the alternative, I am looking at how to let macOS users opt-in to the user site packages, which I guess Soonho's sample code above could suggest as a resolution, if we go that route. |
e6a94a1
to
c219995
Compare
I decided to focus on the codegen rules, and not worry about tests and stuff yet. I retracted the I fixed godotengine by changing the imports; it was the only real genrule at risk. The other codegen genrules are the cps stuff that doesn't really import enough to be worrisome yet. I fixed the vector_gen rule to allow for user site-packages for PyYAML on macOS; the cmake_configure_file rule doesn't need anything from pip so I locked it down fully. This is no longer a trivial PR, so needs at least a second reviewer. |
c219995
to
8455c42
Compare
Reviewed 5 of 6 files at r3. Comments from Reviewable |
Reviewed 1 of 2 files at r2, 5 of 6 files at r3. tools/vector_gen/vector_gen.bzl, line 106 at r3 (raw file):
Since the directory is different on Mac, something like tools/workspace/cmake_configure_file.bzl, line 17 at r3 (raw file):
BTW This is a different behavior to Comments from Reviewable |
8455c42
to
16bd174
Compare
Review status: 3 of 7 files reviewed at latest revision, 2 unresolved discussions. tools/vector_gen/vector_gen.bzl, line 106 at r3 (raw file): Previously, jamiesnape (Jamie Snape) wrote…
Done (in new file). tools/workspace/cmake_configure_file.bzl, line 17 at r3 (raw file): Previously, jamiesnape (Jamie Snape) wrote…
Done. My initial thought was that since this program doesn't use anything from pip, we didn't need the complexity. But on second thought, why try to parse that distinction -- better to just reuse the same settings for everything, so I've factored into a helper. Comments from Reviewable |
Reviewed 4 of 5 files at r4. Comments from Reviewable |
1 similar comment
Reviewed 4 of 5 files at r4. Comments from Reviewable |
This avoids potential collisions with modules named "core" or "methods" found in user site-packages (e.g., $HOME/.local).
Importing from $HOME is not hermetic. This only fixes a few cases where a rule() is invoking Python. Many genrule()s are left untouched.
16bd174
to
7a25b4e
Compare
@drake-jenkins-bot mac-sierra-clang-bazel-experimental-everything please |
Closes #8475 as best we can right now. Hopefully upstream will provide a more comprehensive solution.
Do not merge until:
This change is