The containerd project <https://github.com/containerd/containerd> doesn't 
publish a Python package for its containerd gRPC-based API, so I want to 
generate Python modules for it myself. For API version 1.3 of containerd, 
the .proto files can be found in 
https://github.com/containerd/containerd/tree/release/1.3/api. 
Unfortunately, I'm hitting two road blocks when trying to generate Python 
modules from the API .proto files and when to run them.

For example, the some of the containerd API .proto files reference protobuf 
plugin .proto files using an (for lack of a better term on my side) 
absolute import path: api/events/container.proto 
<https://github.com/containerd/containerd/blob/release/1.3/api/events/container.proto>
 does 
an:

import weak 
"github.com/containerd/containerd/protobuf/plugin/fieldpath.proto";

However, the Python grpc compiler always wants to resolve such references 
in the local file system and containerd's source have 
./protobuf/plugin/fieldpath.proto 
<https://github.com/containerd/containerd/blob/release/1.3/protobuf/plugin/fieldpath.proto>
 -- 
so this won't ever resolve correctly (using -I ...), because it lacks the 
github.lcom/containerd/containerd path elements. Please note that the 
Python grpc protocol compiler resolves such import paths in form of 
chopping down the full import path into parts and then searching its -I 
... include directories.

Trying the lazy route by simply copying over these sources into 
inside vendor/github.com/... inside the containerd source tree will later 
cause *runtime errors *when trying to use the generated Python modules: 
this is because the grpc compiler considers the same containerd API .proto 
file in two locations (paths) to be separate instances. In consequence we 
get duplicate modules which unfortunately now try to register with grpc for 
the same protocol element names. Consequently, the gRPC Python runtime thus 
throws an error and terminates.

How can I correctly get this resolved when using python3 -m 
grpc.tools.protoc ...? What am I missing here or getting wrong?

-- 
You received this message because you are subscribed to the Google Groups 
"grpc.io" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/grpc-io/472d1213-01c3-44d6-a3ac-356ece76e3fdn%40googlegroups.com.

Reply via email to