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"""Setup module for the GRPC Python package's optional health checking.""" 15 16import os 17 18import setuptools 19 20_PACKAGE_PATH = os.path.realpath(os.path.dirname(__file__)) 21_README_PATH = os.path.join(_PACKAGE_PATH, "README.rst") 22 23# Ensure we're in the proper directory whether or not we're being used by pip. 24os.chdir(os.path.dirname(os.path.abspath(__file__))) 25 26# Break import-style to ensure we can actually find our local modules. 27import python_version 28 29import grpc_version 30 31 32class _NoOpCommand(setuptools.Command): 33 """No-op command.""" 34 35 description = "" 36 user_options = [] 37 38 def initialize_options(self): 39 pass 40 41 def finalize_options(self): 42 pass 43 44 def run(self): 45 pass 46 47 48CLASSIFIERS = ( 49 [ 50 "Development Status :: 5 - Production/Stable", 51 "Programming Language :: Python", 52 "Programming Language :: Python :: 3", 53 ] 54 + [ 55 f"Programming Language :: Python :: {x}" 56 for x in python_version.SUPPORTED_PYTHON_VERSIONS 57 ] 58 + ["License :: OSI Approved :: Apache Software License"] 59) 60 61PACKAGE_DIRECTORIES = { 62 "": ".", 63} 64 65INSTALL_REQUIRES = ( 66 "protobuf>=5.26.1,<6.0dev", 67 "grpcio>={version}".format(version=grpc_version.VERSION), 68) 69 70try: 71 import health_commands as _health_commands 72 73 # we are in the build environment, otherwise the above import fails 74 SETUP_REQUIRES = ( 75 "grpcio-tools=={version}".format(version=grpc_version.VERSION), 76 ) 77 COMMAND_CLASS = { 78 # Run preprocess from the repository *before* doing any packaging! 79 "preprocess": _health_commands.Preprocess, 80 "build_package_protos": _health_commands.BuildPackageProtos, 81 } 82except ImportError: 83 SETUP_REQUIRES = () 84 COMMAND_CLASS = { 85 # wire up commands to no-op not to break the external dependencies 86 "preprocess": _NoOpCommand, 87 "build_package_protos": _NoOpCommand, 88 } 89 90setuptools.setup( 91 name="grpcio-health-checking", 92 version=grpc_version.VERSION, 93 description="Standard Health Checking Service for gRPC", 94 long_description=open(_README_PATH, "r").read(), 95 author="The gRPC Authors", 96 author_email="grpc-io@googlegroups.com", 97 url="https://grpc.io", 98 license="Apache License 2.0", 99 classifiers=CLASSIFIERS, 100 package_dir=PACKAGE_DIRECTORIES, 101 packages=setuptools.find_packages("."), 102 python_requires=f">={python_version.MIN_PYTHON_VERSION}", 103 install_requires=INSTALL_REQUIRES, 104 setup_requires=SETUP_REQUIRES, 105 cmdclass=COMMAND_CLASS, 106) 107