Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

protodoc: upgrade to Python 3. #8129

Merged
merged 1 commit into from
Sep 3, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions docs/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion tools/protodoc/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
8 changes: 4 additions & 4 deletions tools/protodoc/protodoc.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
from collections import defaultdict
import cProfile
import functools
import io
import os
import pstats
import StringIO
import re
import sys

Expand Down Expand Up @@ -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')

Expand All @@ -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__':
Expand Down