setup.py 3.1 KB

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