From bd98f3521c13ec5520b46d306bc64d1cb87a9fc0 Mon Sep 17 00:00:00 2001 From: Nikolay Amiantov Date: Tue, 16 Jul 2019 02:19:51 +0300 Subject: [PATCH] bazel: drop absolute Python path Without this Bazel always picks Python 3 which breaks Python 2 packages. Strangely enough just dropping this patch works, with all `bazel.tests` passing. --- .../tools/build-managers/bazel/default.nix | 11 ++++------- .../build-managers/bazel/python-stub-path-fix.patch | 13 ------------- 2 files changed, 4 insertions(+), 20 deletions(-) delete mode 100644 pkgs/development/tools/build-managers/bazel/python-stub-path-fix.patch diff --git a/pkgs/development/tools/build-managers/bazel/default.nix b/pkgs/development/tools/build-managers/bazel/default.nix index bad0023eef3..f52b2e79fe1 100644 --- a/pkgs/development/tools/build-managers/bazel/default.nix +++ b/pkgs/development/tools/build-managers/bazel/default.nix @@ -136,8 +136,6 @@ stdenv.mkDerivation rec { # This is breaking the build of any C target. This patch removes the last # argument if it's found to be an empty string. ./trim-last-argument-to-gcc-if-empty.patch - - ./python-stub-path-fix.patch ] ++ lib.optional enableNixHacks ./nix-hacks.patch; @@ -220,13 +218,13 @@ stdenv.mkDerivation rec { cpp = callPackage ./cpp-test.nix { inherit runLocal bazelTest bazel-examples; }; java = callPackage ./java-test.nix { inherit runLocal bazelTest bazel-examples; }; protobuf = callPackage ./protobuf-test.nix { inherit runLocal bazelTest; }; - pythonBinPath = callPackage ./python-bin-path-test.nix{ inherit runLocal bazelTest; }; + pythonBinPath = callPackage ./python-bin-path-test.nix { inherit runLocal bazelTest; }; bashToolsWithNixHacks = callPackage ./bash-tools-test.nix { inherit runLocal bazelTest; bazel = bazelWithNixHacks; }; cppWithNixHacks = callPackage ./cpp-test.nix { inherit runLocal bazelTest bazel-examples; bazel = bazelWithNixHacks; }; javaWithNixHacks = callPackage ./java-test.nix { inherit runLocal bazelTest bazel-examples; bazel = bazelWithNixHacks; }; protobufWithNixHacks = callPackage ./protobuf-test.nix { inherit runLocal bazelTest; bazel = bazelWithNixHacks; }; - pythonBinPathWithNixHacks = callPackage ./python-bin-path-test.nix{ inherit runLocal bazelTest; bazel = bazelWithNixHacks; }; + pythonBinPathWithNixHacks = callPackage ./python-bin-path-test.nix { inherit runLocal bazelTest; bazel = bazelWithNixHacks; }; }; # update the list of workspace dependencies @@ -310,9 +308,8 @@ stdenv.mkDerivation rec { genericPatches = '' # Substitute python's stub shebang to plain python path. (see TODO add pr URL) # See also `postFixup` where python is added to $out/nix-support - substituteInPlace src/main/java/com/google/devtools/build/lib/bazel/rules/python/python_stub_template.txt\ - --replace "/usr/bin/env python" "${python3}/bin/python" \ - --replace "NIX_STORE_PYTHON_PATH" "${python3}/bin/python" \ + patchShebangs src/main/java/com/google/devtools/build/lib/bazel/rules/python/python_stub_template.txt \ + --replace "#!/usr/bin/env python" "#!${python3}/bin/python" # md5sum is part of coreutils sed -i 's|/sbin/md5|md5sum|' \ diff --git a/pkgs/development/tools/build-managers/bazel/python-stub-path-fix.patch b/pkgs/development/tools/build-managers/bazel/python-stub-path-fix.patch deleted file mode 100644 index cbc4192d2d9..00000000000 --- a/pkgs/development/tools/build-managers/bazel/python-stub-path-fix.patch +++ /dev/null @@ -1,13 +0,0 @@ -diff --git a/src/main/java/com/google/devtools/build/lib/bazel/rules/python/python_stub_template.txt b/src/main/java/com/google/devtools/build/lib/bazel/rules/python/python_stub_template.txt -index dac21c9a83..69b11c283f 100644 ---- a/src/main/java/com/google/devtools/build/lib/bazel/rules/python/python_stub_template.txt -+++ b/src/main/java/com/google/devtools/build/lib/bazel/rules/python/python_stub_template.txt -@@ -67,7 +67,7 @@ def FindPythonBinary(module_space): - return os.path.join(module_space, PYTHON_BINARY) - else: - # Case 4: Path has to be looked up in the search path. -- return SearchPath(PYTHON_BINARY) -+ return "NIX_STORE_PYTHON_PATH" - - def CreatePythonPathEntries(python_imports, module_space): - parts = python_imports.split(':');