Skip to content

Commit

Permalink
Convert to Python 3
Browse files Browse the repository at this point in the history
Python 2 has reached end-of-life.
This change was imported from Debian packaging.

Closes #11201.

PiperOrigin-RevId: 390083418
  • Loading branch information
olekw authored and copybara-github committed Aug 11, 2021
1 parent c51eb57 commit a5d2973
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ public void createExecutable(
* logic will extract the zip's runfiles into a temporary directory.
*
* The stub script has a shebang pointing to a first-stage Python interpreter (as of this
* writing "#!/usr/bin/env python"). When a zip file is built on unix, this shebang is also
* writing "#!/usr/bin/env python3"). When a zip file is built on unix, this shebang is also
* prepended to the final zip artifact. On Windows shebangs are ignored, and the launcher
* runs the first stage with an interpreter whose path is passed in as LaunchInfo.
*/
Expand Down Expand Up @@ -238,9 +238,7 @@ public void createExecutable(

if (OS.getCurrent() != OS.WINDOWS) {
PathFragment shExecutable = ShToolchain.getPathOrError(ruleContext);
// TODO(#8685): Remove this special-case handling as part of making the proper shebang a
// property of the Python toolchain configuration.
String pythonExecutableName = OS.getCurrent() == OS.OPENBSD ? "python3" : "python";
String pythonExecutableName = "python3";
// NOTE: keep the following line intact to support nix builds
String pythonShebang = "#!/usr/bin/env " + pythonExecutableName;
ruleContext.registerAction(
Expand Down
4 changes: 2 additions & 2 deletions src/test/py/bazel/launcher_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,7 @@ def testPyBinaryLauncher(self):
'helloworld(', ' name = "hello",', ' out = "hello.txt",', ')'
])
foo_py = self.ScratchFile('foo/foo.py', [
'#!/usr/bin/env python',
'#!/usr/bin/env python3',
'import sys',
'if len(sys.argv) == 2:',
' with open(sys.argv[1], "w") as f:',
Expand All @@ -364,7 +364,7 @@ def testPyBinaryLauncher(self):
' print("Hello World!")',
])
test_py = self.ScratchFile('foo/test.py', [
'#!/usr/bin/env python',
'#!/usr/bin/env python3',
'import unittest',
'class MyTest(unittest.TestCase):',
' def test_dummy(self):',
Expand Down

0 comments on commit a5d2973

Please sign in to comment.