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", 41 "grpcio>={version}".format(version=grpc_version.VERSION), 42 "grpcio-channelz>={version}".format(version=grpc_version.VERSION), 43 "grpcio-status>={version}".format(version=grpc_version.VERSION), 44 "grpcio-tools>={version}".format(version=grpc_version.VERSION), 45 "grpcio-health-checking>={version}".format(version=grpc_version.VERSION), 46 "grpcio-observability>={version}".format(version=grpc_version.VERSION), 47 "xds-protos>={version}".format(version=grpc_version.VERSION), 48 "oauth2client>=1.4.7", 49 "protobuf>=5.26.1,<6.0dev", 50 "google-auth>=1.17.2", 51 "requests>=2.14.2", 52 "absl-py>=1.4.0", 53) 54 55COMMAND_CLASS = { 56 # Run `preprocess` *before* doing any packaging! 57 "preprocess": commands.GatherProto, 58 "build_package_protos": grpc_tools.command.BuildPackageProtos, 59 "build_py": commands.BuildPy, 60 "run_fork": commands.RunFork, 61 "run_interop": commands.RunInterop, 62 "test_lite": commands.TestLite, 63 "test_aio": commands.TestAio, 64 "test_py3_only": commands.TestPy3Only, 65} 66 67PACKAGE_DATA = { 68 "tests.interop": [ 69 "credentials/ca.pem", 70 "credentials/server1.key", 71 "credentials/server1.pem", 72 ], 73 "tests.protoc_plugin.protos.invocation_testing": [ 74 "same.proto", 75 "compiler.proto", 76 ], 77 "tests.protoc_plugin.protos.invocation_testing.split_messages": [ 78 "messages.proto", 79 ], 80 "tests.protoc_plugin.protos.invocation_testing.split_services": [ 81 "services.proto", 82 ], 83 "tests.testing.proto": [ 84 "requests.proto", 85 "services.proto", 86 ], 87 "tests.unit": [ 88 "credentials/ca.pem", 89 "credentials/server1.key", 90 "credentials/server1.pem", 91 ], 92 "tests": ["tests.json"], 93} 94 95TEST_SUITE = "tests" 96TEST_LOADER = "tests:Loader" 97TEST_RUNNER = "tests:Runner" 98TESTS_REQUIRE = INSTALL_REQUIRES 99 100PACKAGES = setuptools.find_packages(".") 101 102if __name__ == "__main__": 103 multiprocessing.freeze_support() 104 setuptools.setup( 105 name="grpcio-tests", 106 version=grpc_version.VERSION, 107 license=LICENSE, 108 packages=list(PACKAGES), 109 package_dir=PACKAGE_DIRECTORIES, 110 package_data=PACKAGE_DATA, 111 install_requires=INSTALL_REQUIRES, 112 cmdclass=COMMAND_CLASS, 113 tests_require=TESTS_REQUIRE, 114 test_suite=TEST_SUITE, 115 test_loader=TEST_LOADER, 116 test_runner=TEST_RUNNER, 117 ) 118