From f751b0b549ac46b7856c72e97343f4c0fa0742aa Mon Sep 17 00:00:00 2001 From: Masood Malekghassemi Date: Thu, 4 Feb 2016 11:34:53 -0800 Subject: [PATCH 1/3] Use envvar for binary repository --- src/python/grpcio/commands.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/python/grpcio/commands.py b/src/python/grpcio/commands.py index 27e95609d66..490d0f07b3d 100644 --- a/src/python/grpcio/commands.py +++ b/src/python/grpcio/commands.py @@ -52,6 +52,10 @@ import support PYTHON_STEM = os.path.dirname(os.path.abspath(__file__)) +BINARIES_REPOSITORY = os.environ.get( + 'GRPC_PYTHON_BINARIES_REPOSITORY', + 'https://storage.googleapis.com/grpc-precompiled-binaries/python/') + CONF_PY_ADDENDUM = """ extensions.append('sphinx.ext.napoleon') napoleon_google_docstring = True @@ -78,10 +82,7 @@ def _get_grpc_custom_bdist_egg(decorated_basename, target_egg_basename): from six.moves.urllib import request decorated_path = decorated_basename + '.egg' try: - url = ( - 'https://storage.googleapis.com/grpc-precompiled-binaries/' - 'python/{target}' - .format(target=decorated_path)) + url = BINARIES_REPOSITORY + '/{target}'.format(target=decorated_path) egg_data = request.urlopen(url).read() except IOError as error: raise CommandError( From a7a50785be7926a53053cc54fe7ee737d06802b6 Mon Sep 17 00:00:00 2001 From: Masood Malekghassemi Date: Thu, 4 Feb 2016 13:46:58 -0800 Subject: [PATCH 2/3] Don't die on missing win32 resources on non-win32 --- src/python/grpcio/grpc/_cython/cygrpc.pyx | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/python/grpcio/grpc/_cython/cygrpc.pyx b/src/python/grpcio/grpc/_cython/cygrpc.pyx index 3967c3045f7..579bac7b8af 100644 --- a/src/python/grpcio/grpc/_cython/cygrpc.pyx +++ b/src/python/grpcio/grpc/_cython/cygrpc.pyx @@ -31,6 +31,7 @@ cimport cpython import pkg_resources import os.path +import sys # TODO(atash): figure out why the coverage tool gets confused about the Cython # coverage plugin when the following files don't have a '.pxi' suffix. @@ -50,10 +51,11 @@ cdef class _ModuleState: cdef bint is_loaded def __cinit__(self): - filename = pkg_resources.resource_filename( - 'grpc._cython', '_windows/grpc_c.64.python') - if not pygrpc_load_core(filename): - raise ImportError('failed to load core gRPC library') + if 'win32' in sys.platform: + filename = pkg_resources.resource_filename( + 'grpc._cython', '_windows/grpc_c.64.python') + if not pygrpc_load_core(filename): + raise ImportError('failed to load core gRPC library') grpc_init() self.is_loaded = True From eae8fc4a8bbfa0370137b2d870805005eb4a8f63 Mon Sep 17 00:00:00 2001 From: Jan Tattermusch Date: Thu, 4 Feb 2016 10:06:26 -0800 Subject: [PATCH 3/3] python distrib smoketest --- test/distrib/python/distribtest.py | 7 +++++++ test/distrib/python/run_distrib_test.sh | 24 +++++++++++++++++++++++- 2 files changed, 30 insertions(+), 1 deletion(-) create mode 100644 test/distrib/python/distribtest.py diff --git a/test/distrib/python/distribtest.py b/test/distrib/python/distribtest.py new file mode 100644 index 00000000000..428ffe2b34a --- /dev/null +++ b/test/distrib/python/distribtest.py @@ -0,0 +1,7 @@ +from grpc.beta import implementations + +# This code doesn't do much but makes sure the native extension is loaded +# which is what we are testing here. +channel = implementations.insecure_channel('localhost', 1000) +del channel +print 'Success!' diff --git a/test/distrib/python/run_distrib_test.sh b/test/distrib/python/run_distrib_test.sh index 34e3efccbd5..a185bcbc269 100755 --- a/test/distrib/python/run_distrib_test.sh +++ b/test/distrib/python/run_distrib_test.sh @@ -32,5 +32,27 @@ set -ex cd $(dirname $0) -pip install "$EXTERNAL_GIT_ROOT/input_artifacts/grpcio-0.12.0b6.tar.gz" +# TODO(jtattermusch): replace the version number +SDIST_ARCHIVE="$EXTERNAL_GIT_ROOT/input_artifacts/grpcio-0.12.0b8.tar.gz" +BDIST_DIR="file://$EXTERNAL_GIT_ROOT/input_artifacts" +if [ ! -f "${SDIST_ARCHIVE}" ] +then + echo "Archive ${SDIST_ARCHIVE} does not exist." + exit 1 +fi + +# TODO(jtattermusch): this shouldn't be required +pip install --upgrade six + +# TODO(jtattermusch): if these don't get preinstalled, pip tries to install them +# with --use-grpc-custom-bdist option, which obviously fails. +pip install --upgrade enum34 +pip install --upgrade futures + +GRPC_PYTHON_BINARIES_REPOSITORY="${BDIST_DIR}" \ + pip install \ + "${SDIST_ARCHIVE}" \ + --install-option="--use-grpc-custom-bdist" + +python distribtest.py