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