setup.py 3.1 KB

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