diff --git a/docs/build.sh b/docs/build.sh index 1b8cac8b06fa..b959b159c40b 100755 --- a/docs/build.sh +++ b/docs/build.sh @@ -44,11 +44,11 @@ rm -rf "${GENERATED_RST_DIR}" mkdir -p "${GENERATED_RST_DIR}" source_venv "$BUILD_DIR" -pip install -r "${SCRIPT_DIR}"/requirements.txt +pip3 install -r "${SCRIPT_DIR}"/requirements.txt bazel build ${BAZEL_BUILD_OPTIONS} @envoy_api//docs:protos --aspects \ - tools/protodoc/protodoc.bzl%proto_doc_aspect --output_groups=rst --action_env=CPROFILE_ENABLED \ - --action_env=ENVOY_BLOB_SHA --spawn_strategy=standalone --host_force_python=PY2 + tools/protodoc/protodoc.bzl%proto_doc_aspect --output_groups=rst --action_env=CPROFILE_ENABLED=1 \ + --action_env=ENVOY_BLOB_SHA --spawn_strategy=standalone --host_force_python=PY3 # These are the protos we want to put in docs, this list will grow. # TODO(htuch): Factor this out of this script. diff --git a/tools/protodoc/BUILD b/tools/protodoc/BUILD index 8e428b5d24fd..b4b3c3f39acb 100644 --- a/tools/protodoc/BUILD +++ b/tools/protodoc/BUILD @@ -3,7 +3,7 @@ licenses(["notice"]) # Apache 2 py_binary( name = "protodoc", srcs = ["protodoc.py"], - python_version = "PY2", + python_version = "PY3", visibility = ["//visibility:public"], deps = [ "@com_envoyproxy_protoc_gen_validate//validate:validate_py", diff --git a/tools/protodoc/protodoc.py b/tools/protodoc/protodoc.py index bf6a869f0797..562d6de2ac5f 100755 --- a/tools/protodoc/protodoc.py +++ b/tools/protodoc/protodoc.py @@ -6,9 +6,9 @@ from collections import defaultdict import cProfile import functools +import io import os import pstats -import StringIO import re import sys @@ -709,7 +709,7 @@ def GenerateRst(proto_file): def Main(): # http://www.expobrain.net/2015/09/13/create-a-plugin-for-google-protocol-buffer/ request = plugin_pb2.CodeGeneratorRequest() - request.ParseFromString(sys.stdin.read()) + request.ParseFromString(sys.stdin.buffer.read()) response = plugin_pb2.CodeGeneratorResponse() cprofile_enabled = os.getenv('CPROFILE_ENABLED') @@ -724,14 +724,14 @@ def Main(): f.content = GenerateRst(proto_file) if cprofile_enabled: pr.disable() - stats_stream = StringIO.StringIO() + stats_stream = io.StringIO() ps = pstats.Stats(pr, stream=stats_stream).sort_stats(os.getenv('CPROFILE_SORTBY', 'cumulative')) stats_file = response.file.add() stats_file.name = proto_file.name + '.rst.profile' ps.print_stats() stats_file.content = stats_stream.getvalue() - sys.stdout.write(response.SerializeToString()) + sys.stdout.buffer.write(response.SerializeToString()) if __name__ == '__main__':