@ -21,6 +21,7 @@ import filecmp
import glob
import glob
import os
import os
import os . path
import os . path
import pprint
import shutil
import shutil
import subprocess
import subprocess
import sys
import sys
@ -44,6 +45,7 @@ DEPS_FILE_CONTENT = """
# AUTO-GENERATED BY make_grpcio_tools.py!
# AUTO-GENERATED BY make_grpcio_tools.py!
CC_FILES = { cc_files }
CC_FILES = { cc_files }
PROTO_FILES = { proto_files }
PROTO_FILES = { proto_files }
CC_INCLUDE = { cc_include }
CC_INCLUDE = { cc_include }
@ -106,6 +108,18 @@ def bazel_query(query):
return output . decode ( " ascii " ) . splitlines ( )
return output . decode ( " ascii " ) . splitlines ( )
def _pretty_print_list ( items ) :
""" Pretty print python list """
formatted = pprint . pformat ( items , indent = 4 )
# add newline after opening bracket (and fix indent of the next line)
if formatted . startswith ( ' [ ' ) :
formatted = formatted [ 0 ] + ' \n ' + formatted [ 1 : ]
# add newline before closing bracket
if formatted . endswith ( ' ] ' ) :
formatted = formatted [ : - 1 ] + ' \n ' + formatted [ - 1 ]
return formatted
def get_deps ( ) :
def get_deps ( ) :
""" Write the result of the bazel query `query` against protobuf to
""" Write the result of the bazel query `query` against protobuf to
` out_file ` . """
` out_file ` . """
@ -125,8 +139,8 @@ def get_deps():
]
]
commit_hash = protobuf_submodule_commit_hash ( )
commit_hash = protobuf_submodule_commit_hash ( )
deps_file_content = DEPS_FILE_CONTENT . format (
deps_file_content = DEPS_FILE_CONTENT . format (
cc_files = cc_files ,
cc_files = _pretty_print_list ( sorted ( cc_files ) ) ,
proto_files = proto_files ,
proto_files = _pretty_print_list ( sorted ( proto_files ) ) ,
cc_include = repr ( GRPC_PYTHON_PROTOBUF_RELATIVE_ROOT ) ,
cc_include = repr ( GRPC_PYTHON_PROTOBUF_RELATIVE_ROOT ) ,
proto_include = repr ( GRPC_PYTHON_PROTOBUF_RELATIVE_ROOT ) ,
proto_include = repr ( GRPC_PYTHON_PROTOBUF_RELATIVE_ROOT ) ,
commit_hash = COMMIT_HASH_PREFIX + commit_hash + COMMIT_HASH_SUFFIX )
commit_hash = COMMIT_HASH_PREFIX + commit_hash + COMMIT_HASH_SUFFIX )