Using built messages inside package scope
I'm using your setuptools extension to distribute a package. However, I'd like to import the built message classes inside the project itself. This would be a fairly common use case (let's say the package has a web server that needs to serialize these protobuf messages) as compared to a user wanting to use it outside the scope of the project module.
So instead of this directory structure:
sample/
proto/
my_message.proto
sample/
__init__.py
setup.py
We have this:
sample/
sample/
__init__.py
proto/
__init__.py
my_message.proto
server.py
setup.py
where:
# file server.py
from .proto.my_message import MyMessage
For that matter, if someone wants to use my message classes, it seems cleaner to distribute it as a submodule since it belongs under the scope of the project anyway:
from sample.proto.my_message import MyMessage
Is there a reason not to install the package like this by default?
Being able to specify the package namespace would be pretty slick. When I get a chance I will look into how we could do this, unless you want to take a stab at it and put up a PR 😬
@rkrn sorry it took me so long to get around to this. I have a PR up for a solution: https://github.com/appnexus/pyrobuf/pull/114
It's not quite what you asked for, which I agree would be the cleanest, but I think it's at least an improvement. Basically, in the above example, all your message classes will be under the package sample_proto. See the diff in the README for what changed.