Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(127)

Unified Diff: tools/protoc_wrapper/protoc_wrapper.py

Issue 2935953002: Fix protobuf's Python runtime and imports.
Patch Set: debug import path Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « third_party/protobuf/python/google/protobuf/descriptor_pb2.py ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/protoc_wrapper/protoc_wrapper.py
diff --git a/tools/protoc_wrapper/protoc_wrapper.py b/tools/protoc_wrapper/protoc_wrapper.py
index 6a25de0ed5a367cfffea3fae8dc436dc355d1f49..50aee8b98061019ec361a7d2731ae05b2437efe0 100755
--- a/tools/protoc_wrapper/protoc_wrapper.py
+++ b/tools/protoc_wrapper/protoc_wrapper.py
@@ -67,6 +67,17 @@ def WriteIncludes(headers, include):
print(line, file=f)
+def WritePythonInit(base_dir, protos):
+ def write_init_py(path):
+ if not path:
+ return
+ open(os.path.join(base_dir, path, '__init__.py'), 'a').close()
+ write_init_py(os.path.dirname(path))
+
+ for proto in protos:
+ write_init_py(os.path.dirname(proto))
+
+
def main(argv):
parser = argparse.ArgumentParser()
parser.add_argument("--protoc",
@@ -136,6 +147,9 @@ def main(argv):
if options.include:
WriteIncludes(headers, options.include)
+ if options.py_out_dir:
+ WritePythonInit(options.py_out_dir, protos)
+
if __name__ == "__main__":
try:
« no previous file with comments | « third_party/protobuf/python/google/protobuf/descriptor_pb2.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698