summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Ostrovsky <david@ostrovsky.org>2021-03-03 11:52:30 +0100
committerPatrick Hiesel <hiesel@google.com>2021-08-05 11:31:48 +0000
commit6bc4f98a97ac3f2cf86f77e0fce3ed5fce572774 (patch)
tree11eba597409800e042ba220dec26e05105ae0580
parent18dd78a5365a89fa33405a4e8e68f60136926bf8 (diff)
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: Ia4ca09e65a451868de738d3dba6f62fdd7c5e50d (cherry picked from commit 2b5fe095f9431e995b23d3517a052fa7f4c36638)
-rw-r--r--.bazelrc2
-rw-r--r--Documentation/dev-bazel.txt2
-rwxr-xr-xDocumentation/replace_macros.py2
-rwxr-xr-xcontrib/check-valid-commit.py2
-rwxr-xr-xcontrib/git-push-review2
-rwxr-xr-xcontrib/populate-fixture-data.py2
-rw-r--r--tools/bzl/js.bzl10
-rw-r--r--tools/bzl/license-map.py2
-rw-r--r--tools/bzl/license.bzl2
-rw-r--r--tools/bzl/maven_jar.bzl2
-rwxr-xr-xtools/download_file.py2
-rwxr-xr-xtools/eclipse/project.py2
-rwxr-xr-xtools/js/download_bower.py2
-rwxr-xr-xtools/js/npm_pack.py2
-rw-r--r--tools/js/run_npm_binary.py2
-rwxr-xr-xtools/maven/mvn.py2
-rw-r--r--tools/util_test.py2
-rwxr-xr-xtools/version.py2
-rw-r--r--tools/workspace_status.py2
-rw-r--r--tools/workspace_status_release.py10
20 files changed, 28 insertions, 28 deletions
diff --git a/.bazelrc b/.bazelrc
index bf3aa6c3b0..e560f2397a 100644
--- a/.bazelrc
+++ b/.bazelrc
@@ -1,4 +1,4 @@
-build --workspace_status_command="python ./tools/workspace_status.py" --strategy=Closure=worker
+build --workspace_status_command="python3 ./tools/workspace_status.py" --strategy=Closure=worker
build --repository_cache=~/.gerritcodereview/bazel-cache/repository
build --action_env=PATH
build --disk_cache=~/.gerritcodereview/bazel-cache/cas
diff --git a/Documentation/dev-bazel.txt b/Documentation/dev-bazel.txt
index 2a8b7c17f0..10ee7616bc 100644
--- a/Documentation/dev-bazel.txt
+++ b/Documentation/dev-bazel.txt
@@ -7,7 +7,7 @@ To build Gerrit from source, you need:
* A Linux or macOS system (Windows is not supported at this time)
* A JDK for Java 8|9|10|11|...
-* Python 2 or 3
+* Python 3
* link:https://github.com/nodesource/distributions/blob/master/README.md[Node.js (including npm)]
* Bower (`sudo npm install -g bower`)
* link:https://docs.bazel.build/versions/master/install.html[Bazel] -launched with
diff --git a/Documentation/replace_macros.py b/Documentation/replace_macros.py
index aaa9223bf0..f2702313db 100755
--- a/Documentation/replace_macros.py
+++ b/Documentation/replace_macros.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
# coding=utf-8
# Copyright (C) 2013 The Android Open Source Project
#
diff --git a/contrib/check-valid-commit.py b/contrib/check-valid-commit.py
index 763ae3e062..bb018f9bcf 100755
--- a/contrib/check-valid-commit.py
+++ b/contrib/check-valid-commit.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
from __future__ import print_function
diff --git a/contrib/git-push-review b/contrib/git-push-review
index b995fc25a6..5a7f664bf3 100755
--- a/contrib/git-push-review
+++ b/contrib/git-push-review
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
# Copyright (C) 2014 The Android Open Source Project
#
# Licensed under the Apache License, Version 2.0 (the "License");
diff --git a/contrib/populate-fixture-data.py b/contrib/populate-fixture-data.py
index 4c6769cf3e..e51e29d0eb 100755
--- a/contrib/populate-fixture-data.py
+++ b/contrib/populate-fixture-data.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
# Copyright (C) 2016 The Android Open Source Project
#
# Licensed under the Apache License, Version 2.0 (the "License");
diff --git a/tools/bzl/js.bzl b/tools/bzl/js.bzl
index b428a2d903..9baa30c156 100644
--- a/tools/bzl/js.bzl
+++ b/tools/bzl/js.bzl
@@ -26,7 +26,7 @@ def _npm_binary_impl(ctx):
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]
@@ -49,7 +49,7 @@ ComponentInfo = provider()
# 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([
str(python_bin),
str(ctx.path(ctx.attr._run_npm)),
@@ -63,7 +63,7 @@ def _bower_archive(ctx):
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, []),
@@ -318,7 +318,7 @@ def _bundle_impl(ctx):
app_path = app_path[app_path.index(pkg_dir) + len(pkg_dir):]
hermetic_npm_binary = " ".join([
- "python",
+ "python3",
"$p/" + ctx.file._run_npm.path,
"$p/" + ctx.file._bundler_archive.path,
"--inline-scripts",
@@ -369,7 +369,7 @@ def _bundle_impl(ctx):
if ctx.attr.split:
hermetic_npm_command = "export PATH && " + " ".join([
- "python",
+ "python3",
ctx.file._run_npm.path,
ctx.file._crisper_archive.path,
"--script-in-head=false",
diff --git a/tools/bzl/license-map.py b/tools/bzl/license-map.py
index 2779130f47..e23331852d 100644
--- a/tools/bzl/license-map.py
+++ b/tools/bzl/license-map.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
# reads bazel query XML files, to join target names with their licenses.
diff --git a/tools/bzl/license.bzl b/tools/bzl/license.bzl
index 5a6bf7fa63..ec89c41608 100644
--- a/tools/bzl/license.bzl
+++ b/tools/bzl/license.bzl
@@ -25,7 +25,7 @@ def license_map(name, targets = [], opts = [], **kwargs):
# post process the XML into our favorite format.
native.genrule(
name = "gen_license_txt_" + name,
- cmd = "python $(location //tools/bzl:license-map.py) %s %s > $@" % (" ".join(opts), " ".join(xmls)),
+ cmd = "python3 $(location //tools/bzl:license-map.py) %s %s > $@" % (" ".join(opts), " ".join(xmls)),
outs = [name + ".gen.txt"],
tools = tools,
**kwargs
diff --git a/tools/bzl/maven_jar.bzl b/tools/bzl/maven_jar.bzl
index 5bc181b24a..fa7fbf78e8 100644
--- a/tools/bzl/maven_jar.bzl
+++ b/tools/bzl/maven_jar.bzl
@@ -154,7 +154,7 @@ def _maven_jar_impl(ctx):
binjar_path = ctx.path("/".join(["jar", binjar]))
binurl = url + ".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/download_file.py b/tools/download_file.py
index 936bcef32c..2af2c0722c 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 9915a6e213..77dc226fd7 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) 2016 The Android Open Source Project
#
# Licensed under the Apache License, Version 2.0 (the "License");
diff --git a/tools/js/download_bower.py b/tools/js/download_bower.py
index d541b565a9..2a75fc16ed 100755
--- a/tools/js/download_bower.py
+++ b/tools/js/download_bower.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
# Copyright (C) 2015 The Android Open Source Project
#
# Licensed under the Apache License, Version 2.0 (the "License");
diff --git a/tools/js/npm_pack.py b/tools/js/npm_pack.py
index 57f31661c5..33b38a0280 100755
--- a/tools/js/npm_pack.py
+++ b/tools/js/npm_pack.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
# Copyright (C) 2015 The Android Open Source Project
#
# Licensed under the Apache License, Version 2.0 (the "License");
diff --git a/tools/js/run_npm_binary.py b/tools/js/run_npm_binary.py
index bdee5ab489..31f8a54113 100644
--- a/tools/js/run_npm_binary.py
+++ b/tools/js/run_npm_binary.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
# Copyright (C) 2015 The Android Open Source Project
#
# Licensed under the Apache License, Version 2.0 (the "License");
diff --git a/tools/maven/mvn.py b/tools/maven/mvn.py
index 60e9f15608..4ed5bf95d5 100755
--- a/tools/maven/mvn.py
+++ b/tools/maven/mvn.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/util_test.py b/tools/util_test.py
index 1a389f552c..ab1133b22e 100644
--- a/tools/util_test.py
+++ b/tools/util_test.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/version.py b/tools/version.py
index 2326757a05..d02fc26c76 100755
--- a/tools/version.py
+++ b/tools/version.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
# Copyright (C) 2014 The Android Open Source Project
#
# Licensed under the Apache License, Version 2.0 (the "License");
diff --git a/tools/workspace_status.py b/tools/workspace_status.py
index 86df519ed5..0dc4a48bfe 100644
--- a/tools/workspace_status.py
+++ b/tools/workspace_status.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
# This script will be run by bazel when the build process starts to
# generate key-value information that represents the status of the
diff --git a/tools/workspace_status_release.py b/tools/workspace_status_release.py
index 36535fb70f..b3e72ff76a 100644
--- a/tools/workspace_status_release.py
+++ b/tools/workspace_status_release.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
# This is a variant of the `workspace_status.py` script that in addition to
# plain `git describe` implements a few heuristics to arrive at more to the
@@ -9,7 +9,7 @@
#
# To use it, simply add
#
-# --workspace_status_command="python ./tools/workspace_status_release.py"
+# --workspace_status_command="python3 ./tools/workspace_status_release.py"
#
# to your bazel command. So for example instead of
#
@@ -17,11 +17,11 @@
#
# use
#
-# bazel build --workspace_status_command="python ./tools/workspace_status_release.py" release.war
+# bazel build --workspace_status_command="python3 ./tools/workspace_status_release.py" release.war
#
# Alternatively, you can add
#
-# build --workspace_status_command="python ./tools/workspace_status_release.py"
+# build --workspace_status_command="python3 ./tools/workspace_status_release.py"
#
# to `.bazelrc` in your home directory.
#
@@ -150,7 +150,7 @@ def print_stamps_for_cwd(name, template):
'tools', 'workspace_status_release.py')
if os.path.isfile(workspace_status_script):
# directory has own workspace_status_command, so we use stamps from that
- for line in run(["python", workspace_status_script]).split('\n'):
+ for line in run(["python3", workspace_status_script]).split('\n'):
if re.search("^STABLE_[a-zA-Z0-9().:@/_ -]*$", line):
print(line)
else: