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 adapted from Debian packaging.
  • Loading branch information
olekw committed Jul 23, 2021
1 parent 5b9aaa9 commit 68380a1
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 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 @@ -240,7 +240,7 @@ public void createExecutable(
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
2 changes: 1 addition & 1 deletion third_party/py/mock/setup.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#! /usr/bin/env python
#! /usr/bin/env python3

# Copyright (C) 2007-2012 Michael Foord & the mock team
# E-mail: fuzzyman AT voidspace DOT org DOT uk
Expand Down

0 comments on commit 68380a1

Please sign in to comment.