-
Notifications
You must be signed in to change notification settings - Fork 0
Description
There's a certain schism in how Python's proto compiles, in that the python classes module path/namespace adheres to the proto file path instead of the package defined in the files.
Thus, as per this example, those three files will all be rendered as three individual python files and those messages will be under three different modules:
efrit/common/game.proto
-> efrit.common.game_dc.py
efrit/common/text.proto
-> efrit.common.text_dc.py
efrit/common/catalog.proto
-> efrit.common.catalog_dc.py
However in proto, all the messages in there are in the same package/namespace in efrit.common
while in python, going from efrit.common import *
imports nothing.
Since proto doesn't allow any name collisions within package definitions, we can assume that everything defined in the same package can also live in the same namespace/module in Python and from that, in the __init__.py
of each package module, "alias-import"every message that belongs to that package.
E.g. for the example above:
File: efrit/common/__init__.py
# Proto package alias importing
from efrit.common.game_dc import *
from efrit.common.text_dc import *
from efrit.common.catalog_dc import *
```
Thus, when using the neobuf package you can import stuff based on the proto packages definitions:
```python
from efrit.common import *
```