title: How do you define/organize proto files for a project with multiple python packages?
body: <p>How do I define and organize gRPC proto files for a project with two (or more) python packages?</p>
  
  <p>Suppose I have the following monorepo structure:</p>
  
  <pre><code>my_project/  
   |
   |-my_client_pkg/
   |  |_Dockerfile
   |  |_setup.py
   |  |_my_client/
   |     |___init__.py
   |     |_client.py
   |
    -my_server_pkg/
      |_Dockerfile
      |_setup.py
      |_my_server/
         |___init__.py
         |_server.py
  </code></pre>
  
  <p>I want to use gRPC to connect these two services together. I can add a <code>protos/</code> directory, with the appropriate child directories like so:</p>
  
  <pre><code>my_project/  
   |
   |-protos/
   |  |_my_client_pkg/
   |  |  |_my_client.proto
   |  |
   |  |_my_server_pkg/
   |     |_my_server.proto
   |
   |-my_client_pkg/
   |  |_Dockerfile
   |  |_setup.py
   |  |_my_client/
   |     |___init__.py
   |     |_client.py
   |
    -my_server_pkg/
      |_Dockerfile
      |_setup.py
      |_my_server/
         |___init__.py
         |_server.py
  </code></pre>
  
  <p>and this works: I can generate the .py files correctly, with the correct import statements. The problem with this approach is that I must duplicate everything from <code>my_client.proto</code> into <code>my_server.proto</code>. If I need to make a change, it must be in both files, something is obviously error prone. It really seems to defeat the purpose of protobufs.</p>
  
  <p>How should I be organizing my proto files? Is it possible to define the proto in one place, and then use the proto <code>import</code> statement to seamlessly duplicate the definitions? Should I be doing something completely different?</p>
  
  <p>Edit:
  Here is an example proto file:</p>
  
  <pre><code>syntax = "proto3";
  
  message AbcRequest {
    string utterance = 1;
  }
  
  message AbcResponse {
    string value = 2;
  }
  
  service Abc {
    rpc most_similar(AbcRequest) returns (AbcResponse) {}
  }
  </code></pre>
  
  <p>I did try defining the proto in a single place, and then importing it:</p>
  
  <pre><code>my_project/  
   |
   |-protos/
   |  |-base.proto
   |  |_my_client_pkg/
   |  |  |_my_client.proto
   |  |
   |  |_my_server_pkg/
   |     |_my_server.proto
  </code></pre>
  
  <p>Where my_client.proto and my_server.proto both just have:</p>
  
  <pre><code>syntax = "proto3";
  import "protos/base.proto";
  </code></pre>
  
  <p>However, when I generated the python code, the *_grpc.py file had nothing in it. Should I be doing something else for the importing to work like this?</p>