1# Copyright 2015 gRPC authors. 2# 3# Licensed under the Apache License, Version 2.0 (the "License"); 4# you may not use this file except in compliance with the License. 5# You may obtain a copy of the License at 6# 7# http://www.apache.org/licenses/LICENSE-2.0 8# 9# Unless required by applicable law or agreed to in writing, software 10# distributed under the License is distributed on an "AS IS" BASIS, 11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12# See the License for the specific language governing permissions and 13# limitations under the License. 14"""A setup module for the gRPC Python package.""" 15 16import multiprocessing 17import os 18import os.path 19import sys 20 21import grpc_tools.command 22import setuptools 23 24PY3 = sys.version_info.major == 3 25 26# Ensure we're in the proper directory whether or not we're being used by pip. 27os.chdir(os.path.dirname(os.path.abspath(__file__))) 28 29# Break import-style to ensure we can actually find our in-repo dependencies. 30import commands 31import grpc_version 32 33LICENSE = 'Apache License 2.0' 34 35PACKAGE_DIRECTORIES = { 36 '': '.', 37} 38 39INSTALL_REQUIRES = ( 40 'coverage>=4.0', 'grpcio>={version}'.format(version=grpc_version.VERSION), 41 'grpcio-channelz>={version}'.format(version=grpc_version.VERSION), 42 'grpcio-status>={version}'.format(version=grpc_version.VERSION), 43 'grpcio-tools>={version}'.format(version=grpc_version.VERSION), 44 'grpcio-health-checking>={version}'.format(version=grpc_version.VERSION), 45 'oauth2client>=1.4.7', 'protobuf>=3.6.0', 'six>=1.10', 46 'google-auth>=1.17.2', 'requests>=2.14.2') 47 48if not PY3: 49 INSTALL_REQUIRES += ('futures>=2.2.0', 'enum34>=1.0.4') 50 51COMMAND_CLASS = { 52 # Run `preprocess` *before* doing any packaging! 53 'preprocess': commands.GatherProto, 54 'build_package_protos': grpc_tools.command.BuildPackageProtos, 55 'build_py': commands.BuildPy, 56 'run_fork': commands.RunFork, 57 'run_interop': commands.RunInterop, 58 'test_lite': commands.TestLite, 59 'test_gevent': commands.TestGevent, 60 'test_aio': commands.TestAio, 61 'test_py3_only': commands.TestPy3Only, 62} 63 64PACKAGE_DATA = { 65 'tests.interop': [ 66 'credentials/ca.pem', 67 'credentials/server1.key', 68 'credentials/server1.pem', 69 ], 70 'tests.protoc_plugin.protos.invocation_testing': ['same.proto',], 71 'tests.protoc_plugin.protos.invocation_testing.split_messages': [ 72 'messages.proto', 73 ], 74 'tests.protoc_plugin.protos.invocation_testing.split_services': [ 75 'services.proto', 76 ], 77 'tests.testing.proto': [ 78 'requests.proto', 79 'services.proto', 80 ], 81 'tests.unit': [ 82 'credentials/ca.pem', 83 'credentials/server1.key', 84 'credentials/server1.pem', 85 ], 86 'tests': ['tests.json'], 87} 88 89TEST_SUITE = 'tests' 90TEST_LOADER = 'tests:Loader' 91TEST_RUNNER = 'tests:Runner' 92TESTS_REQUIRE = INSTALL_REQUIRES 93 94PACKAGES = setuptools.find_packages('.') 95 96if __name__ == "__main__": 97 multiprocessing.freeze_support() 98 setuptools.setup( 99 name='grpcio-tests', 100 version=grpc_version.VERSION, 101 license=LICENSE, 102 packages=list(PACKAGES), 103 package_dir=PACKAGE_DIRECTORIES, 104 package_data=PACKAGE_DATA, 105 install_requires=INSTALL_REQUIRES, 106 cmdclass=COMMAND_CLASS, 107 tests_require=TESTS_REQUIRE, 108 test_suite=TEST_SUITE, 109 test_loader=TEST_LOADER, 110 test_runner=TEST_RUNNER, 111 ) 112