title: Generating python client from a .proto with (well-known) timestamp
body: <p>When I take a simple <code>hello.proto</code> file</p>
  
  <pre><code>syntax = "proto3";
  package helloworld;
  //import "timestamp.proto";
  service Greeter {
    rpc SayHello (HelloRequest) returns (HelloReply) {}
  }
  message HelloRequest {
    string name = 1;
    //google.protobuf.Timestamp smth = 2;
  }
  message HelloReply {
    string message = 1;
  }
  </code></pre>
  
  <p>and (within <code>virtualenv -p python3 py</code>) generate python code with </p>
  
  <pre><code>python -m grpc_tools.protoc -I. --python_out=. --grpc_python_out=. ./hello.proto
  </code></pre>
  
  <p>I get two nice files: <code>hello_pb2.py</code> and <code>hello_pb2_grpc.py</code></p>
  
  <p>and a simple two-line playground.py:</p>
  
  <pre><code>import hello_pb2
  import hello_pb2_grpc
  </code></pre>
  
  <p>works fine with <code>python playground.py</code></p>
  
  <p><strong>Everything changes</strong> when try to use a well-known protobuf type, timestamp, and uncomment lines 3 and 9.</p>
  
  <hr>
  
  <p>The closest corresponding file, <code>timestamp.proto</code> I see in site-packages:</p>
  
  <pre><code>$ find -name timestamp\*
  ./lib/python3.5/site-packages/grpc_tools/_proto/google/protobuf/timestamp.proto
  ./lib/python3.5/site-packages/google/protobuf/timestamp_pb2.py
  ./lib/python3.5/site-packages/google/protobuf/__pycache__/timestamp_pb2.cpython-35.pyc
  </code></pre>
  
  <p>so I use a bit different code generation command:</p>
  
  <pre><code>python -m grpc_tools.protoc -I. \
         -I./lib/python3.5/site-packages/grpc_tools/_proto/google/protobuf \
         --python_out=. --grpc_python_out=. ./hello.proto
  </code></pre>
  
  <p>but <code>python playground.py</code> now results in an error:</p>
  
  <pre><code>Traceback (most recent call last):
    File "playground.py", line 1, in &lt;module&gt;
      import hello_pb2
    File "/py/hello_pb2.py", line 16, in &lt;module&gt;
      import timestamp_pb2 as timestamp__pb2
  ImportError: No module named 'timestamp_pb2
  </code></pre>
  
  <p>that's because <code>hello_pb2.py</code> now has a line:</p>
  
  <pre><code>import timestamp_pb2 as timestamp__pb2
  </code></pre>
  
  <p>I tried a bit different playground.py:</p>
  
  <pre><code>import sys
  sys.path.append('./lib/python3.5/site-packages/google/protobuf')
  import hello_pb2
  import hello_pb2_grpc
  </code></pre>
  
  <p>but that leads to a different error:</p>
  
  <pre><code>$ python playground.py 
  Traceback (most recent call last):
    File "playground.py", line 3, in &lt;module&gt;
      import hello_pb2
    File "/py/hello_pb2.py", line 25, in &lt;module&gt;
      dependencies=[timestamp__pb2.DESCRIPTOR,])
    File "/py/lib/python3.5/site-packages/google/protobuf/descriptor.py", line 829, in __new__
      return _message.default_pool.AddSerializedFile(serialized_pb)
  TypeError: Couldn't build proto file into descriptor pool!
  Invalid proto descriptor for file "hello.proto":
    hello.proto: Import "timestamp.proto" has not been loaded.
    helloworld.HelloRequest.smth: "google.protobuf.Timestamp" seems to be defined in "google/protobuf/timestamp.proto", which is not imported by "hello.proto".  To use it here, please add the necessary import.
  </code></pre>
  
  <p>So, I'm out of ideas. How do I use this well-known type with python (3)?</p>
  
  <hr>
  
  <p>Details: ubuntu:xenial, python 3.5.2, virtualenv 15.2.0,
  env: <code>virtualenv -p python3 py &amp;&amp; cd py &amp;&amp; source bin/activate &amp;&amp; pip install grpcio grpcio_tools</code> (this installs protobuf-3.5.2, grpcio-1.10.0, grpcio_tools-1.10.0) </p>