f8c0e93913dec9ddfc1146108e5e6852ced1502d
[platform/upstream/grpc.git] / src / python / grpcio_channelz / setup.py
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
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 we can actually find our local 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 CLASSIFIERS = [
45     'Development Status :: 5 - Production/Stable',
46     'Programming Language :: Python',
47     'Programming Language :: Python :: 2',
48     'Programming Language :: Python :: 2.7',
49     'Programming Language :: Python :: 3',
50     'Programming Language :: Python :: 3.4',
51     'Programming Language :: Python :: 3.5',
52     'Programming Language :: Python :: 3.6',
53     'License :: OSI Approved :: Apache Software License',
54 ]
55
56 PACKAGE_DIRECTORIES = {
57     '': '.',
58 }
59
60 INSTALL_REQUIRES = (
61     'protobuf>=3.6.0',
62     'grpcio>={version}'.format(version=grpc_version.VERSION),
63 )
64
65 try:
66     import channelz_commands as _channelz_commands
67     # we are in the build environment, otherwise the above import fails
68     SETUP_REQUIRES = (
69         'grpcio-tools=={version}'.format(version=grpc_version.VERSION),)
70     COMMAND_CLASS = {
71         # Run preprocess from the repository *before* doing any packaging!
72         'preprocess': _channelz_commands.Preprocess,
73         'build_package_protos': _channelz_commands.BuildPackageProtos,
74     }
75 except ImportError:
76     SETUP_REQUIRES = ()
77     COMMAND_CLASS = {
78         # wire up commands to no-op not to break the external dependencies
79         'preprocess': _NoOpCommand,
80         'build_package_protos': _NoOpCommand,
81     }
82
83 setuptools.setup(
84     name='grpcio-channelz',
85     version=grpc_version.VERSION,
86     license='Apache License 2.0',
87     description='Channel Level Live Debug Information Service for gRPC',
88     author='The gRPC Authors',
89     author_email='grpc-io@googlegroups.com',
90     classifiers=CLASSIFIERS,
91     url='https://grpc.io',
92     package_dir=PACKAGE_DIRECTORIES,
93     packages=setuptools.find_packages('.'),
94     install_requires=INSTALL_REQUIRES,
95     setup_requires=SETUP_REQUIRES,
96     cmdclass=COMMAND_CLASS)