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

py_test allows non-hermetic unspecified dependencies #8501

Closed
mdvorsky opened this issue May 29, 2019 · 2 comments
Closed

py_test allows non-hermetic unspecified dependencies #8501

mdvorsky opened this issue May 29, 2019 · 2 comments
Labels
team-Rules-Python Native rules for Python

Comments

@mdvorsky
Copy link

mdvorsky commented May 29, 2019

Description of the problem / feature request:

py_test allows the source file to import an unspecified dependency

Bugs: what's the simplest, easiest way to reproduce this bug? Please provide a minimal example if possible.

$ cat WORKSPACE
$ cat BUILD
py_test(
    name = "test",
    srcs = ["test.py"]
)
$ cat test.py
import import_test
print('pass')
$ cat import_test.py
$ bazel test test
...
//:test                            PASSED in 0.1s

What operating system are you running Bazel on?

macOS Mojave 10.14.5

What's the output of bazel info release?

release 0.25.3-homebrew

Have you found anything relevant by searching the web?

No.

@brandjon brandjon added team-Rules-Python Native rules for Python untriaged labels May 29, 2019
@brandjon
Copy link
Member

Thanks for the report. This is #7091. In order to fix it we'd have to inject some sys.path manipulation logic into the initialization of the user Python process (not the stub script), or generate a dummy directory holding only a copy of the main file and nothing else, or both.

@mdvorsky
Copy link
Author

mdvorsky commented Dec 3, 2019

@brandjon the linked issue #7091 is now reported fixed in Bazel 1.2.1, but the above repro still works even with that version.

$ bazel version
Build label: 1.2.1-homebrew
Build target: bazel-out/darwin-opt/bin/src/main/java/com/google/devtools/build/lib/bazel/BazelServer_deploy.jar
Build time: Wed Nov 27 03:51:56 2019 (1574826716)
Build timestamp: 1574826716
Build timestamp as int: 1574826716

$ bazel test test
...
//:test                                                                  PASSED in 0.3s

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
team-Rules-Python Native rules for Python
Projects
None yet
Development

No branches or pull requests

2 participants