Skip to content

Commit

Permalink
Use python3 everywhere
Browse files Browse the repository at this point in the history
  • Loading branch information
Krishna Ersson committed Mar 17, 2022
1 parent 1537172 commit 938c427
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,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 @@ -251,11 +251,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";
// NOTE: keep the following line intact to support nix builds
String pythonShebang = "#!/usr/bin/env " + pythonExecutableName;
String pythonShebang = "#!/usr/bin/env python3";
ruleContext.registerAction(
new SpawnAction.Builder()
.addInput(zipFile)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
category = DocCategory.PROVIDER)
public interface PyRuntimeInfoApi<FileT extends FileApi> extends StarlarkValue {

static final String DEFAULT_STUB_SHEBANG = "#!/usr/bin/env python";
static final String DEFAULT_STUB_SHEBANG = "#!/usr/bin/env python3";

@StarlarkMethod(
name = "interpreter_path",
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
4 changes: 2 additions & 2 deletions tools/objc/libtool.sh
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,9 @@ function hash_objfile() {
echo "$SYMLINK_NAME"
}

python_executable=/usr/bin/python2.7
python_executable=/usr/bin/python3
if [[ ! -x "$python_executable" ]]; then
python_executable=python
python_executable=python3
fi

ARGS=()
Expand Down

0 comments on commit 938c427

Please sign in to comment.