aboutsummaryrefslogtreecommitdiffstats
path: root/testing/bazel/python3.patch
blob: e427ba83ad366c8d07b5c5d44bcaf4a701d7937a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
Some scripts rely on /usr/bin/pyhton.

python2 package provides /usr/bin/python as a link to /usr/bin/python2
so there is no any issue here, but we do not want python2.

python3 package do not provide /usr/bin/python, only /usr/bin/python3.

To make things work we need to change shebang '#!/usr/bin/env python' to
'#!/usr/bin/env python3'.

This is a longstanding issue, one of the first traces to it could be seen
here [1] and here [2].

[1] https://github.com/bazelbuild/bazel/issues/544
[2] https://github.com/bazelbuild/bazel/issues/8446


--- a/src/main/java/com/google/devtools/build/lib/bazel/rules/python/python_stub_template.txt.orig
+++ b/src/main/java/com/google/devtools/build/lib/bazel/rules/python/python_stub_template.txt
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
 
 from __future__ import absolute_import
 from __future__ import division
--- a/src/main/java/com/google/devtools/build/lib/bazel/rules/python/BazelPythonSemantics.java.orig
+++ b/src/main/java/com/google/devtools/build/lib/bazel/rules/python/BazelPythonSemantics.java
@@ -241,7 +241,7 @@
                 .addOutput(executable)
                 .setShellCommand(
                     shExecutable,
-                    "echo '#!/usr/bin/env python' | cat - "
+                    "echo '#!/usr/bin/env python3' | cat - "
                         + zipFile.getExecPathString()
                         + " > "
                         + executable.getExecPathString())