I asked this on GitHub but this seems to be the preferred place for asking 
for help? :) https://github.com/google/protobuf/issues/973

I'm trying to integrate protobufs with an existing codebase that's 
structured like


And I'm planning to add a `src/proto3` directory. It's a bit lost as to how 
to make this work for the Python code since "In Python, the package 
directive is ignored, since Python modules are organized according to their 
location in the file system."

So if I wanted to generate them in a folder like `/gen/proto3/python/`, 
where the `python` folder is placed on the `$PYTHON_PATH`, a thrift file 
placed at `src/proto3/demo/demo.proto` would be turned into 
`/gen/proto3/python/demo/demo_pb2.py` (assuming I set `-I src/proto3`). I 
would have to generate `__init__.py` manually, which is fine, but its 
module path is `demo.demo_pb2` rather than something like 
`gen.proto3.demo.demo_pb2`, so it'll easily run into module conflicts with 
stuff in `src/python`.

Of course I could move the protos to `src/proto3/gen/proto3` instead and 
it'll give the desired namespace, but that's kind of... weird?

It seems like the generated code are designed to be put in the same module 
that the code that references them will be in, which seems like it'd 
require building some non-trivial tooling around so it's not cluttering the 
source tree.

So to summarize, I think I'm probably missing something really simple, that 
there's a much better way to organize this? If not, might there be an 
option for `option python_package` to specify custom module paths for 
Python code as well?


You received this message because you are subscribed to the Google Groups 
"Protocol Buffers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to protobuf+unsubscr...@googlegroups.com.
To post to this group, send email to protobuf@googlegroups.com.
Visit this group at http://groups.google.com/group/protobuf.
For more options, visit https://groups.google.com/d/optout.

Reply via email to