Skip to content

Commit 91b26dc

Browse files
Googlercopybara-github
Googler
authored andcommitted
Automated rollback of commit ad628ec.
*** 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
1 parent ad628ec commit 91b26dc

15 files changed

+182
-245
lines changed

src/BUILD

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -127,10 +127,7 @@ JAVA_TOOLS = [
127127
"//third_party/ijar:embedded_zipper_sources",
128128
"//third_party/ijar:zipper",
129129
"//third_party/java/j2objc:embedded_tools_srcs",
130-
"//third_party/py/abseil:srcs",
131130
"//third_party/py/concurrent:srcs",
132-
# TODO(laszlocsomor): delete "//third_party/py/gflags:srcs" after
133-
# every script in @bazel_tools was migrated to use Abseil.
134131
"//third_party/py/gflags:srcs",
135132
"//third_party/py/six:srcs",
136133
"//src/conditions:embedded_tools",

tools/android/BUILD

Lines changed: 28 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
1-
load("//tools/python:private/defs.bzl", "py_binary", "py_library", "py_test")
1+
load("//tools/python:private/defs.bzl", "py_library", "py_binary", "py_test")
22

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

55
py_binary(
66
name = "build_incremental_dexmanifest",
77
srcs = [":build_incremental_dexmanifest.py"],
8+
python_version = "PY2",
89
)
910

1011
sh_test(
@@ -26,14 +27,16 @@ sh_test(
2627
py_binary(
2728
name = "build_split_manifest",
2829
srcs = ["build_split_manifest.py"],
30+
python_version = "PY2",
2931
deps = [
30-
"//third_party/py/abseil",
32+
"//third_party/py/gflags",
3133
],
3234
)
3335

3436
py_test(
3537
name = "build_split_manifest_test",
3638
srcs = ["build_split_manifest_test.py"],
39+
python_version = "PY2",
3740
deps = [
3841
":build_split_manifest",
3942
],
@@ -42,15 +45,17 @@ py_test(
4245
py_binary(
4346
name = "incremental_install",
4447
srcs = ["incremental_install.py"],
48+
python_version = "PY2",
4549
deps = [
46-
"//third_party/py/abseil",
4750
"//third_party/py/concurrent:futures",
51+
"//third_party/py/gflags",
4852
],
4953
)
5054

5155
py_test(
5256
name = "incremental_install_test",
5357
srcs = ["incremental_install_test.py"],
58+
python_version = "PY2",
5459
tags = [
5560
# TODO(laszlocsomor): fix on Windows or describe why it cannot pass.
5661
"no_windows",
@@ -64,7 +69,8 @@ py_test(
6469
py_binary(
6570
name = "strip_resources",
6671
srcs = ["strip_resources.py"],
67-
deps = ["//third_party/py/abseil"],
72+
python_version = "PY2",
73+
deps = ["//third_party/py/gflags"],
6874
)
6975

7076
sh_test(
@@ -86,9 +92,10 @@ py_binary(
8692
srcs = [
8793
"aar_native_libs_zip_creator.py",
8894
],
95+
python_version = "PY2",
8996
deps = [
9097
":junction_lib",
91-
"//third_party/py/abseil",
98+
"//third_party/py/gflags",
9299
],
93100
)
94101

@@ -97,6 +104,7 @@ py_test(
97104
srcs = [
98105
"aar_native_libs_zip_creator_test.py",
99106
],
107+
python_version = "PY2",
100108
deps = [
101109
":aar_native_libs_zip_creator",
102110
],
@@ -105,14 +113,16 @@ py_test(
105113
py_binary(
106114
name = "stubify_manifest",
107115
srcs = ["stubify_manifest.py"],
116+
python_version = "PY2",
108117
deps = [
109-
"//third_party/py/abseil",
118+
"//third_party/py/gflags",
110119
],
111120
)
112121

113122
py_test(
114123
name = "stubify_manifest_test",
115124
srcs = ["stubify_manifest_test.py"],
125+
python_version = "PY2",
116126
deps = [
117127
":stubify_manifest",
118128
],
@@ -121,53 +131,61 @@ py_test(
121131
py_binary(
122132
name = "aar_embedded_jars_extractor",
123133
srcs = ["aar_embedded_jars_extractor.py"],
134+
python_version = "PY2",
124135
deps = [
125136
":junction_lib",
126-
"//third_party/py/abseil",
137+
"//third_party/py/gflags",
127138
],
128139
)
129140

130141
py_test(
131142
name = "aar_embedded_jars_extractor_test",
132143
srcs = ["aar_embedded_jars_extractor_test.py"],
144+
python_version = "PY2",
133145
deps = [":aar_embedded_jars_extractor"],
134146
)
135147

136148
py_binary(
137149
name = "aar_resources_extractor",
138150
srcs = ["aar_resources_extractor.py"],
151+
python_version = "PY2",
139152
deps = [
140153
":junction_lib",
141-
"//third_party/py/abseil",
154+
"//third_party/py/gflags",
142155
],
143156
)
144157

145158
py_test(
146159
name = "aar_resources_extractor_test",
147160
srcs = ["aar_resources_extractor_test.py"],
161+
python_version = "PY2",
148162
deps = [":aar_resources_extractor"],
149163
)
150164

151165
py_binary(
152166
name = "resource_extractor",
153167
srcs = ["resource_extractor.py"],
168+
python_version = "PY2",
154169
)
155170

156171
py_test(
157172
name = "resource_extractor_test",
158173
srcs = ["resource_extractor_test.py"],
174+
python_version = "PY2",
159175
deps = [":resource_extractor"],
160176
)
161177

162178
py_binary(
163179
name = "instrumentation_test_check",
164180
srcs = ["instrumentation_test_check.py"],
165-
deps = ["//third_party/py/abseil"],
181+
python_version = "PY2",
182+
deps = ["//third_party/py/gflags"],
166183
)
167184

168185
py_test(
169186
name = "instrumentation_test_check_test",
170187
srcs = ["instrumentation_test_check_test.py"],
188+
python_version = "PY2",
171189
deps = [":instrumentation_test_check"],
172190
)
173191

@@ -187,6 +205,7 @@ py_test(
187205
"//src/conditions:windows": "junction_test.py",
188206
"//conditions:default": "dummy_test.py",
189207
}),
208+
python_version = "PY2",
190209
deps = [
191210
":junction_lib",
192211
"//src/test/py/bazel:test_base",

tools/android/BUILD.tools

Lines changed: 8 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -216,47 +216,42 @@ alias(
216216
py_binary(
217217
name = "instrumentation_test_check",
218218
srcs = ["instrumentation_test_check.py"],
219-
# TODO(bazel-team): remove python_version = "PY2" while fixing https://github.com/bazelbuild/bazel/issues/10127.
220219
python_version = "PY2",
221-
deps = ["//third_party/py/abseil"],
220+
deps = ["//third_party/py/gflags"],
222221
)
223222

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

232230
py_binary(
233231
name = "build_split_manifest",
234232
srcs = ["build_split_manifest.py"],
235-
# TODO(bazel-team): remove python_version = "PY2" while fixing https://github.com/bazelbuild/bazel/issues/10127.
236233
python_version = "PY2",
237234
deps = [
238-
"//third_party/py/abseil",
235+
"//third_party/py/gflags",
239236
],
240237
)
241238

242239
py_binary(
243240
name = "incremental_install",
244241
srcs = ["incremental_install.py"],
245-
# TODO(bazel-team): remove python_version = "PY2" while fixing https://github.com/bazelbuild/bazel/issues/10127.
246242
python_version = "PY2",
247243
deps = [
248244
"//third_party/py/concurrent:futures",
249-
"//third_party/py/abseil",
245+
"//third_party/py/gflags",
250246
],
251247
)
252248

253249
py_binary(
254250
name = "strip_resources",
255251
srcs = ["strip_resources.py"],
256-
# TODO(bazel-team): remove python_version = "PY2" while fixing https://github.com/bazelbuild/bazel/issues/10127.
257252
python_version = "PY2",
258253
deps = [
259-
"//third_party/py/abseil",
254+
"//third_party/py/gflags",
260255
],
261256
)
262257

@@ -265,58 +260,51 @@ py_binary(
265260
srcs = [
266261
"aar_native_libs_zip_creator.py",
267262
],
268-
# TODO(bazel-team): remove python_version = "PY2" while fixing https://github.com/bazelbuild/bazel/issues/10127.
269263
python_version = "PY2",
270264
deps = [
271265
":junction_lib",
272-
"//third_party/py/abseil",
266+
"//third_party/py/gflags",
273267
],
274268
)
275269

276270
py_binary(
277271
name = "stubify_manifest",
278272
srcs = ["stubify_manifest.py"],
279-
# TODO(bazel-team): remove python_version = "PY2" while fixing https://github.com/bazelbuild/bazel/issues/10127.
280273
python_version = "PY2",
281274
deps = [
282-
"//third_party/py/abseil",
275+
"//third_party/py/gflags",
283276
],
284277
)
285278

286279
py_binary(
287280
name = "aar_embedded_jars_extractor",
288281
srcs = ["aar_embedded_jars_extractor.py"],
289-
# TODO(bazel-team): remove python_version = "PY2" while fixing https://github.com/bazelbuild/bazel/issues/10127.
290282
python_version = "PY2",
291283
deps = [
292284
":junction_lib",
293-
"//third_party/py/abseil",
285+
"//third_party/py/gflags",
294286
],
295287
)
296288

297289
py_binary(
298290
name = "aar_resources_extractor",
299291
srcs = ["aar_resources_extractor.py"],
300-
# TODO(bazel-team): remove python_version = "PY2" while fixing https://github.com/bazelbuild/bazel/issues/10127.
301292
python_version = "PY2",
302293
deps = [
303294
":junction_lib",
304-
"//third_party/py/abseil",
295+
"//third_party/py/gflags",
305296
],
306297
)
307298

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

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

tools/android/aar_embedded_jars_extractor.py

Lines changed: 12 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
# Lint as: python2, python3
21
# pylint: disable=g-direct-third-party-import
32
# Copyright 2016 The Bazel Authors. All rights reserved.
43
#
@@ -20,30 +19,23 @@
2019
of the jars and creates a param file for singlejar to merge them into one jar.
2120
"""
2221

23-
from __future__ import absolute_import
24-
from __future__ import division
25-
from __future__ import print_function
26-
2722
import os
2823
import re
2924
import sys
3025
import zipfile
3126

32-
from absl import app
33-
from absl import flags
34-
import six
35-
3627
from tools.android import junction
28+
from third_party.py import gflags
3729

38-
FLAGS = flags.FLAGS
30+
FLAGS = gflags.FLAGS
3931

40-
flags.DEFINE_string("input_aar", None, "Input AAR")
41-
flags.mark_flag_as_required("input_aar")
42-
flags.DEFINE_string("output_singlejar_param_file", None,
43-
"Output parameter file for singlejar")
44-
flags.mark_flag_as_required("output_singlejar_param_file")
45-
flags.DEFINE_string("output_dir", None, "Output directory to extract jars in")
46-
flags.mark_flag_as_required("output_dir")
32+
gflags.DEFINE_string("input_aar", None, "Input AAR")
33+
gflags.MarkFlagAsRequired("input_aar")
34+
gflags.DEFINE_string(
35+
"output_singlejar_param_file", None, "Output parameter file for singlejar")
36+
gflags.MarkFlagAsRequired("output_singlejar_param_file")
37+
gflags.DEFINE_string("output_dir", None, "Output directory to extract jars in")
38+
gflags.MarkFlagAsRequired("output_dir")
4739

4840

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

6658

@@ -76,7 +68,7 @@ def _Main(input_aar,
7668
output_dir_orig)
7769

7870

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

9991
if __name__ == "__main__":
10092
FLAGS(sys.argv)
101-
app.run(main)
93+
main()

0 commit comments

Comments
 (0)