Skip to content

Commit

Permalink
fix: generate packages in the output directory
Browse files Browse the repository at this point in the history
  • Loading branch information
cpcloud committed Nov 24, 2021
1 parent ae75384 commit a00cc06
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
5 changes: 5 additions & 0 deletions protoletariat/fdsetgen.py
Expand Up @@ -54,6 +54,11 @@ def fix_imports(
if create_init:
generated_python_dir.joinpath("__init__.py").touch(exist_ok=True)

# recursively create packages
for dir_entry in generated_python_dir.rglob("*"):
if dir_entry.is_dir():
dir_entry.joinpath("__init__.py").touch(exist_ok=True)


class Protoc(FileDescriptorSetGenerator):
def __init__(
Expand Down
7 changes: 7 additions & 0 deletions protoletariat/tests/test_rewrite.py
Expand Up @@ -477,3 +477,10 @@ def test_nested_buf(
importlib.import_module("out_nested")
importlib.import_module("out_nested.a.b.c.thing2_pb2")
importlib.import_module("out_nested.d.thing1_pb2")

# check that we created packages in the correct locations
assert out.joinpath("__init__.py").exists()
assert out.joinpath("a", "__init__.py").exists()
assert out.joinpath("a", "b", "__init__.py").exists()
assert out.joinpath("a", "b", "c", "__init__.py").exists()
assert out.joinpath("d", "__init__.py").exists()

0 comments on commit a00cc06

Please sign in to comment.