Merge branch 'stable-3.4' into stable-3.5
* stable-3.4:
download to GERRIT_CACHE_HOME when set
Migrate to python 3
tools/maven/package.bzl: Use bazelisk instead bazel
Change-Id: I3d13738ec314a23041bc9681164100d95df3d82f
diff --git a/tools/download_file.py b/tools/download_file.py
index f62a43c..1900b20 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");
@@ -17,7 +17,7 @@
from hashlib import sha1
from optparse import OptionParser
-from os import link, makedirs, path, remove
+from os import environ, link, makedirs, path, remove
import shutil
from subprocess import check_call, CalledProcessError
from sys import stderr
@@ -25,7 +25,10 @@
from zipfile import ZipFile, BadZipfile, LargeZipFile
GERRIT_HOME = path.expanduser('~/.gerritcodereview')
-CACHE_DIR = path.join(GERRIT_HOME, 'bazel-cache', 'downloaded-artifacts')
+CACHE_DIR = environ.get(
+ 'GERRIT_CACHE_HOME',
+ path.join(GERRIT_HOME, 'bazel-cache', 'downloaded-artifacts'))
+
LOCAL_PROPERTIES = 'local.properties'
diff --git a/tools/eclipse/project.py b/tools/eclipse/project.py
index 236fb75..f30a171 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 06feecd..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(
@@ -31,7 +31,7 @@
jar = {},
src = {},
doc = {}):
- build_cmd = ["bazel", "build"]
+ build_cmd = ["bazelisk", "build"]
mvn_cmd = [
"$(location @com_googlesource_gerrit_bazlets//tools/maven:mvn.py)",
"-v",
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");