aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/python/grpcio/setup.py
diff options
context:
space:
mode:
Diffstat (limited to 'src/python/grpcio/setup.py')
-rw-r--r--src/python/grpcio/setup.py120
1 files changed, 85 insertions, 35 deletions
diff --git a/src/python/grpcio/setup.py b/src/python/grpcio/setup.py
index ec68eb6755..8ac185bd6b 100644
--- a/src/python/grpcio/setup.py
+++ b/src/python/grpcio/setup.py
@@ -43,12 +43,21 @@ os.chdir(os.path.dirname(os.path.abspath(__file__)))
# Break import-style to ensure we can actually find our commands module.
import commands
-# Use environment variables to determine whether or not the Cython extension
-# should *use* Cython or use the generated C files. Note that this requires the
-# C files to have been generated by building first *with* Cython support.
-_BUILD_WITH_CYTHON = os.environ.get('GRPC_PYTHON_BUILD_WITH_CYTHON', False)
+# Environment variable to determine whether or not the Cython extension should
+# *use* Cython or use the generated C files. Note that this requires the C files
+# to have been generated by building first *with* Cython support.
+BUILD_WITH_CYTHON = os.environ.get('GRPC_PYTHON_BUILD_WITH_CYTHON', False)
-_C_EXTENSION_SOURCES = (
+# Environment variable to determine whether or not to enable coverage analysis
+# in Cython modules.
+ENABLE_CYTHON_TRACING = os.environ.get(
+ 'GRPC_PYTHON_ENABLE_CYTHON_TRACING', False)
+
+# Environment variable to determine whether or not to include the test files in
+# the installation.
+INSTALL_TESTS = os.environ.get('GRPC_PYTHON_INSTALL_TESTS', False)
+
+C_EXTENSION_SOURCES = (
'grpc/_adapter/_c/module.c',
'grpc/_adapter/_c/types.c',
'grpc/_adapter/_c/utility.c',
@@ -61,9 +70,9 @@ _C_EXTENSION_SOURCES = (
'grpc/_adapter/_c/types/server.c',
)
-_CYTHON_EXTENSION_PACKAGE_NAMES = ()
+CYTHON_EXTENSION_PACKAGE_NAMES = ()
-_CYTHON_EXTENSION_MODULE_NAMES = (
+CYTHON_EXTENSION_MODULE_NAMES = (
'grpc._cython.cygrpc',
'grpc._cython._cygrpc.call',
'grpc._cython._cygrpc.channel',
@@ -73,24 +82,24 @@ _CYTHON_EXTENSION_MODULE_NAMES = (
'grpc._cython._cygrpc.server',
)
-_EXTENSION_INCLUDE_DIRECTORIES = (
+EXTENSION_INCLUDE_DIRECTORIES = (
'.',
)
-_EXTENSION_LIBRARIES = (
+EXTENSION_LIBRARIES = (
'grpc',
'gpr',
)
if not "darwin" in sys.platform:
- _EXTENSION_LIBRARIES += ('rt',)
+ EXTENSION_LIBRARIES += ('rt',)
-_C_EXTENSION_MODULE = _core.Extension(
- 'grpc._adapter._c', sources=list(_C_EXTENSION_SOURCES),
- include_dirs=list(_EXTENSION_INCLUDE_DIRECTORIES),
- libraries=list(_EXTENSION_LIBRARIES),
+C_EXTENSION_MODULE = _core.Extension(
+ 'grpc._adapter._c', sources=list(C_EXTENSION_SOURCES),
+ include_dirs=list(EXTENSION_INCLUDE_DIRECTORIES),
+ libraries=list(EXTENSION_LIBRARIES)
)
-_EXTENSION_MODULES = [_C_EXTENSION_MODULE]
+EXTENSION_MODULES = [C_EXTENSION_MODULE]
def cython_extensions(package_names, module_names, include_dirs, libraries,
@@ -101,48 +110,89 @@ def cython_extensions(package_names, module_names, include_dirs, libraries,
extensions = [
_extension.Extension(
name=module_name, sources=[module_file],
- include_dirs=include_dirs, libraries=libraries
+ include_dirs=include_dirs, libraries=libraries,
+ define_macros=[('CYTHON_TRACE_NOGIL', 1)] if ENABLE_CYTHON_TRACING else []
) for (module_name, module_file) in zip(module_names, module_files)
]
if build_with_cython:
import Cython.Build
- return Cython.Build.cythonize(extensions)
+ return Cython.Build.cythonize(
+ extensions,
+ compiler_directives={'linetrace': bool(ENABLE_CYTHON_TRACING)})
else:
return extensions
-_CYTHON_EXTENSION_MODULES = cython_extensions(
- list(_CYTHON_EXTENSION_PACKAGE_NAMES), list(_CYTHON_EXTENSION_MODULE_NAMES),
- list(_EXTENSION_INCLUDE_DIRECTORIES), list(_EXTENSION_LIBRARIES),
- bool(_BUILD_WITH_CYTHON))
+CYTHON_EXTENSION_MODULES = cython_extensions(
+ list(CYTHON_EXTENSION_PACKAGE_NAMES), list(CYTHON_EXTENSION_MODULE_NAMES),
+ list(EXTENSION_INCLUDE_DIRECTORIES), list(EXTENSION_LIBRARIES),
+ bool(BUILD_WITH_CYTHON))
-_PACKAGES = setuptools.find_packages('.')
-
-_PACKAGE_DIRECTORIES = {
+PACKAGE_DIRECTORIES = {
'': '.',
}
-_INSTALL_REQUIRES = (
+INSTALL_REQUIRES = (
'enum34>=1.0.4',
'futures>=2.2.0',
)
-_SETUP_REQUIRES = (
+SETUP_REQUIRES = (
'sphinx>=1.3',
-) + _INSTALL_REQUIRES
+) + INSTALL_REQUIRES
-_COMMAND_CLASS = {
+COMMAND_CLASS = {
'doc': commands.SphinxDocumentation,
+ 'build_proto_modules': commands.BuildProtoModules,
'build_project_metadata': commands.BuildProjectMetadata,
'build_py': commands.BuildPy,
+ 'gather': commands.Gather,
+ 'run_interop': commands.RunInterop,
+}
+
+TEST_PACKAGE_DATA = {
+ 'tests.interop': [
+ 'credentials/ca.pem',
+ 'credentials/server1.key',
+ 'credentials/server1.pem',
+ ],
+ 'tests.protoc_plugin': [
+ 'protoc_plugin_test.proto',
+ ],
+ 'tests.unit': [
+ 'credentials/ca.pem',
+ 'credentials/server1.key',
+ 'credentials/server1.pem',
+ ],
}
+TESTS_REQUIRE = (
+ 'oauth2client>=1.4.7',
+ 'protobuf==3.0.0a3',
+ 'coverage>=4.0',
+) + INSTALL_REQUIRES
+
+TEST_SUITE = 'tests'
+TEST_LOADER = 'tests:Loader'
+TEST_RUNNER = 'tests:Runner'
+
+PACKAGE_DATA = {}
+if INSTALL_TESTS:
+ PACKAGE_DATA = dict(PACKAGE_DATA, **TEST_PACKAGE_DATA)
+ PACKAGES = setuptools.find_packages('.')
+else:
+ PACKAGES = setuptools.find_packages('.', exclude=['tests', 'tests.*'])
+
setuptools.setup(
name='grpcio',
- version='0.11.0b1',
- ext_modules=_EXTENSION_MODULES + _CYTHON_EXTENSION_MODULES,
- packages=list(_PACKAGES),
- package_dir=_PACKAGE_DIRECTORIES,
- install_requires=_INSTALL_REQUIRES,
- setup_requires=_SETUP_REQUIRES,
- cmdclass=_COMMAND_CLASS
+ version='0.11.0b2',
+ ext_modules=EXTENSION_MODULES + CYTHON_EXTENSION_MODULES,
+ packages=list(PACKAGES),
+ package_dir=PACKAGE_DIRECTORIES,
+ install_requires=INSTALL_REQUIRES,
+ setup_requires=SETUP_REQUIRES,
+ cmdclass=COMMAND_CLASS,
+ tests_require=TESTS_REQUIRE,
+ test_suite=TEST_SUITE,
+ test_loader=TEST_LOADER,
+ test_runner=TEST_RUNNER,
)