Re: [protobuf] Putting compiled protobufs into a python package

2016-03-03 Thread 'Adrian Wan' via Protocol Buffers
I believe I ran into this issue as well - 
https://github.com/google/protobuf/issues/881? 

On Monday, March 29, 2010 at 11:59:01 AM UTC-7, Kenton Varda wrote:
>
> Yeah, there's really no way to accomplish this without editing the .proto 
> files you are importing.  This is an issue in regular old Python as well 
> (or many other languages):  you can't really fix someone else's poor 
> package layout without editing their code.  I guess it's a bigger problem 
> in protobufs because people working in C++ may make decisions that aren't 
> so bad for C++ but are poor for Python.
>
> Instead of actually maintaining forks, you could write a sed script which 
> automatically fixes up the other project's .proto files and have your build 
> system automatically run this script.
>
> On Mon, Mar 29, 2010 at 10:00 AM, John Admanski  > wrote:
>
>> I have a situation where I want to make use of protocol buffers defined 
>> in a separate source tree; but when I compile the protobufs into python 
>> code all the compiled code assumes it's going to be exposed by putting it 
>> onto sys.path somehow (via one of the usual mechanisms). The problem is 
>> that due to the way the protobufs are defined in the original source tree 
>> this adds a bunch of new top-level packages and generally pollutes the 
>> global module namespace.
>>
>> So I wanted to work around this by putting all the compiled protobufs 
>> into a package, but this doesn't work with protoc; it assumes that if a 
>> protobuf references X/Y/Z.proto, then there's going to be an X.Y.Z_pb2 
>> module it can import. I can fix this by editing all the proto files to 
>> change all the references to be relative to this new package I'm defining 
>> but that basically means I have to fork the proto files from this other 
>> project.
>>
>> Is there any better mechanism when compiling protobufs that would allow 
>> me to put the compiled output into a package, rather than having to hang 
>> them off of sys.path or tweak all the proto files?
>>
>> -- John
>>
>> -- 
>> You received this message because you are subscribed to the Google Groups 
>> "Protocol Buffers" group.
>> To post to this group, send email to prot...@googlegroups.com 
>> .
>> To unsubscribe from this group, send email to 
>> protobuf+u...@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 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 https://groups.google.com/group/protobuf.
For more options, visit https://groups.google.com/d/optout.


Re: [protobuf] Putting compiled protobufs into a python package

2016-03-03 Thread 'John Admanski' via Protocol Buffers
This has been far enough in the past that I can't actually remember what I
was doing that ran into this issue...

On Thu, Mar 3, 2016 at 11:36 AM, Adrian Wan  wrote:

> I believe I ran into this issue as well -
> https://github.com/google/protobuf/issues/881?
>
> On Monday, March 29, 2010 at 11:59:01 AM UTC-7, Kenton Varda wrote:
>>
>> Yeah, there's really no way to accomplish this without editing the .proto
>> files you are importing.  This is an issue in regular old Python as well
>> (or many other languages):  you can't really fix someone else's poor
>> package layout without editing their code.  I guess it's a bigger problem
>> in protobufs because people working in C++ may make decisions that aren't
>> so bad for C++ but are poor for Python.
>>
>> Instead of actually maintaining forks, you could write a sed script which
>> automatically fixes up the other project's .proto files and have your build
>> system automatically run this script.
>>
>> On Mon, Mar 29, 2010 at 10:00 AM, John Admanski 
>> wrote:
>>
>>> I have a situation where I want to make use of protocol buffers defined
>>> in a separate source tree; but when I compile the protobufs into python
>>> code all the compiled code assumes it's going to be exposed by putting it
>>> onto sys.path somehow (via one of the usual mechanisms). The problem is
>>> that due to the way the protobufs are defined in the original source tree
>>> this adds a bunch of new top-level packages and generally pollutes the
>>> global module namespace.
>>>
>>> So I wanted to work around this by putting all the compiled protobufs
>>> into a package, but this doesn't work with protoc; it assumes that if a
>>> protobuf references X/Y/Z.proto, then there's going to be an X.Y.Z_pb2
>>> module it can import. I can fix this by editing all the proto files to
>>> change all the references to be relative to this new package I'm defining
>>> but that basically means I have to fork the proto files from this other
>>> project.
>>>
>>> Is there any better mechanism when compiling protobufs that would allow
>>> me to put the compiled output into a package, rather than having to hang
>>> them off of sys.path or tweak all the proto files?
>>>
>>> -- John
>>>
>>> --
>>> You received this message because you are subscribed to the Google
>>> Groups "Protocol Buffers" group.
>>> To post to this group, send email to prot...@googlegroups.com.
>>> To unsubscribe from this group, send email to
>>> protobuf+u...@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 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 https://groups.google.com/group/protobuf.
For more options, visit https://groups.google.com/d/optout.


Re: [protobuf] Putting compiled protobufs into a python package

2010-03-29 Thread Kenton Varda
Yeah, there's really no way to accomplish this without editing the .proto
files you are importing.  This is an issue in regular old Python as well (or
many other languages):  you can't really fix someone else's poor package
layout without editing their code.  I guess it's a bigger problem in
protobufs because people working in C++ may make decisions that aren't so
bad for C++ but are poor for Python.

Instead of actually maintaining forks, you could write a sed script which
automatically fixes up the other project's .proto files and have your build
system automatically run this script.

On Mon, Mar 29, 2010 at 10:00 AM, John Admanski jadman...@google.comwrote:

 I have a situation where I want to make use of protocol buffers defined in
 a separate source tree; but when I compile the protobufs into python code
 all the compiled code assumes it's going to be exposed by putting it onto
 sys.path somehow (via one of the usual mechanisms). The problem is that due
 to the way the protobufs are defined in the original source tree this adds a
 bunch of new top-level packages and generally pollutes the global module
 namespace.

 So I wanted to work around this by putting all the compiled protobufs into
 a package, but this doesn't work with protoc; it assumes that if a protobuf
 references X/Y/Z.proto, then there's going to be an X.Y.Z_pb2 module it can
 import. I can fix this by editing all the proto files to change all the
 references to be relative to this new package I'm defining but that
 basically means I have to fork the proto files from this other project.

 Is there any better mechanism when compiling protobufs that would allow me
 to put the compiled output into a package, rather than having to hang them
 off of sys.path or tweak all the proto files?

 -- John

 --
 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.comprotobuf%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.