From 736173487cfda82b3dd3bdcf812eddc9de7a6129 Mon Sep 17 00:00:00 2001 From: Masood Malekghassemi Date: Thu, 18 Feb 2016 12:39:42 -0800 Subject: [PATCH] Exclude cygrpc.so from the Python package --- PYTHON-MANIFEST.in | 3 ++- setup.py | 1 - src/python/grpcio/precompiled.py | 2 ++ tools/run_tests/build_artifact_python.sh | 13 +++++++++++-- 4 files changed, 15 insertions(+), 4 deletions(-) diff --git a/PYTHON-MANIFEST.in b/PYTHON-MANIFEST.in index 072089ac51f14..25aba87c187d2 100644 --- a/PYTHON-MANIFEST.in +++ b/PYTHON-MANIFEST.in @@ -1,4 +1,5 @@ -graft src/python/grpcio/grpc +recursive-include src/python/grpcio/grpc *.c *.h *.py *.pyx *.pxd *.pxi *.python *.pem +recursive-exclude src/python/grpcio/grpc/_cython *.so *.pyd graft src/python/grpcio/tests graft src/core graft include/grpc diff --git a/setup.py b/setup.py index 01faa4c96cd31..46ad75f5a4234 100644 --- a/setup.py +++ b/setup.py @@ -210,7 +210,6 @@ def cython_extensions(package_names, module_names, extra_sources, include_dirs, 'grpc._cython': [ '_windows/grpc_c.32.python', '_windows/grpc_c.64.python', - 'cygrpc.so', ], } if INSTALL_TESTS: diff --git a/src/python/grpcio/precompiled.py b/src/python/grpcio/precompiled.py index 05c651b506f9b..ae2a0c835a078 100644 --- a/src/python/grpcio/precompiled.py +++ b/src/python/grpcio/precompiled.py @@ -100,3 +100,5 @@ def update_setup_arguments(setup_arguments): sys.stderr.write( 'could not write precompiled extension to directory: {} -> {}\n' .format(url, target_path)) + return + setup_arguments['package_data']['grpc._cython'].append('cygrpc.so') diff --git a/tools/run_tests/build_artifact_python.sh b/tools/run_tests/build_artifact_python.sh index 6e7ab911d5bb5..7ba04d75463f3 100755 --- a/tools/run_tests/build_artifact_python.sh +++ b/tools/run_tests/build_artifact_python.sh @@ -39,6 +39,14 @@ then pip install -rrequirements.txt fi +# Build the source distribution first because MANIFEST.in cannot override +# exclusion of built shared objects among package resources (for some +# inexplicable reason). +GRPC_PYTHON_USE_CUSTOM_BDIST=0 \ +GRPC_PYTHON_BUILD_WITH_CYTHON=1 \ +${SETARCH_CMD} python setup.py \ + sdist + # The bdist_wheel_grpc_custom command is finicky about command output ordering # and thus ought to be run in a shell command separate of others. Further, it # trashes the actual bdist_wheel output, so it should be run first so that @@ -48,11 +56,12 @@ GRPC_PYTHON_BUILD_WITH_CYTHON=1 \ ${SETARCH_CMD} python setup.py \ build_tagged_ext +# Wheel has a bug where directories don't get excluded. +# https://bitbucket.org/pypa/wheel/issues/99/cannot-exclude-directory GRPC_PYTHON_USE_CUSTOM_BDIST=0 \ GRPC_PYTHON_BUILD_WITH_CYTHON=1 \ ${SETARCH_CMD} python setup.py \ - bdist_wheel \ - sdist + bdist_wheel mkdir -p artifacts