Fix support for python3 in tools/js/bower2bazel.py
Change-Id: I1f222dafcacbdfe8525c95823a2e4ab07493460a
(cherry picked from commit 0fb28c14d3
)
This commit is contained in:
@@ -98,10 +98,15 @@ def build_bower_json(version_targets, seeds):
|
|||||||
json.dump(bower_json, f, indent=2)
|
json.dump(bower_json, f, indent=2)
|
||||||
return ret
|
return ret
|
||||||
|
|
||||||
|
def decode(input):
|
||||||
|
try:
|
||||||
|
return input.decode("utf-8")
|
||||||
|
except TypeError:
|
||||||
|
return input
|
||||||
|
|
||||||
def bower_command(args):
|
def bower_command(args):
|
||||||
base = subprocess.check_output(["bazel", "info", "output_base"]).strip()
|
base = subprocess.check_output(["bazel", "info", "output_base"]).strip()
|
||||||
exp = os.path.join(base, "external", "bower", "*npm_binary.tgz")
|
exp = os.path.join(decode(base), "external", "bower", "*npm_binary.tgz")
|
||||||
fs = sorted(glob.glob(exp))
|
fs = sorted(glob.glob(exp))
|
||||||
assert len(fs) == 1, "bower tarball not found or have multiple versions %s" % fs
|
assert len(fs) == 1, "bower tarball not found or have multiple versions %s" % fs
|
||||||
return ["python", os.getcwd() + "/tools/js/run_npm_binary.py", sorted(fs)[0]] + args
|
return ["python", os.getcwd() + "/tools/js/run_npm_binary.py", sorted(fs)[0]] + args
|
||||||
@@ -117,8 +122,8 @@ def main(args):
|
|||||||
"bazel", "query", "kind(bower_component_bundle, //polygerrit-ui/...)"])
|
"bazel", "query", "kind(bower_component_bundle, //polygerrit-ui/...)"])
|
||||||
seed_str = subprocess.check_output([
|
seed_str = subprocess.check_output([
|
||||||
"bazel", "query", "attr(seed, 1, kind(bower_component, deps(//polygerrit-ui/...)))"])
|
"bazel", "query", "attr(seed, 1, kind(bower_component, deps(//polygerrit-ui/...)))"])
|
||||||
targets = [s for s in target_str.split('\n') if s]
|
targets = [s for s in decode(target_str).split('\n') if s]
|
||||||
seeds = [s for s in seed_str.split('\n') if s]
|
seeds = [s for s in decode(seed_str).split('\n') if s]
|
||||||
prefix = "//lib/js:"
|
prefix = "//lib/js:"
|
||||||
non_seeds = [s for s in seeds if not s.startswith(prefix)]
|
non_seeds = [s for s in seeds if not s.startswith(prefix)]
|
||||||
assert not non_seeds, non_seeds
|
assert not non_seeds, non_seeds
|
||||||
@@ -203,7 +208,7 @@ def interpret_bower_json(seeds, ws_out, build_out):
|
|||||||
out = subprocess.check_output(["find", "bower_components/", "-name", ".bower.json"])
|
out = subprocess.check_output(["find", "bower_components/", "-name", ".bower.json"])
|
||||||
|
|
||||||
data = []
|
data = []
|
||||||
for f in sorted(out.split('\n')):
|
for f in sorted(decode(out).split('\n')):
|
||||||
if not f:
|
if not f:
|
||||||
continue
|
continue
|
||||||
pkg = json.load(open(f))
|
pkg = json.load(open(f))
|
||||||
|
Reference in New Issue
Block a user