Jan Tattermusch | 7897ae9 | 2017-06-07 22:57:36 +0200 | [diff] [blame] | 1 | # Copyright 2016 gRPC authors. |
Masood Malekghassemi | aff6936 | 2016-09-21 15:10:36 -0700 | [diff] [blame] | 2 | # |
Jan Tattermusch | 7897ae9 | 2017-06-07 22:57:36 +0200 | [diff] [blame] | 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 |
Masood Malekghassemi | aff6936 | 2016-09-21 15:10:36 -0700 | [diff] [blame] | 6 | # |
Jan Tattermusch | 7897ae9 | 2017-06-07 22:57:36 +0200 | [diff] [blame] | 7 | # http://www.apache.org/licenses/LICENSE-2.0 |
Masood Malekghassemi | aff6936 | 2016-09-21 15:10:36 -0700 | [diff] [blame] | 8 | # |
Jan Tattermusch | 7897ae9 | 2017-06-07 22:57:36 +0200 | [diff] [blame] | 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. |
Masood Malekghassemi | aff6936 | 2016-09-21 15:10:36 -0700 | [diff] [blame] | 14 | """Setup module for the GRPC Python package's optional reflection.""" |
| 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 | |
Mehrdad Afshari | 9d1ba2e | 2017-11-13 14:16:21 -0800 | [diff] [blame] | 24 | # Break import-style to ensure we can actually find our local modules. |
Masood Malekghassemi | aff6936 | 2016-09-21 15:10:36 -0700 | [diff] [blame] | 25 | import grpc_version |
| 26 | |
Mehrdad Afshari | 9d1ba2e | 2017-11-13 14:16:21 -0800 | [diff] [blame] | 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 | |
Ken Payson | 9c42044 | 2017-07-25 12:06:46 -0700 | [diff] [blame] | 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', |
Ken Payson | f5f5ed0 | 2017-08-24 11:46:03 -0700 | [diff] [blame] | 54 | ] |
Ken Payson | 9c42044 | 2017-07-25 12:06:46 -0700 | [diff] [blame] | 55 | |
Ken Payson | 2fa5f2f | 2017-02-06 10:27:09 -0800 | [diff] [blame] | 56 | PACKAGE_DIRECTORIES = { |
| 57 | '': '.', |
| 58 | } |
Masood Malekghassemi | aff6936 | 2016-09-21 15:10:36 -0700 | [diff] [blame] | 59 | |
Mehrdad Afshari | 87cd994 | 2018-01-02 14:40:00 -0800 | [diff] [blame] | 60 | INSTALL_REQUIRES = ( |
| 61 | 'protobuf>=3.5.0.post1', |
| 62 | 'grpcio>={version}'.format(version=grpc_version.VERSION), |
| 63 | ) |
Masood Malekghassemi | aff6936 | 2016-09-21 15:10:36 -0700 | [diff] [blame] | 64 | |
Mehrdad Afshari | 9d1ba2e | 2017-11-13 14:16:21 -0800 | [diff] [blame] | 65 | try: |
Mehrdad Afshari | 9d1ba2e | 2017-11-13 14:16:21 -0800 | [diff] [blame] | 66 | import reflection_commands as _reflection_commands |
Mehrdad Afshari | 90dbd2b | 2017-11-16 15:21:02 -0800 | [diff] [blame] | 67 | # we are in the build environment, otherwise the above import fails |
Mehrdad Afshari | 9d1ba2e | 2017-11-13 14:16:21 -0800 | [diff] [blame] | 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': _reflection_commands.CopyProtoModules, |
| 73 | 'build_package_protos': _reflection_commands.BuildPackageProtos, |
| 74 | } |
Mehrdad Afshari | 90dbd2b | 2017-11-16 15:21:02 -0800 | [diff] [blame] | 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 | } |
Masood Malekghassemi | aff6936 | 2016-09-21 15:10:36 -0700 | [diff] [blame] | 82 | |
| 83 | setuptools.setup( |
| 84 | name='grpcio-reflection', |
| 85 | version=grpc_version.VERSION, |
Jan Tattermusch | 4d5c310 | 2017-06-07 10:23:56 +0200 | [diff] [blame] | 86 | license='Apache License 2.0', |
Ken Payson | 7835430 | 2017-03-06 09:28:16 -0800 | [diff] [blame] | 87 | description='Standard Protobuf Reflection Service for gRPC', |
| 88 | author='The gRPC Authors', |
| 89 | author_email='grpc-io@googlegroups.com', |
Ken Payson | 9c42044 | 2017-07-25 12:06:46 -0700 | [diff] [blame] | 90 | classifiers=CLASSIFIERS, |
Mehrdad Afshari | bb3d95b | 2017-07-10 22:24:28 +0000 | [diff] [blame] | 91 | url='https://grpc.io', |
Masood Malekghassemi | aff6936 | 2016-09-21 15:10:36 -0700 | [diff] [blame] | 92 | package_dir=PACKAGE_DIRECTORIES, |
| 93 | packages=setuptools.find_packages('.'), |
Masood Malekghassemi | aff6936 | 2016-09-21 15:10:36 -0700 | [diff] [blame] | 94 | install_requires=INSTALL_REQUIRES, |
| 95 | setup_requires=SETUP_REQUIRES, |
Masood Malekghassemi | cc79370 | 2017-01-13 19:20:10 -0800 | [diff] [blame] | 96 | cmdclass=COMMAND_CLASS) |