bazel_6: Fix pythonBinPath and pythonBinPathWithNixHacks tests
The tests started to fail after the repo-wide python 3.10 -> 3.11 update.
This is caused by Bazel's py_binary rule setting the [`PYTHONSAFEPATH`][1]
environment variable, which only has an effect for Python >= 3.11.
Setting this variable avoids prepending the current working directory and the
script's directory. The current test code relied on this behavior and thus
failed with:
```
Traceback (most recent call last):
File "/build/.cache/bazel/_bazel_build/8bcfff1c77854f2a2b07d1413b0fc106/execroot/our_workspace/bazel-out/k8-fastbuild/bin/python/bin.runfiles/our_workspace/python/bin.py", line 6, in <module>
from lib import foo
ModuleNotFoundError: No module named 'lib'
```
See also [bazelbuild/bazel#7091][2]
[1]: https://docs.python.org/3.11/using/cmdline.html#envvar-PYTHONSAFEPATH
[2]: https://github.com/bazelbuild/bazel/issues/7091
This commit is contained in:
@@ -51,6 +51,7 @@ let
|
||||
py_binary(
|
||||
name = "bin",
|
||||
srcs = [ "bin.py" ],
|
||||
imports = [ "." ],
|
||||
deps = [ ":lib" ],
|
||||
)
|
||||
'';
|
||||
|
||||
Reference in New Issue
Block a user