setup.py 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. # Copyright 2017 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 gRPC Python's testing package."""
  15. import os
  16. import sys
  17. import setuptools
  18. # Ensure we're in the proper directory whether or not we're being used by pip.
  19. os.chdir(os.path.dirname(os.path.abspath(__file__)))
  20. # Break import style to ensure that we can find same-directory modules.
  21. import grpc_version
  22. class _NoOpCommand(setuptools.Command):
  23. """No-op command."""
  24. description = ''
  25. user_options = []
  26. def initialize_options(self):
  27. pass
  28. def finalize_options(self):
  29. pass
  30. def run(self):
  31. pass
  32. PACKAGE_DIRECTORIES = {
  33. '': '.',
  34. }
  35. INSTALL_REQUIRES = (
  36. 'protobuf>=3.6.0',
  37. 'grpcio>={version}'.format(version=grpc_version.VERSION),
  38. )
  39. try:
  40. import testing_commands as _testing_commands
  41. # we are in the build environment, otherwise the above import fails
  42. COMMAND_CLASS = {
  43. # Run preprocess from the repository *before* doing any packaging!
  44. 'preprocess': _testing_commands.Preprocess,
  45. }
  46. except ImportError:
  47. COMMAND_CLASS = {
  48. # wire up commands to no-op not to break the external dependencies
  49. 'preprocess': _NoOpCommand,
  50. }
  51. setuptools.setup(
  52. name='grpcio-testing',
  53. version=grpc_version.VERSION,
  54. license='Apache License 2.0',
  55. description='Testing utilities for gRPC Python',
  56. author='The gRPC Authors',
  57. author_email='grpc-io@googlegroups.com',
  58. url='https://grpc.io',
  59. package_dir=PACKAGE_DIRECTORIES,
  60. packages=setuptools.find_packages('.'),
  61. install_requires=INSTALL_REQUIRES,
  62. cmdclass=COMMAND_CLASS)