Skip to content
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

.pyc files in source directories #10996

Closed
RussTedrake opened this issue Mar 22, 2019 · 6 comments
Closed

.pyc files in source directories #10996

RussTedrake opened this issue Mar 22, 2019 · 6 comments

Comments

@RussTedrake
Copy link
Contributor

Running bazel run //doc:serve_sphinx results in doc/sphinx_base.pyc being left in the source dir (for git to complain about).

Running tests in manipulation station now results in examples/manipulation_station/differential_ik.pyc being left in the source dir.

Although I'm tempted to add the *.pyc to .gitignore, there is probably a better solution?

@jwnimmer-tri
Copy link
Collaborator

I started seeing this too, and was annoyed. I only now just realized that my realpath call in #10969 is likely at fault.

@jwnimmer-tri
Copy link
Collaborator

Actually, maybe it was tickled by my test runner change, but it was a bug in #10632 as it turns out.

@jwnimmer-tri
Copy link
Collaborator

The sphinx pyc file thing has been a bug for a while, I think it was @EricCousineau-TRI 8502b61 which did it. I'll let him decide how to mitigate / ignore it.

@EricCousineau-TRI
Copy link
Contributor

In the FWIW category, I always add *.pyc files to my global gitignore file.

But yeah, we shouldn't be spewing these out in the first place!

@EricCousineau-TRI
Copy link
Contributor

EricCousineau-TRI commented Mar 22, 2019

Confirmed that this also happens with --config=python3; in this case, it pukes __pycache__ all over the workspace.

Seems to be related to https://bugs.python.org/issue6386 (though probably not due to this bug, as the author wants to do weird things with relative imports?)

Made a repro as well, here: EricCousineau-TRI/repro@c913515

$ ./symlink_junk.sh python2
...
+ python2 ./symlink/root.py
...
+ find . -name '*.pyc' -o -name __pycache__
./sub.pyc

$ ./symlink_junk.sh python3
...
+ python3 ./symlink/root.py
...
+ find . -name '*.pyc' -o -name __pycache__
./__pycache__
./__pycache__/sub.cpython-36.pyc

This is mentioned here: bazelbuild/bazel#793 (comment)
EDIT: More directly here: bazelbuild/bazel#7091
Since bazel run runs without sandboxing, it spews junk everywhere.

I don't feel like doing any Bazel gymnastics to suppress this right now, as it's due to really esoteric behavior on Python's side for doing weird crap with symlinks. (I don't like this feature, and also really don't like that Python permits importing relative modules at all...)

(My ideal idea of behavior is that executing the symlink just straight up falls over, so that way there's no weird context bleeding that's currently happening.
Failing that, I'd prefer that the compiled bytecode litter the symlink tree instead...)

Will just submit a PR to suppress in .gitignore; maybe later we can try suppressing bytecode, but meh for now?

EDIT: Disclaimer: Still love Python. Just hate some of the odd design choices for paths...

@EricCousineau-TRI
Copy link
Contributor

EricCousineau-TRI commented Mar 22, 2019

Er, looking at #10997, will first try absolute importing (using the other implicit behavior I hate... auto-gen'd __init__.py files...)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants