Skip to content

Commit

Permalink
Automated rollback of commit ad628ec.
Browse files Browse the repository at this point in the history
*** Reason for rollback ***

TAP has detected 10 or more targets failed to build at ad628ec.

TO ROLLFORWARD (without additional approval): Use[]

To see all broken targets visit []
To prevent noise from flakes, TAP double-checked the following target fails to build:
[]
but used to build fine:
[]

Questions? Comments? See the URL:[]

*** Original change description ***

py2to3: update tools/android/*.py to PY3

Details:
- use six.ensure_str / six.ensure_bytes
- use absl.flags instead of gflags
- put third_party/py/abseil:srcs into @bazel_tools
  so the embedded Android tools can also use it
- remove python_version = "PY2" from py_binary and
  py_test rules (the default is "PY3"), except in
  BUILD.tools, to preserve PY2 compatibility for
  running Bazel (its embedded Python tools)
- added srcs_version = "PY2AND3" to BUILD.tools to
  make it explicit that these...

***

PiperOrigin-RevId: 278322023
  • Loading branch information
Googler authored and copybara-github committed Nov 4, 2019
1 parent ad628ec commit 91b26dc
Show file tree
Hide file tree
Showing 15 changed files with 182 additions and 245 deletions.
3 changes: 0 additions & 3 deletions src/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -127,10 +127,7 @@ JAVA_TOOLS = [
"//third_party/ijar:embedded_zipper_sources",
"//third_party/ijar:zipper",
"//third_party/java/j2objc:embedded_tools_srcs",
"//third_party/py/abseil:srcs",
"//third_party/py/concurrent:srcs",
# TODO(laszlocsomor): delete "//third_party/py/gflags:srcs" after
# every script in @bazel_tools was migrated to use Abseil.
"//third_party/py/gflags:srcs",
"//third_party/py/six:srcs",
"//src/conditions:embedded_tools",
Expand Down
37 changes: 28 additions & 9 deletions tools/android/BUILD
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
load("//tools/python:private/defs.bzl", "py_binary", "py_library", "py_test")
load("//tools/python:private/defs.bzl", "py_library", "py_binary", "py_test")

package(default_visibility = ["//tools:__pkg__"])

py_binary(
name = "build_incremental_dexmanifest",
srcs = [":build_incremental_dexmanifest.py"],
python_version = "PY2",
)

sh_test(
Expand All @@ -26,14 +27,16 @@ sh_test(
py_binary(
name = "build_split_manifest",
srcs = ["build_split_manifest.py"],
python_version = "PY2",
deps = [
"//third_party/py/abseil",
"//third_party/py/gflags",
],
)

py_test(
name = "build_split_manifest_test",
srcs = ["build_split_manifest_test.py"],
python_version = "PY2",
deps = [
":build_split_manifest",
],
Expand All @@ -42,15 +45,17 @@ py_test(
py_binary(
name = "incremental_install",
srcs = ["incremental_install.py"],
python_version = "PY2",
deps = [
"//third_party/py/abseil",
"//third_party/py/concurrent:futures",
"//third_party/py/gflags",
],
)

py_test(
name = "incremental_install_test",
srcs = ["incremental_install_test.py"],
python_version = "PY2",
tags = [
# TODO(laszlocsomor): fix on Windows or describe why it cannot pass.
"no_windows",
Expand All @@ -64,7 +69,8 @@ py_test(
py_binary(
name = "strip_resources",
srcs = ["strip_resources.py"],
deps = ["//third_party/py/abseil"],
python_version = "PY2",
deps = ["//third_party/py/gflags"],
)

sh_test(
Expand All @@ -86,9 +92,10 @@ py_binary(
srcs = [
"aar_native_libs_zip_creator.py",
],
python_version = "PY2",
deps = [
":junction_lib",
"//third_party/py/abseil",
"//third_party/py/gflags",
],
)

Expand All @@ -97,6 +104,7 @@ py_test(
srcs = [
"aar_native_libs_zip_creator_test.py",
],
python_version = "PY2",
deps = [
":aar_native_libs_zip_creator",
],
Expand All @@ -105,14 +113,16 @@ py_test(
py_binary(
name = "stubify_manifest",
srcs = ["stubify_manifest.py"],
python_version = "PY2",
deps = [
"//third_party/py/abseil",
"//third_party/py/gflags",
],
)

py_test(
name = "stubify_manifest_test",
srcs = ["stubify_manifest_test.py"],
python_version = "PY2",
deps = [
":stubify_manifest",
],
Expand All @@ -121,53 +131,61 @@ py_test(
py_binary(
name = "aar_embedded_jars_extractor",
srcs = ["aar_embedded_jars_extractor.py"],
python_version = "PY2",
deps = [
":junction_lib",
"//third_party/py/abseil",
"//third_party/py/gflags",
],
)

py_test(
name = "aar_embedded_jars_extractor_test",
srcs = ["aar_embedded_jars_extractor_test.py"],
python_version = "PY2",
deps = [":aar_embedded_jars_extractor"],
)

py_binary(
name = "aar_resources_extractor",
srcs = ["aar_resources_extractor.py"],
python_version = "PY2",
deps = [
":junction_lib",
"//third_party/py/abseil",
"//third_party/py/gflags",
],
)

py_test(
name = "aar_resources_extractor_test",
srcs = ["aar_resources_extractor_test.py"],
python_version = "PY2",
deps = [":aar_resources_extractor"],
)

py_binary(
name = "resource_extractor",
srcs = ["resource_extractor.py"],
python_version = "PY2",
)

py_test(
name = "resource_extractor_test",
srcs = ["resource_extractor_test.py"],
python_version = "PY2",
deps = [":resource_extractor"],
)

py_binary(
name = "instrumentation_test_check",
srcs = ["instrumentation_test_check.py"],
deps = ["//third_party/py/abseil"],
python_version = "PY2",
deps = ["//third_party/py/gflags"],
)

py_test(
name = "instrumentation_test_check_test",
srcs = ["instrumentation_test_check_test.py"],
python_version = "PY2",
deps = [":instrumentation_test_check"],
)

Expand All @@ -187,6 +205,7 @@ py_test(
"//src/conditions:windows": "junction_test.py",
"//conditions:default": "dummy_test.py",
}),
python_version = "PY2",
deps = [
":junction_lib",
"//src/test/py/bazel:test_base",
Expand Down
28 changes: 8 additions & 20 deletions tools/android/BUILD.tools
Original file line number Diff line number Diff line change
Expand Up @@ -216,47 +216,42 @@ alias(
py_binary(
name = "instrumentation_test_check",
srcs = ["instrumentation_test_check.py"],
# TODO(bazel-team): remove python_version = "PY2" while fixing https://github.com/bazelbuild/bazel/issues/10127.
python_version = "PY2",
deps = ["//third_party/py/abseil"],
deps = ["//third_party/py/gflags"],
)

py_binary(
name = "build_incremental_dexmanifest",
srcs = [":build_incremental_dexmanifest.py"],
# TODO(bazel-team): remove python_version = "PY2" while fixing https://github.com/bazelbuild/bazel/issues/10127.
python_version = "PY2",
deps = [],
)

py_binary(
name = "build_split_manifest",
srcs = ["build_split_manifest.py"],
# TODO(bazel-team): remove python_version = "PY2" while fixing https://github.com/bazelbuild/bazel/issues/10127.
python_version = "PY2",
deps = [
"//third_party/py/abseil",
"//third_party/py/gflags",
],
)

py_binary(
name = "incremental_install",
srcs = ["incremental_install.py"],
# TODO(bazel-team): remove python_version = "PY2" while fixing https://github.com/bazelbuild/bazel/issues/10127.
python_version = "PY2",
deps = [
"//third_party/py/concurrent:futures",
"//third_party/py/abseil",
"//third_party/py/gflags",
],
)

py_binary(
name = "strip_resources",
srcs = ["strip_resources.py"],
# TODO(bazel-team): remove python_version = "PY2" while fixing https://github.com/bazelbuild/bazel/issues/10127.
python_version = "PY2",
deps = [
"//third_party/py/abseil",
"//third_party/py/gflags",
],
)

Expand All @@ -265,58 +260,51 @@ py_binary(
srcs = [
"aar_native_libs_zip_creator.py",
],
# TODO(bazel-team): remove python_version = "PY2" while fixing https://github.com/bazelbuild/bazel/issues/10127.
python_version = "PY2",
deps = [
":junction_lib",
"//third_party/py/abseil",
"//third_party/py/gflags",
],
)

py_binary(
name = "stubify_manifest",
srcs = ["stubify_manifest.py"],
# TODO(bazel-team): remove python_version = "PY2" while fixing https://github.com/bazelbuild/bazel/issues/10127.
python_version = "PY2",
deps = [
"//third_party/py/abseil",
"//third_party/py/gflags",
],
)

py_binary(
name = "aar_embedded_jars_extractor",
srcs = ["aar_embedded_jars_extractor.py"],
# TODO(bazel-team): remove python_version = "PY2" while fixing https://github.com/bazelbuild/bazel/issues/10127.
python_version = "PY2",
deps = [
":junction_lib",
"//third_party/py/abseil",
"//third_party/py/gflags",
],
)

py_binary(
name = "aar_resources_extractor",
srcs = ["aar_resources_extractor.py"],
# TODO(bazel-team): remove python_version = "PY2" while fixing https://github.com/bazelbuild/bazel/issues/10127.
python_version = "PY2",
deps = [
":junction_lib",
"//third_party/py/abseil",
"//third_party/py/gflags",
],
)

py_binary(
name = "resource_extractor",
srcs = ["resource_extractor.py"],
# TODO(bazel-team): remove python_version = "PY2" while fixing https://github.com/bazelbuild/bazel/issues/10127.
python_version = "PY2",
)

py_library(
name = "junction_lib",
srcs = ["junction.py"],
# TODO(bazel-team): remove srcs_version = "PY2AND3" while fixing https://github.com/bazelbuild/bazel/issues/10127.
srcs_version = "PY2AND3",
visibility = ["//visibility:private"],
)

Expand Down
32 changes: 12 additions & 20 deletions tools/android/aar_embedded_jars_extractor.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# Lint as: python2, python3
# pylint: disable=g-direct-third-party-import
# Copyright 2016 The Bazel Authors. All rights reserved.
#
Expand All @@ -20,30 +19,23 @@
of the jars and creates a param file for singlejar to merge them into one jar.
"""

from __future__ import absolute_import
from __future__ import division
from __future__ import print_function

import os
import re
import sys
import zipfile

from absl import app
from absl import flags
import six

from tools.android import junction
from third_party.py import gflags

FLAGS = flags.FLAGS
FLAGS = gflags.FLAGS

flags.DEFINE_string("input_aar", None, "Input AAR")
flags.mark_flag_as_required("input_aar")
flags.DEFINE_string("output_singlejar_param_file", None,
"Output parameter file for singlejar")
flags.mark_flag_as_required("output_singlejar_param_file")
flags.DEFINE_string("output_dir", None, "Output directory to extract jars in")
flags.mark_flag_as_required("output_dir")
gflags.DEFINE_string("input_aar", None, "Input AAR")
gflags.MarkFlagAsRequired("input_aar")
gflags.DEFINE_string(
"output_singlejar_param_file", None, "Output parameter file for singlejar")
gflags.MarkFlagAsRequired("output_singlejar_param_file")
gflags.DEFINE_string("output_dir", None, "Output directory to extract jars in")
gflags.MarkFlagAsRequired("output_dir")


def ExtractEmbeddedJars(aar,
Expand All @@ -60,7 +52,7 @@ def ExtractEmbeddedJars(aar,
# output_dir may be a temporary junction, so write the original
# (unshortened) path to the params file
singlejar_param_file.write(
six.ensure_binary((output_dir_orig + "/" + name + "\n"), "utf-8"))
(output_dir_orig + "/" + name + "\n").encode("utf-8"))
aar.extract(name, output_dir)


Expand All @@ -76,7 +68,7 @@ def _Main(input_aar,
output_dir_orig)


def main(unused_argv):
def main():
if os.name == "nt":
# Shorten paths unconditionally, because the extracted paths in
# ExtractEmbeddedJars (which we cannot yet predict, because they depend on
Expand All @@ -98,4 +90,4 @@ def main(unused_argv):

if __name__ == "__main__":
FLAGS(sys.argv)
app.run(main)
main()
Loading

0 comments on commit 91b26dc

Please sign in to comment.