Debian Codegraph @

src/python/grpcio_reflection/setup.py

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