From c871ce0f51bcc77e033d85204ca77efcb167d356 Mon Sep 17 00:00:00 2001 From: Claudio Bley Date: Mon, 30 Oct 2023 09:29:07 +0100 Subject: 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 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 --- pkgs/development/tools/build-managers/bazel/python-bin-path-test.nix | 1 + 1 file changed, 1 insertion(+) (limited to 'pkgs/development/tools/build-managers') diff --git a/pkgs/development/tools/build-managers/bazel/python-bin-path-test.nix b/pkgs/development/tools/build-managers/bazel/python-bin-path-test.nix index d560b0af848..1ab073a64c8 100644 --- a/pkgs/development/tools/build-managers/bazel/python-bin-path-test.nix +++ b/pkgs/development/tools/build-managers/bazel/python-bin-path-test.nix @@ -51,6 +51,7 @@ let py_binary( name = "bin", srcs = [ "bin.py" ], + imports = [ "." ], deps = [ ":lib" ], ) ''; -- cgit 1.4.1