title: python3 grpc compiler: how to handle absolute and relative imports in .protos?
body: <p>I'm trying to generate working Python modules from the containerd API .proto files as to be found here: <a href="https://github.com/containerd/containerd/tree/master/api" rel="nofollow noreferrer">https://github.com/containerd/containerd/tree/master/api</a>.</p>
  <p>Unfortunately, containerd's own .proto files contain references such as (in <code>api/events/container.proto</code>):</p>
  <pre class="lang-proto prettyprint-override"><code>import weak &quot;github.com/containerd/containerd/protobuf/plugin/fieldpath.proto&quot;;
  </code></pre>
  <p>Now, this import is actually located in <code>protobuf/plugin/fieldpath.proto</code>, as opposed to (<code>vendor/</code>)<code>github.com/containerd/...</code>. A simple <code>-I ...</code> does not work in this context, as the import uses a &quot;github&quot;-absolute path, whereas the corresponding sources aren't located inside the vendor branch.</p>
  <p>Simply copying over the sources inside <code>vendor/github.com/...</code> will cause runtime errors when trying to use the generated Python modules: this is because there are now two separate instances for the same protocol elements trying to register with GRPC with the same protocol element name, yet from two different Python modules. The GRPC Python runtime thus throws an error and terminates.</p>
  <p>How can I correctly get this resolved when using <code>python3 -m grpc.tools.protoc ...</code>?</p>