Merge pull request #5165 from ctiller/bring_back_gpr

Bring back gpr
diff --git a/PYTHON-MANIFEST.in b/PYTHON-MANIFEST.in
index 2f5700d..3c46d61 100644
--- a/PYTHON-MANIFEST.in
+++ b/PYTHON-MANIFEST.in
@@ -5,6 +5,7 @@
 graft third_party/boringssl
 graft third_party/zlib
 include src/python/grpcio/commands.py
+include src/python/grpcio/grpc_version.py
 include src/python/grpcio/grpc_core_dependencies.py
 include src/python/grpcio/support.py
 include src/python/grpcio/README.rst
diff --git a/examples/protos/helloworld.proto b/examples/protos/helloworld.proto
index 7d58870..e670503 100644
--- a/examples/protos/helloworld.proto
+++ b/examples/protos/helloworld.proto
@@ -1,4 +1,4 @@
-// Copyright 2015, Google Inc.
+// Copyright 2015-2016, Google Inc.
 // All rights reserved.
 //
 // Redistribution and use in source and binary forms, with or without
@@ -29,7 +29,9 @@
 
 syntax = "proto3";
 
-option java_package = "io.grpc.examples";
+option java_multiple_files = true;
+option java_package = "io.grpc.examples.helloworld";
+option java_outer_classname = "HelloWorldProto";
 option objc_class_prefix = "HLW";
 
 package helloworld;
diff --git a/examples/protos/route_guide.proto b/examples/protos/route_guide.proto
index 7a70040..b3553ee 100644
--- a/examples/protos/route_guide.proto
+++ b/examples/protos/route_guide.proto
@@ -1,4 +1,4 @@
-// Copyright 2015, Google Inc.
+// Copyright 2015-2016, Google Inc.
 // All rights reserved.
 //
 // Redistribution and use in source and binary forms, with or without
@@ -29,7 +29,9 @@
 
 syntax = "proto3";
 
-option java_package = "ex.grpc";
+option java_multiple_files = true;
+option java_package = "io.grpc.examples.routeguide";
+option java_outer_classname = "RouteGuideProto";
 option objc_class_prefix = "RTG";
 
 package routeguide;
diff --git a/grpc.gemspec b/grpc.gemspec
index ddc27ed..9e4683f 100755
--- a/grpc.gemspec
+++ b/grpc.gemspec
@@ -31,7 +31,7 @@
   s.require_paths = %w( src/ruby/bin src/ruby/lib src/ruby/pb )
   s.platform      = Gem::Platform::RUBY
 
-  s.add_dependency 'google-protobuf', '~> 3.0.0alpha.1.1'
+  s.add_dependency 'google-protobuf', '~> 3.0.0.alpha.5.0.2'
   s.add_dependency 'googleauth',      '~> 0.5.1'
 
   s.add_development_dependency 'bundler',            '~> 1.9'
@@ -39,7 +39,7 @@
   s.add_development_dependency 'simplecov',          '~> 0.9'
   s.add_development_dependency 'rake',               '~> 10.4'
   s.add_development_dependency 'rake-compiler',      '~> 0.9'
-  s.add_development_dependency 'rake-compiler-dock', '~> 0.5'
+  s.add_development_dependency 'rake-compiler-dock', '~> 0.5.1'
   s.add_development_dependency 'rspec',              '~> 3.2'
   s.add_development_dependency 'rubocop',            '~> 0.30.0'
   s.add_development_dependency 'signet',             '~> 0.7.0'
diff --git a/include/grpc++/impl/codegen/rpc_service_method.h b/include/grpc++/impl/codegen/rpc_service_method.h
index 519d942..6256301 100644
--- a/include/grpc++/impl/codegen/rpc_service_method.h
+++ b/include/grpc++/impl/codegen/rpc_service_method.h
@@ -40,6 +40,7 @@
 #include <memory>
 #include <vector>
 
+#include <grpc/impl/codegen/byte_buffer.h>
 #include <grpc++/impl/codegen/config.h>
 #include <grpc++/impl/codegen/rpc_method.h>
 #include <grpc++/impl/codegen/status.h>
diff --git a/include/grpc++/impl/codegen/server_interface.h b/include/grpc++/impl/codegen/server_interface.h
index 96934ed..5c187c9 100644
--- a/include/grpc++/impl/codegen/server_interface.h
+++ b/include/grpc++/impl/codegen/server_interface.h
@@ -34,6 +34,7 @@
 #ifndef GRPCXX_IMPL_CODEGEN_SERVER_INTERFACE_H
 #define GRPCXX_IMPL_CODEGEN_SERVER_INTERFACE_H
 
+#include <grpc/impl/codegen/grpc_types.h>
 #include <grpc++/impl/codegen/call_hook.h>
 #include <grpc++/impl/codegen/completion_queue_tag.h>
 #include <grpc++/impl/codegen/rpc_service_method.h>
diff --git a/requirements.txt b/requirements.txt
index 9d00274..a1cc88c 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -3,3 +3,4 @@
 futures>=2.2.0
 cython>=0.23
 coverage>=4.0
+six>=1.10
diff --git a/setup.py b/setup.py
index f8450a7..ceca6f6 100644
--- a/setup.py
+++ b/setup.py
@@ -168,7 +168,7 @@
 }
 
 # Ensure that package data is copied over before any commands have been run:
-credentials_dir = os.path.join(PYTHON_STEM, 'grpc/_adapter/credentials')
+credentials_dir = os.path.join(PYTHON_STEM, 'grpc/_cython/_credentials')
 try:
   os.mkdir(credentials_dir)
 except OSError:
@@ -202,10 +202,8 @@
 TEST_RUNNER = 'tests:Runner'
 
 PACKAGE_DATA = {
-    'grpc._adapter': [
-        'credentials/roots.pem'
-    ],
     'grpc._cython': [
+        '_credentials/roots.pem',
         '_windows/grpc_c.32.python',
         '_windows/grpc_c.64.python',
     ],
diff --git a/src/core/iomgr/pollset_windows.c b/src/core/iomgr/pollset_windows.c
index 2e650ca..02c6678 100644
--- a/src/core/iomgr/pollset_windows.c
+++ b/src/core/iomgr/pollset_windows.c
@@ -212,10 +212,8 @@
         grpc_iocp_kick();
       }
     } else {
-      if (p->is_iocp_worker) {
-        if (g_active_poller == specific_worker) {
-          grpc_iocp_kick();
-        }
+      if (p->is_iocp_worker && g_active_poller == specific_worker) {
+        grpc_iocp_kick();
       } else {
         specific_worker->kicked = 1;
         gpr_cv_signal(&specific_worker->cv);
diff --git a/src/core/transport/static_metadata.c b/src/core/transport/static_metadata.c
index 233e5c0..eeedae0 100644
--- a/src/core/transport/static_metadata.c
+++ b/src/core/transport/static_metadata.c
@@ -35,11 +35,11 @@
  * WARNING: Auto-generated code.
  *
  * To make changes to this file, change
- *tools/codegen/core/gen_static_metadata.py,
+ * tools/codegen/core/gen_static_metadata.py,
  * and then re-run it.
  *
  * See metadata.h for an explanation of the interface here, and metadata.c for
- *an
+ * an
  * explanation of what's going on.
  */
 
@@ -69,21 +69,21 @@
     "0", "1", "2", "200", "204", "206", "304", "400", "404", "500", "accept",
     "accept-charset", "accept-encoding", "accept-language", "accept-ranges",
     "access-control-allow-origin", "age", "allow", "application/grpc",
-    ":authority", "authorization", "cache-control", "census", "census-bin",
-    "content-disposition", "content-encoding", "content-language",
-    "content-length", "content-location", "content-range", "content-type",
-    "cookie", "date", "deflate", "deflate,gzip", "", "etag", "expect",
-    "expires", "from", "GET", "grpc", "grpc-accept-encoding", "grpc-encoding",
-    "grpc-internal-encoding-request", "grpc-message", "grpc-status",
-    "grpc-timeout", "gzip", "gzip, deflate", "host", "http", "https",
-    "identity", "identity,deflate", "identity,deflate,gzip", "identity,gzip",
-    "if-match", "if-modified-since", "if-none-match", "if-range",
-    "if-unmodified-since", "last-modified", "link", "location", "max-forwards",
-    ":method", ":path", "POST", "proxy-authenticate", "proxy-authorization",
-    "range", "referer", "refresh", "retry-after", ":scheme", "server",
-    "set-cookie", "/", "/index.html", ":status", "strict-transport-security",
-    "te", "trailers", "transfer-encoding", "user-agent", "vary", "via",
-    "www-authenticate"};
+    ":authority", "authorization", "cache-control", "census-bin",
+    "census-binary-bin", "content-disposition", "content-encoding",
+    "content-language", "content-length", "content-location", "content-range",
+    "content-type", "cookie", "date", "deflate", "deflate,gzip", "", "etag",
+    "expect", "expires", "from", "GET", "grpc", "grpc-accept-encoding",
+    "grpc-encoding", "grpc-internal-encoding-request", "grpc-message",
+    "grpc-status", "grpc-timeout", "gzip", "gzip, deflate", "host", "http",
+    "https", "identity", "identity,deflate", "identity,deflate,gzip",
+    "identity,gzip", "if-match", "if-modified-since", "if-none-match",
+    "if-range", "if-unmodified-since", "last-modified", "link", "location",
+    "max-forwards", ":method", ":path", "POST", "proxy-authenticate",
+    "proxy-authorization", "range", "referer", "refresh", "retry-after",
+    ":scheme", "server", "set-cookie", "/", "/index.html", ":status",
+    "strict-transport-security", "te", "trailers", "transfer-encoding",
+    "user-agent", "vary", "via", "www-authenticate"};
 
 const uint8_t grpc_static_accept_encoding_metadata[8] = {0,  29, 26, 30,
                                                          28, 32, 27, 31};
diff --git a/src/core/transport/static_metadata.h b/src/core/transport/static_metadata.h
index 3803a04..ef72b80 100644
--- a/src/core/transport/static_metadata.h
+++ b/src/core/transport/static_metadata.h
@@ -94,10 +94,10 @@
 #define GRPC_MDSTR_AUTHORIZATION (&grpc_static_mdstr_table[20])
 /* "cache-control" */
 #define GRPC_MDSTR_CACHE_CONTROL (&grpc_static_mdstr_table[21])
-/* "census" */
-#define GRPC_MDSTR_CENSUS (&grpc_static_mdstr_table[22])
 /* "census-bin" */
-#define GRPC_MDSTR_CENSUS_BIN (&grpc_static_mdstr_table[23])
+#define GRPC_MDSTR_CENSUS_BIN (&grpc_static_mdstr_table[22])
+/* "census-binary-bin" */
+#define GRPC_MDSTR_CENSUS_BINARY_BIN (&grpc_static_mdstr_table[23])
 /* "content-disposition" */
 #define GRPC_MDSTR_CONTENT_DISPOSITION (&grpc_static_mdstr_table[24])
 /* "content-encoding" */
diff --git a/src/csharp/Grpc.Core.Tests/GrpcEnvironmentTest.cs b/src/csharp/Grpc.Core.Tests/GrpcEnvironmentTest.cs
index ab12c12..fac93fc 100644
--- a/src/csharp/Grpc.Core.Tests/GrpcEnvironmentTest.cs
+++ b/src/csharp/Grpc.Core.Tests/GrpcEnvironmentTest.cs
@@ -1,6 +1,6 @@
 #region Copyright notice and license
 
-// Copyright 2015, Google Inc.
+// Copyright 2015-2016, Google Inc.
 // All rights reserved.
 //
 // Redistribution and use in source and binary forms, with or without
diff --git a/src/csharp/Grpc.Core/Profiling/Profilers.cs b/src/csharp/Grpc.Core/Profiling/Profilers.cs
index 471ee20..8a18144 100644
--- a/src/csharp/Grpc.Core/Profiling/Profilers.cs
+++ b/src/csharp/Grpc.Core/Profiling/Profilers.cs
@@ -1,6 +1,6 @@
 #region Copyright notice and license
 
-// Copyright 2015, Google Inc.
+// Copyright 2015-2016, Google Inc.
 // All rights reserved.
 //
 // Redistribution and use in source and binary forms, with or without
@@ -111,7 +111,7 @@
 
         public void Dump(string filepath)
         {
-            using (var stream = new StreamWriter(filepath))
+            using (var stream = File.CreateText(filepath))
             {
                 Dump(stream);
             }
diff --git a/src/csharp/Grpc.Core/Version.cs b/src/csharp/Grpc.Core/Version.cs
index 8a26bd8..6d88438 100644
--- a/src/csharp/Grpc.Core/Version.cs
+++ b/src/csharp/Grpc.Core/Version.cs
@@ -1,6 +1,6 @@
 #region Copyright notice and license
 
-// Copyright 2015, Google Inc.
+// Copyright 2015-2016, Google Inc.
 // All rights reserved.
 //
 // Redistribution and use in source and binary forms, with or without
diff --git a/src/node/ext/byte_buffer.cc b/src/node/ext/byte_buffer.cc
index ee703fd..0f7edad 100644
--- a/src/node/ext/byte_buffer.cc
+++ b/src/node/ext/byte_buffer.cc
@@ -63,6 +63,10 @@
   return byte_buffer;
 }
 
+namespace {
+void delete_buffer(char *data, void *hint) { delete[] data; }
+}
+
 Local<Value> ByteBufferToBuffer(grpc_byte_buffer *buffer) {
   Nan::EscapableHandleScope scope;
   if (buffer == NULL) {
@@ -80,7 +84,7 @@
     gpr_slice_unref(next);
   }
   return scope.Escape(MakeFastBuffer(
-      Nan::NewBuffer(result, length).ToLocalChecked()));
+      Nan::NewBuffer(result, length, delete_buffer, NULL).ToLocalChecked()));
 }
 
 Local<Value> MakeFastBuffer(Local<Value> slowBuffer) {
diff --git a/src/python/grpcio/.gitignore b/src/python/grpcio/.gitignore
index 1d804e1..6e5e650 100644
--- a/src/python/grpcio/.gitignore
+++ b/src/python/grpcio/.gitignore
@@ -14,4 +14,4 @@
 doc/
 _grpcio_metadata.py
 htmlcov/
-grpc/_adapter/credentials
+grpc/_cython/_credentials
diff --git a/src/python/grpcio/grpc/_adapter/_low.py b/src/python/grpcio/grpc/_adapter/_low.py
index a850c57..62fd52a 100644
--- a/src/python/grpcio/grpc/_adapter/_low.py
+++ b/src/python/grpcio/grpc/_adapter/_low.py
@@ -27,7 +27,6 @@
 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 
-import pkg_resources
 import threading
 
 from grpc import _grpcio_metadata
@@ -35,7 +34,6 @@
 from grpc._adapter import _implementations
 from grpc._adapter import _types
 
-_ROOT_CERTIFICATES_RESOURCE_PATH = 'credentials/roots.pem'
 _USER_AGENT = 'Python-gRPC-{}'.format(_grpcio_metadata.__version__)
 
 ChannelCredentials = cygrpc.ChannelCredentials
@@ -56,9 +54,6 @@
   pair = None
   if private_key is not None or certificate_chain is not None:
     pair = cygrpc.SslPemKeyCertPair(private_key, certificate_chain)
-  if root_certificates is None:
-    root_certificates = pkg_resources.resource_string(
-      __name__, _ROOT_CERTIFICATES_RESOURCE_PATH)
   return cygrpc.channel_credentials_ssl(root_certificates, pair)
 
 
diff --git a/src/python/grpcio/grpc/_cython/_cygrpc/grpc.pxi b/src/python/grpcio/grpc/_cython/_cygrpc/grpc.pxi
index 9c85e0e..bbeed9a 100644
--- a/src/python/grpcio/grpc/_cython/_cygrpc/grpc.pxi
+++ b/src/python/grpcio/grpc/_cython/_cygrpc/grpc.pxi
@@ -100,6 +100,11 @@
     GRPC_STATUS_DATA_LOSS
     GRPC_STATUS__DO_NOT_USE
 
+  ctypedef enum grpc_ssl_roots_override_result:
+    GRPC_SSL_ROOTS_OVERRIDE_OK
+    GRPC_SSL_ROOTS_OVERRIDE_FAILED_PERMANENTLY
+    GRPC_SSL_ROOTS_OVERRIDE_FAILED
+
   struct grpc_byte_buffer_reader:
     # We don't care about the internals
     pass
@@ -338,6 +343,10 @@
     # We don't care about the internals (and in fact don't know them)
     pass
 
+  ctypedef void (*grpc_ssl_roots_override_callback)(char **pem_root_certs)
+
+  void grpc_set_ssl_roots_override_callback(grpc_ssl_roots_override_callback cb)
+
   grpc_channel_credentials *grpc_google_default_credentials_create()
   grpc_channel_credentials *grpc_ssl_credentials_create(
       const char *pem_root_certs, grpc_ssl_pem_key_cert_pair *pem_key_cert_pair,
diff --git a/src/python/grpcio/grpc/_cython/_cygrpc/security.pxd.pxi b/src/python/grpcio/grpc/_cython/_cygrpc/security.pxd.pxi
new file mode 100644
index 0000000..3a952ca
--- /dev/null
+++ b/src/python/grpcio/grpc/_cython/_cygrpc/security.pxd.pxi
@@ -0,0 +1,32 @@
+# Copyright 2016, Google Inc.
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions are
+# met:
+#
+#     * Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+#     * Redistributions in binary form must reproduce the above
+# copyright notice, this list of conditions and the following disclaimer
+# in the documentation and/or other materials provided with the
+# distribution.
+#     * Neither the name of Google Inc. nor the names of its
+# contributors may be used to endorse or promote products derived from
+# this software without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+
+cdef grpc_ssl_roots_override_result ssl_roots_override_callback(
+    char **pem_root_certs) with gil
diff --git a/src/python/grpcio/grpc/_cython/_cygrpc/security.pyx.pxi b/src/python/grpcio/grpc/_cython/_cygrpc/security.pyx.pxi
new file mode 100644
index 0000000..23cee7b
--- /dev/null
+++ b/src/python/grpcio/grpc/_cython/_cygrpc/security.pyx.pxi
@@ -0,0 +1,44 @@
+# Copyright 2016, Google Inc.
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions are
+# met:
+#
+#     * Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+#     * Redistributions in binary form must reproduce the above
+# copyright notice, this list of conditions and the following disclaimer
+# in the documentation and/or other materials provided with the
+# distribution.
+#     * Neither the name of Google Inc. nor the names of its
+# contributors may be used to endorse or promote products derived from
+# this software without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+from libc.string cimport memcpy
+
+import pkg_resources
+
+
+cdef grpc_ssl_roots_override_result ssl_roots_override_callback(
+    char **pem_root_certs) with gil:
+  temporary_pem_root_certs = pkg_resources.resource_string(
+      'grpc._cython', '_credentials/roots.pem')
+  pem_root_certs[0] = <char *>gpr_malloc(len(temporary_pem_root_certs) + 1)
+  memcpy(
+      pem_root_certs[0], <char *>temporary_pem_root_certs,
+      len(temporary_pem_root_certs))
+  pem_root_certs[0][len(temporary_pem_root_certs)] = '\0'
+  return GRPC_SSL_ROOTS_OVERRIDE_OK
diff --git a/src/python/grpcio/grpc/_cython/cygrpc.pxd b/src/python/grpcio/grpc/_cython/cygrpc.pxd
index f22346c..61b0fa7 100644
--- a/src/python/grpcio/grpc/_cython/cygrpc.pxd
+++ b/src/python/grpcio/grpc/_cython/cygrpc.pxd
@@ -34,4 +34,5 @@
 include "grpc/_cython/_cygrpc/credentials.pxd.pxi"
 include "grpc/_cython/_cygrpc/completion_queue.pxd.pxi"
 include "grpc/_cython/_cygrpc/records.pxd.pxi"
+include "grpc/_cython/_cygrpc/security.pxd.pxi"
 include "grpc/_cython/_cygrpc/server.pxd.pxi"
diff --git a/src/python/grpcio/grpc/_cython/cygrpc.pyx b/src/python/grpcio/grpc/_cython/cygrpc.pyx
index b1836bf..30cc7a1 100644
--- a/src/python/grpcio/grpc/_cython/cygrpc.pyx
+++ b/src/python/grpcio/grpc/_cython/cygrpc.pyx
@@ -40,6 +40,7 @@
 include "grpc/_cython/_cygrpc/credentials.pyx.pxi"
 include "grpc/_cython/_cygrpc/completion_queue.pyx.pxi"
 include "grpc/_cython/_cygrpc/records.pyx.pxi"
+include "grpc/_cython/_cygrpc/security.pyx.pxi"
 include "grpc/_cython/_cygrpc/server.pyx.pxi"
 
 #
@@ -58,6 +59,8 @@
         raise ImportError('failed to load core gRPC library')
     grpc_init()
     self.is_loaded = True
+    grpc_set_ssl_roots_override_callback(
+        <grpc_ssl_roots_override_callback>ssl_roots_override_callback)
 
   def __dealloc__(self):
     if self.is_loaded:
diff --git a/src/python/grpcio/tests/unit/beta/_implementations_test.py b/src/python/grpcio/tests/unit/beta/_implementations_test.py
new file mode 100644
index 0000000..6b32305
--- /dev/null
+++ b/src/python/grpcio/tests/unit/beta/_implementations_test.py
@@ -0,0 +1,54 @@
+# Copyright 2016, Google Inc.
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions are
+# met:
+#
+#     * Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+#     * Redistributions in binary form must reproduce the above
+# copyright notice, this list of conditions and the following disclaimer
+# in the documentation and/or other materials provided with the
+# distribution.
+#     * Neither the name of Google Inc. nor the names of its
+# contributors may be used to endorse or promote products derived from
+# this software without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+"""Tests the implementations module of the gRPC Python Beta API."""
+
+import unittest
+
+from grpc.beta import implementations
+from tests.unit import resources
+
+
+class ChannelCredentialsTest(unittest.TestCase):
+
+  def test_runtime_provided_root_certificates(self):
+    channel_credentials = implementations.ssl_channel_credentials(
+        None, None, None)
+    self.assertIsInstance(
+        channel_credentials, implementations.ChannelCredentials)
+  
+  def test_application_provided_root_certificates(self):
+    channel_credentials = implementations.ssl_channel_credentials(
+        resources.test_root_certificates(), None, None)
+    self.assertIsInstance(
+        channel_credentials, implementations.ChannelCredentials)
+
+
+if __name__ == '__main__':
+  unittest.main(verbosity=2)
diff --git a/src/ruby/lib/grpc/version.rb b/src/ruby/lib/grpc/version.rb
index 9cbd36a..ef08761 100644
--- a/src/ruby/lib/grpc/version.rb
+++ b/src/ruby/lib/grpc/version.rb
@@ -29,5 +29,5 @@
 
 # GRPC contains the General RPC module.
 module GRPC
-  VERSION = '0.14.0-dev'
+  VERSION = '0.14.0.dev'
 end
diff --git a/templates/grpc.gemspec.template b/templates/grpc.gemspec.template
index c4987a6..6cc3e96 100644
--- a/templates/grpc.gemspec.template
+++ b/templates/grpc.gemspec.template
@@ -33,7 +33,7 @@
     s.require_paths = %w( src/ruby/bin src/ruby/lib src/ruby/pb )
     s.platform      = Gem::Platform::RUBY
 
-    s.add_dependency 'google-protobuf', '~> 3.0.0alpha.1.1'
+    s.add_dependency 'google-protobuf', '~> 3.0.0.alpha.5.0.2'
     s.add_dependency 'googleauth',      '~> 0.5.1'
 
     s.add_development_dependency 'bundler',            '~> 1.9'
@@ -41,7 +41,7 @@
     s.add_development_dependency 'simplecov',          '~> 0.9'
     s.add_development_dependency 'rake',               '~> 10.4'
     s.add_development_dependency 'rake-compiler',      '~> 0.9'
-    s.add_development_dependency 'rake-compiler-dock', '~> 0.5'
+    s.add_development_dependency 'rake-compiler-dock', '~> 0.5.1'
     s.add_development_dependency 'rspec',              '~> 3.2'
     s.add_development_dependency 'rubocop',            '~> 0.30.0'
     s.add_development_dependency 'signet',             '~> 0.7.0'
diff --git a/templates/src/ruby/lib/grpc/version.rb.template b/templates/src/ruby/lib/grpc/version.rb.template
index a47d2d8..6488614 100644
--- a/templates/src/ruby/lib/grpc/version.rb.template
+++ b/templates/src/ruby/lib/grpc/version.rb.template
@@ -31,5 +31,5 @@
 
   # GRPC contains the General RPC module.
   module GRPC
-    VERSION = '${settings.ruby_version}'
+    VERSION = '${settings.ruby_version.ruby()}'
   end
diff --git a/test/distrib/csharp/run_distrib_test.sh b/test/distrib/csharp/run_distrib_test.sh
index 8ddb4c4..1de6204 100755
--- a/test/distrib/csharp/run_distrib_test.sh
+++ b/test/distrib/csharp/run_distrib_test.sh
@@ -34,8 +34,9 @@
 
 unzip -o "$EXTERNAL_GIT_ROOT/input_artifacts/csharp_nugets.zip" -d TestNugetFeed
 
-# TODO(jtattermusch): replace the version number
-./update_version.sh 0.13.0
+# Extract the version number from Grpc nuget package name.
+CSHARP_VERSION=$(ls TestNugetFeed | grep '^Grpc\.[0-9].*\.nupkg$' | sed s/^Grpc\.// | sed s/\.nupkg$//)
+./update_version.sh $CSHARP_VERSION
 
 nuget restore
 
diff --git a/test/distrib/node/run_distrib_test.sh b/test/distrib/node/run_distrib_test.sh
index ac9e7d7..99a51f0 100755
--- a/test/distrib/node/run_distrib_test.sh
+++ b/test/distrib/node/run_distrib_test.sh
@@ -28,15 +28,12 @@
 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 
+NODE_VERSION=$1
+source ~/.nvm/nvm.sh
 set -ex
 
 cd $(dirname $0)
 
-NODE_VERSION="$1"
-
-# make sure nvm is available
-source ~/.nvm/nvm.sh || true
-
 nvm install $NODE_VERSION
 
 npm install -g node-static
diff --git a/test/distrib/python/run_distrib_test.sh b/test/distrib/python/run_distrib_test.sh
index 08856ad..8fd7ffb 100755
--- a/test/distrib/python/run_distrib_test.sh
+++ b/test/distrib/python/run_distrib_test.sh
@@ -32,11 +32,11 @@
 
 cd $(dirname $0)
 
-# TODO(jtattermusch): replace the version number
-SDIST_ARCHIVE="$EXTERNAL_GIT_ROOT/input_artifacts/grpcio-0.12.0b8.tar.gz"
+# Pick up the source dist archive whatever its version is
+SDIST_ARCHIVE=$EXTERNAL_GIT_ROOT/input_artifacts/grpcio-*.tar.gz
 BDIST_DIR="file://$EXTERNAL_GIT_ROOT/input_artifacts"
 
-if [ ! -f "${SDIST_ARCHIVE}" ]
+if [ ! -f ${SDIST_ARCHIVE} ]
 then
   echo "Archive ${SDIST_ARCHIVE} does not exist."
   exit 1
@@ -52,7 +52,7 @@
 
 GRPC_PYTHON_BINARIES_REPOSITORY="${BDIST_DIR}" \
     $PIP install \
-    "${SDIST_ARCHIVE}"
+    ${SDIST_ARCHIVE}
 
 $PYTHON distribtest.py
 
diff --git a/third_party/rake-compiler-dock/Dockerfile b/third_party/rake-compiler-dock/Dockerfile
index a8f5b8a..c7a6657 100644
--- a/third_party/rake-compiler-dock/Dockerfile
+++ b/third_party/rake-compiler-dock/Dockerfile
@@ -27,46 +27,75 @@
 
 # Regenerate the following using build.sh if the build folder changes.
 RUN echo \
-H4sIAByxrVYAA+1ae1PbSBLPv6dP0SeoxYAlWX7IkEAuBBziqgRSPJK7SnLasTSydJYl3cwIQwH7\
-2a9nJAMmIYTb4K3s6ldlaTSP7p5X93R7BnkU+9aTR0UD0e125Nvudhrq2+621LvEE7vpdFqtZrdp\
-Y75tt1qtJ9B5XLEK5FwQBvAki05p/I16fuqNKJuHRHPFQM0/j4bBxPQeiYecYMdp3zX/ttO8Pf9N\
-x+48gcYjyTODv/j8WysarMBRGHHIWDpkZAwhSfyYcjjs7/b3jgC/IEjZhDCfQyRApJiVipAy2cKj\
-nJuSRF8A0ogSQROf+rLWgALLEyAc3vV3wJa1ZMUdNZAgh13wKQlkN4lECHoxzLKhPtMS9hN4EyX5\
-aR2QNfg0IHksABduQuJSZCblLJoA5qcMqZLkrKxUiHmEclOsRmFbsNjYBjIi055K+VUzHzIkVvKQ\
-zSxNW4gSL859ChsFOTN8fjPvjFviLKP8y+wJiYTM1XBsIIt82ITGM007SSNfK+R2kaIsrMmHpJ6P\
-l7VzDSAKathgGVMAoyiO5Ve9lHb5mXZZ0ByTKFFNCRt6dfBCXM8rmD75+HlZUuGC5Z4iTDwRpQkk\
-dOIWyWeSiWQqiMg5SmbYKBqAtQKHVECeqcEuCOQ4Zj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uXF1isbpsSrYsjZNwrQ35H61k9h9DOPatvL+77/+026v3\
+/5qtxtr/e5CC9p9sP9rMoWEM0FQn9HrBHEBp88XxIV3QfXHy5t3bkjHWt6jNBOpoAerDeMyNVHKx\
+PNpMsfZO116AmIxrFFjQpBK29OdTwRzTwNOjE7TNdIFjf7NCJMDe3h6U9C3jf2TdVSOMwJSgTyl9\
+Di1HowiG5pfq1lIzngoac1qgwRhZcmVq5NlN7Z+enf7sHL1+v1/nytU3X4kC4ebdGM+VNn9cu6br\
+si7rsi7r8qcs/w8AInVFAFAAAA==\
 | base64 -d | tar xzC /tmp
 
 # Import patch files for ruby and gems
@@ -86,7 +115,7 @@
 # do not generate documentation for gems
 RUN echo "gem: --no-ri --no-rdoc" >> ~/.gemrc && \
     bash -c " \
-        rvm all do gem install bundler rake-compiler hoe mini_portile rubygems-tasks json && \
+        rvm all do gem install bundler rake-compiler hoe mini_portile rubygems-tasks && \
         rvm 2.3.0 do gem install mini_portile2 && \
         find /usr/local/rvm -type d -print0 | sudo xargs -0 chmod g+sw "
 
@@ -96,7 +125,7 @@
     ln -s /usr/local/rake-compiler ~/.rake-compiler
 
 # Patch rake-compiler to avoid build of ruby extensions
-RUN cd /usr/local/rvm/gems/ruby-2.3.0/gems/rake-compiler-0.9.5 && patch -p1 < /home/rvm/patches/rake-compiler-0.9.5/without-exts.diff ; \
+RUN cd /usr/local/rvm/gems/ruby-2.3.0/gems/rake-compiler-0.9.5 && git apply /home/rvm/patches/rake-compiler-0.9.5/*.diff ; \
     true
 
 RUN bash -c "rvm use 2.3.0 --default && \
@@ -150,9 +179,12 @@
 RUN find / -name rbconfig.rb | while read f ; do sed -i 's/0x0501/0x0600/' $f ; done
 RUN find / -name win32.h | while read f ; do sed -i 's/gettimeofday/rb_gettimeofday/' $f ; done
 RUN sed -i 's/defined.__MINGW64__.$/1/' /usr/local/rake-compiler/ruby/i686-w64-mingw32/ruby-2.0.0-p645/include/ruby-2.0.0/ruby/win32.h
-RUN find / -name libwinpthread.dll.a | while read f ; do rm $f ; done
-RUN find / -name libwinpthread-1.dll | while read f ; do rm $f ; done
+RUN find / -name libwinpthread.dll.a | xargs rm
+RUN find / -name libwinpthread-1.dll | xargs rm
 RUN find / -name *msvcrt-ruby*.dll.a | while read f ; do n=`echo $f | sed s/.dll//` ; mv $f $n ; done
+RUN find /usr/local/rake-compiler/ruby -name libruby.so | xargs rm
+RUN find /usr/local/rake-compiler/ruby -name libruby-static.a | while read f ; do ar t $f | xargs ar d $f ; done
+RUN find /usr/local/rake-compiler/ruby -name libruby-static.a | while read f ; do mv $f `echo $f | sed s/-static//` ; done
 
 # Install SIGINT forwarder
 RUN cp /tmp/build/sigfw.c /root/
diff --git a/third_party/rake-compiler-dock/build.sh b/third_party/rake-compiler-dock/build.sh
index 22ffd18..ca01fa6 100755
--- a/third_party/rake-compiler-dock/build.sh
+++ b/third_party/rake-compiler-dock/build.sh
@@ -4,4 +4,4 @@
 
 echo 'RUN echo \\'
 tar cz build | base64 | sed 's/$/\\/'
-echo '| base64 -d | tar xzC /'
+echo '| base64 -d | tar xzC /tmp'
diff --git a/third_party/rake-compiler-dock/build/patches/rake-compiler-0.9.5/compat-with-bundler.diff b/third_party/rake-compiler-dock/build/patches/rake-compiler-0.9.5/compat-with-bundler.diff
new file mode 100644
index 0000000..ea22bd9
--- /dev/null
+++ b/third_party/rake-compiler-dock/build/patches/rake-compiler-0.9.5/compat-with-bundler.diff
@@ -0,0 +1,105 @@
+From 41f834449fc4323b2f995e8715aa5842d9fd9334 Mon Sep 17 00:00:00 2001
+From: Lars Kanis <lars@greiz-reinsdorf.de>
+Date: Sat, 30 Jan 2016 08:08:07 +0100
+Subject: [PATCH] Change the fake mechanism to be compatible with bundler.
+
+The previous fake mechanism worked by hooking onto the
+"require 'rbconfig'" call.
+This is problematic because bundler internally requires rbconfig, but doesn't
+work corretly in a faked environment.
+It then fails to load gems that are also part of the standard library, like
+json and rdoc.
+This results in issues like https://github.com/rake-compiler/rake-compiler-dock/issues/8
+
+The fake mechanism is now changed to hook onto the "require 'mkrb'" call,
+which is typically part of the extconf file, and it is where the faked platform
+values are actually needed.
+That way it is loaded after bundler/setup, so that the library paths are
+set according to the Gemfile.lock, to the native Linux libraries, before
+the fake environment is active.
+
+Please note, that the build directory of a given gem needs to be cleared,
+in order to get updated fake files. So do a "rm tmp pkg -rf".
+---
+ lib/rake/extensiontask.rb | 35 ++++++++++++++---------------------
+ 1 file changed, 14 insertions(+), 21 deletions(-)
+
+diff --git a/lib/rake/extensiontask.rb b/lib/rake/extensiontask.rb
+index 030af96..f914919 100644
+--- a/lib/rake/extensiontask.rb
++++ b/lib/rake/extensiontask.rb
+@@ -169,8 +169,8 @@ Java extension should be preferred.
+         # now add the extconf script
+         cmd << abs_extconf.relative_path_from(abs_tmp_path)
+ 
+-        # rbconfig.rb will be present if we are cross compiling
+-        if t.prerequisites.include?("#{tmp_path}/rbconfig.rb") then
++        # fake.rb will be present if we are cross compiling
++        if t.prerequisites.include?("#{tmp_path}/fake.rb") then
+           options.push(*cross_config_options(platf))
+         end
+ 
+@@ -365,39 +365,30 @@ Java extension should be preferred.
+       # define compilation tasks for cross platform!
+       define_compile_tasks(for_platform, ruby_ver)
+ 
+-      # chain fake.rb, rbconfig.rb and mkmf.rb to Makefile generation
++      # chain fake.rb and mkmf.rb to Makefile generation
+       file "#{tmp_path}/Makefile" => ["#{tmp_path}/fake.rb",
+-                                      "#{tmp_path}/rbconfig.rb",
+                                       "#{tmp_path}/mkmf.rb"]
+ 
+-      # copy the file from the cross-ruby location
+-      file "#{tmp_path}/rbconfig.rb" => [rbconfig_file] do |t|
++      # copy the rbconfig from the cross-ruby location and
++      # genearte fake.rb for different ruby versions
++      file "#{tmp_path}/fake.rb" => [rbconfig_file] do |t|
+         File.open(t.name, 'w') do |f|
+-          f.write "require 'fake.rb'\n\n"
++          f.write fake_rb(for_platform, ruby_ver)
+           f.write File.read(t.prerequisites.first)
+         end
+       end
+ 
+       # copy mkmf from cross-ruby location
+       file "#{tmp_path}/mkmf.rb" => [mkmf_file] do |t|
+-        cp t.prerequisites.first, t.name
+-        if ruby_ver < "1.9" && "1.9" <= RUBY_VERSION
+-          File.open(t.name, 'r+t') do |f|
+-            content = f.read
++        File.open(t.name, 'w') do |f|
++          content = File.read(t.prerequisites.first)
++          content.sub!(/^(require ')rbconfig(')$/, '\\1fake\\2')
++          if ruby_ver < "1.9" && "1.9" <= RUBY_VERSION
+             content.sub!(/^(      break )\*(defaults)$/, '\\1\\2.first')
+             content.sub!(/^(    return )\*(defaults)$/, '\\1\\2.first')
+             content.sub!(/^(  mfile\.)print( configuration\(srcprefix\))$/, '\\1puts\\2')
+-            f.rewind
+-            f.write content
+-            f.truncate(f.tell)
+           end
+-        end
+-      end
+-
+-      # genearte fake.rb for different ruby versions
+-      file "#{tmp_path}/fake.rb" do |t|
+-        File.open(t.name, 'w') do |f|
+-          f.write fake_rb(for_platform, ruby_ver)
++          f.write content
+         end
+       end
+ 
+@@ -495,8 +486,10 @@ Java extension should be preferred.
+         # "cannot load such file -- win32/resolv" when it is required later on.
+         # See also: https://github.com/tjschuck/rake-compiler-dev-box/issues/5
+         require 'resolv'
++        require 'rbconfig'
+ 
+         class Object
++          remove_const :RbConfig
+           remove_const :RUBY_PLATFORM
+           remove_const :RUBY_VERSION
+           remove_const :RUBY_DESCRIPTION if defined?(RUBY_DESCRIPTION)
+-- 
+2.5.0.windows.1
+
diff --git a/tools/buildgen/plugins/expand_version.py b/tools/buildgen/plugins/expand_version.py
index 4600c32..b55e1b1 100755
--- a/tools/buildgen/plugins/expand_version.py
+++ b/tools/buildgen/plugins/expand_version.py
@@ -51,6 +51,7 @@
 class Version:
 
   def __init__(self, s):
+    self.tag = None
     if '-' in s:
       s, self.tag = s.split('-')
     self.major, self.minor, self.patch = [int(x) for x in s.split('.')]
@@ -76,6 +77,13 @@
         raise Exception('Don\'t know how to translate version tag "%s" to pep440' % self.tag)
     return s
 
+  def ruby(self):
+    """Version string in Ruby style"""
+    if self.tag:
+      return '%d.%d.%d.%s' % (self.major, self.minor, self.patch, self.tag)
+    else:
+      return '%d.%d.%d' % (self.major, self.minor, self.patch)
+
 def mako_plugin(dictionary):
   """Expand version numbers:
      - for each language, ensure there's a language_version tag in
diff --git a/tools/codegen/core/gen_static_metadata.py b/tools/codegen/core/gen_static_metadata.py
index 3e47d7f..e6ae00e 100755
--- a/tools/codegen/core/gen_static_metadata.py
+++ b/tools/codegen/core/gen_static_metadata.py
@@ -1,6 +1,6 @@
 #!/usr/bin/env python2.7
 
-# Copyright 2015, Google Inc.
+# Copyright 2015-2016, Google Inc.
 # All rights reserved.
 #
 # Redistribution and use in source and binary forms, with or without
@@ -50,8 +50,8 @@
     'host',
     'grpc-message',
     'grpc-status',
-    'census',
     'census-bin',
+    'census-binary-bin',
     '',
     ('grpc-status', '0'),
     ('grpc-status', '1'),
diff --git a/tools/dockerfile/grpc_interop_python/build_interop.sh b/tools/dockerfile/grpc_interop_python/build_interop.sh
index 203b012..ed73680 100755
--- a/tools/dockerfile/grpc_interop_python/build_interop.sh
+++ b/tools/dockerfile/grpc_interop_python/build_interop.sh
@@ -39,7 +39,6 @@
 
 cd /var/local/git/grpc
 
-make install-certs
 make
 
 # build Python interop client and server
diff --git a/tools/jenkins/docker_run.sh b/tools/jenkins/docker_run.sh
index 519dc5c..df7b657 100755
--- a/tools/jenkins/docker_run.sh
+++ b/tools/jenkins/docker_run.sh
@@ -47,8 +47,6 @@
   rvm use ruby-2.1
 fi
 
-nvm use 4 || true
-
 cd /var/local/git/grpc
 
 $RUN_COMMAND
diff --git a/tools/run_tests/artifact_targets.py b/tools/run_tests/artifact_targets.py
index b37f968..74d2a48 100644
--- a/tools/run_tests/artifact_targets.py
+++ b/tools/run_tests/artifact_targets.py
@@ -62,7 +62,7 @@
           cmdline=cmdline,
           environ=environ,
           shortname='build_artifact.%s' % (name),
-          timeout_seconds=10*60,
+          timeout_seconds=30*60,
           flake_retries=flake_retries,
           timeout_retries=timeout_retries,
           shell=shell)
diff --git a/tools/run_tests/build_artifact_node.sh b/tools/run_tests/build_artifact_node.sh
index ec3fb64..8aeec79 100755
--- a/tools/run_tests/build_artifact_node.sh
+++ b/tools/run_tests/build_artifact_node.sh
@@ -28,8 +28,12 @@
 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 
+NODE_TARGET_ARCH=$1
+source ~/.nvm/nvm.sh
 set -ex
 
+nvm use 4
+
 cd $(dirname $0)/../..
 
 rm -rf build
@@ -42,6 +46,6 @@
 
 for version in ${node_versions[@]}
 do
-  node-pre-gyp configure rebuild package testpackage --target=$version --target_arch=$1
+  node-pre-gyp configure rebuild package testpackage --target=$version --target_arch=$NODE_TARGET_ARCH
   cp -r build/stage/* artifacts/
 done
diff --git a/tools/run_tests/build_package_node.sh b/tools/run_tests/build_package_node.sh
index 1358740..a8b9448 100755
--- a/tools/run_tests/build_package_node.sh
+++ b/tools/run_tests/build_package_node.sh
@@ -28,8 +28,11 @@
 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 
+source ~/.nvm/nvm.sh
 set -ex
 
+nvm use 4
+
 cd $(dirname $0)/../..
 
 mkdir -p artifacts/
diff --git a/tools/run_tests/distribtest_targets.py b/tools/run_tests/distribtest_targets.py
index d0efdc0..a46917c 100644
--- a/tools/run_tests/distribtest_targets.py
+++ b/tools/run_tests/distribtest_targets.py
@@ -111,10 +111,11 @@
     self.arch = arch
     self.node_version = node_version
     self.labels = ['distribtest', 'node', platform, arch,
-                   docker_suffix, 'node-%s' % node_version]
+                   'node-%s' % node_version]
     if docker_suffix is not None:
       self.name += '_%s' % docker_suffix
       self.docker_suffix = docker_suffix
+      self.labels.append(docker_suffix)
 
   def pre_build_jobspecs(self):
     return []
diff --git a/tools/run_tests/run_interop_tests.py b/tools/run_tests/run_interop_tests.py
index 4a670e0..76be932 100755
--- a/tools/run_tests/run_interop_tests.py
+++ b/tools/run_tests/run_interop_tests.py
@@ -535,10 +535,10 @@
     env['TTY_FLAG'] = '-t'
   # This env variable is used to get around the github rate limit
   # error when running the PHP `composer install` command
-  # TODO(stanleycheung): find a more elegant way to do this
-  if language.safename == 'php' and os.path.exists('/var/local/.composer/auth.json'):
+  host_file = '%s/.composer/auth.json' % os.environ['HOME']
+  if language.safename == 'php' and os.path.exists(host_file):
     env['BUILD_INTEROP_DOCKER_EXTRA_ARGS'] = \
-      '-v /var/local/.composer/auth.json:/root/.composer/auth.json:ro'
+      '-v %s:/root/.composer/auth.json:ro' % host_file
   build_job = jobset.JobSpec(
           cmdline=['tools/jenkins/build_interop_image.sh'],
           environ=env,