Migrate to python 3

Given that on most systems Python is still linked to the Python 2.7,
switch explicitly to using Python 3.

Python 2.7 was discontinued on January 1, 2020: [1].

Moreover, there is PEP recommending to use python3 in the shebang: [2].

[1] https://www.python.org/doc/sunset-python-2
[2] https://www.python.org/dev/peps/pep-0394

Change-Id: I84e87db6e2dd90e5807d6e90a16eec451c4dc511
diff --git a/tools/download_file.py b/tools/download_file.py
index f62a43c..092a81f 100755
--- a/tools/download_file.py
+++ b/tools/download_file.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
 # Copyright (C) 2013 The Android Open Source Project
 #
 # Licensed under the Apache License, Version 2.0 (the "License");
diff --git a/tools/eclipse/project.py b/tools/eclipse/project.py
index 154ae53..4929e81 100755
--- a/tools/eclipse/project.py
+++ b/tools/eclipse/project.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
 # Copyright (C) 2017 The Android Open Source Project
 #
 # Licensed under the Apache License, Version 2.0 (the "License");
diff --git a/tools/js.bzl b/tools/js.bzl
index 7bd33da..1b63a04 100644
--- a/tools/js.bzl
+++ b/tools/js.bzl
@@ -30,7 +30,7 @@
     else:
         fail("repository %s not in {%s,%s}" % (repository, GERRIT, NPMJS))
 
-    python = ctx.which("python")
+    python = ctx.which("python3")
     script = ctx.path(ctx.attr._download_script)
 
     args = [python, script, "-o", dest, "-u", url, "-v", sha1]
@@ -53,7 +53,7 @@
 
 # for use in repo rules.
 def _run_npm_binary_str(ctx, tarball, args):
-    python_bin = ctx.which("python")
+    python_bin = ctx.which("python3")
     return " ".join([
         python_bin,
         ctx.path(ctx.attr._run_npm),
@@ -67,7 +67,7 @@
     version_name = "%s__version.json" % ctx.name
 
     cmd = [
-        ctx.which("python"),
+        ctx.which("python3"),
         ctx.path(ctx.attr._download_bower),
         "-b",
         "%s" % _run_npm_binary_str(ctx, ctx.attr._bower_archive, []),
@@ -315,7 +315,7 @@
     zips = [z for d in ctx.attr.deps for z in d[ComponentInfo].transitive_zipfiles.to_list()]
 
     hermetic_npm_binary = " ".join([
-        "python",
+        "python3",
         "$p/" + ctx.file._run_npm.path,
         "$p/" + ctx.file._bundler_archive.path,
         "--inline-scripts",
@@ -364,7 +364,7 @@
 
     if ctx.attr.split:
         hermetic_npm_command = "export PATH && " + " ".join([
-            "python",
+            "python3",
             ctx.file._run_npm.path,
             ctx.file._crisper_archive.path,
             "--always-write-script",
diff --git a/tools/maven/package.bzl b/tools/maven/package.bzl
index 9b54e47..fcb899e 100644
--- a/tools/maven/package.bzl
+++ b/tools/maven/package.bzl
@@ -20,7 +20,7 @@
     "echo \"\" >> $@",
     "echo %s >> $@",
     "echo \"\" >> $@",
-    "echo 'python $$OUTPUT_BASE/%s' >> $@",
+    "echo 'python3 $$OUTPUT_BASE/%s' >> $@",
 ]))
 
 def maven_package(
diff --git a/tools/maven_jar.bzl b/tools/maven_jar.bzl
index fec3ea7..5ce74c6 100644
--- a/tools/maven_jar.bzl
+++ b/tools/maven_jar.bzl
@@ -136,7 +136,7 @@
     srcjar_path = ctx.path("/".join(["src", srcjar]))
     srcurl = url + "-sources.jar"
 
-    python = ctx.which("python")
+    python = ctx.which("python3")
     script = ctx.path(ctx.attr._download_script)
 
     args = [python, script, "-o", binjar_path, "-u", binurl]
diff --git a/tools/sonar/gen_sonar_project_properties.py b/tools/sonar/gen_sonar_project_properties.py
index daf1dda..86b1823 100755
--- a/tools/sonar/gen_sonar_project_properties.py
+++ b/tools/sonar/gen_sonar_project_properties.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
 # Copyright (C) 2018 The Android Open Source Project
 #
 # Licensed under the Apache License, Version 2.0 (the "License");
diff --git a/tools/sonar/sonar.py b/tools/sonar/sonar.py
index 18c5c22..f439488 100755
--- a/tools/sonar/sonar.py
+++ b/tools/sonar/sonar.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
 # Copyright (C) 2018 The Android Open Source Project
 #
 # Licensed under the Apache License, Version 2.0 (the "License");