Right, --proto_path should always point at the "root" of your source tree,
and all imports should be fully-qualified.

Probably the documentation for "import" in the language guide should include
a bit more text on this, as it comes up a lot.  If you file a bug I'll
update it when I get time.

Thanks for offering to help, BTW.  Unfortunately our documentation is not in
a repository that can easily be edited from the outside.  This was a mistake
I made when setting up the project, but oh well...

On Tue, Oct 26, 2010 at 1:10 PM, Sancho <sanc...@gmail.com> wrote:

> Nevermind! I fixed it...
>
> The solution was to use import "sift/sift_descriptors.proto" in
> filtered_descriptors.proto, and then point protoc to --proto_path=../
> instead of --proto_path=../sift.
> Then, protoc generates python code that does the import as import
> sift.sift_descriptors_pb2.
>
> This isn't explained well in the documentation. How can I help write
> something?
>
> On Oct 26, 1:03 pm, Sancho <sanc...@gmail.com> wrote:
> > Sorry, transcription error... I meant "import sift_descriptors_pb2"
> > where I wrote "import sift_descriptors_pb2.py" both times.
> >
> > On Oct 26, 12:58 pm, Sancho <sanc...@gmail.com> wrote:
> >
> >
> >
> > > I have my directory structure like this:
> >
> > > root/
> > >   sift/
> > >     __init__.py
> > >     sift_descriptors.proto
> > >     sift_descriptors_pb2.py
> > >   project/
> > >     __init__.py
> > >     filtered_descriptors.proto
> > >     filtered_descriptors_pb2.py
> > >     filtered_descriptors_test.py
> > > The root directory is in my $PYTHONPATH.
> >
> > > I build root/sift/sift_descriptors_pb2.py using protoc --python_out=./
> > > sift_descriptors.proto
> >
> > > I build root/project/filtered_descriptors_pb2.py using /cs/public/lib/
> > > pkg/protobuf/bin/protoc --proto_path=../sift --proto_path=./ --
> > > python_out=./ filtered_descriptors.proto
> >
> > > In filtered_descriptors.proto, I use import "sift_descriptors.proto"
> >
> > > The problem is that in filtered_descriptors_pb2.py, there's a
> > > statement that just does this bare import: import
> > > sift_descriptors_pb2.py, without reference via the module name as
> > > would be needed: from sift import sift_descriptors_pb2.py.
> >
> > > What am I doing wrong?
>
> --
> You received this message because you are subscribed to the Google Groups
> "Protocol Buffers" group.
> To post to this group, send email to proto...@googlegroups.com.
> To unsubscribe from this group, send email to
> protobuf+unsubscr...@googlegroups.com<protobuf%2bunsubscr...@googlegroups.com>
> .
> For more options, visit this group at
> http://groups.google.com/group/protobuf?hl=en.
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Protocol Buffers" group.
To post to this group, send email to proto...@googlegroups.com.
To unsubscribe from this group, send email to 
protobuf+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/protobuf?hl=en.

Reply via email to