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