Craig Tiller | 6169d5f | 2016-03-31 07:46:18 -0700 | [diff] [blame] | 1 | # Copyright 2015, Google Inc. |
Masood Malekghassemi | d65632a | 2015-07-27 14:30:09 -0700 | [diff] [blame] | 2 | # All rights reserved. |
| 3 | # |
| 4 | # Redistribution and use in source and binary forms, with or without |
| 5 | # modification, are permitted provided that the following conditions are |
| 6 | # met: |
| 7 | # |
| 8 | # * Redistributions of source code must retain the above copyright |
| 9 | # notice, this list of conditions and the following disclaimer. |
| 10 | # * Redistributions in binary form must reproduce the above |
| 11 | # copyright notice, this list of conditions and the following disclaimer |
| 12 | # in the documentation and/or other materials provided with the |
| 13 | # distribution. |
| 14 | # * Neither the name of Google Inc. nor the names of its |
| 15 | # contributors may be used to endorse or promote products derived from |
| 16 | # this software without specific prior written permission. |
| 17 | # |
| 18 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
| 19 | # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
| 20 | # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
| 21 | # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
| 22 | # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
| 23 | # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
| 24 | # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 25 | # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 26 | # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 27 | # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 28 | # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
Masood Malekghassemi | d65632a | 2015-07-27 14:30:09 -0700 | [diff] [blame] | 29 | """Provides distutils command classes for the GRPC Python setup process.""" |
| 30 | |
Masood Malekghassemi | 7566c9a | 2015-10-21 20:29:23 -0700 | [diff] [blame] | 31 | import distutils |
Masood Malekghassemi | 154b0ee | 2016-01-25 16:45:29 -0800 | [diff] [blame] | 32 | import glob |
Masood Malekghassemi | d65632a | 2015-07-27 14:30:09 -0700 | [diff] [blame] | 33 | import os |
| 34 | import os.path |
Masood Malekghassemi | 154b0ee | 2016-01-25 16:45:29 -0800 | [diff] [blame] | 35 | import platform |
Masood Malekghassemi | 7566c9a | 2015-10-21 20:29:23 -0700 | [diff] [blame] | 36 | import re |
Masood Malekghassemi | 154b0ee | 2016-01-25 16:45:29 -0800 | [diff] [blame] | 37 | import shutil |
Masood Malekghassemi | 7566c9a | 2015-10-21 20:29:23 -0700 | [diff] [blame] | 38 | import subprocess |
Masood Malekghassemi | d65632a | 2015-07-27 14:30:09 -0700 | [diff] [blame] | 39 | import sys |
Masood Malekghassemi | 154b0ee | 2016-01-25 16:45:29 -0800 | [diff] [blame] | 40 | import traceback |
Masood Malekghassemi | d65632a | 2015-07-27 14:30:09 -0700 | [diff] [blame] | 41 | |
| 42 | import setuptools |
Masood Malekghassemi | 58a1dc2 | 2016-01-21 14:23:55 -0800 | [diff] [blame] | 43 | from setuptools.command import build_ext |
Masood Malekghassemi | 5c14763 | 2015-07-31 14:08:19 -0700 | [diff] [blame] | 44 | from setuptools.command import build_py |
Masood Malekghassemi | 154b0ee | 2016-01-25 16:45:29 -0800 | [diff] [blame] | 45 | from setuptools.command import easy_install |
| 46 | from setuptools.command import install |
Masood Malekghassemi | 7566c9a | 2015-10-21 20:29:23 -0700 | [diff] [blame] | 47 | from setuptools.command import test |
Masood Malekghassemi | 1d17781 | 2016-01-12 09:21:57 -0800 | [diff] [blame] | 48 | |
Masood Malekghassemi | 5fec8b3 | 2016-01-25 16:16:50 -0800 | [diff] [blame] | 49 | import support |
| 50 | |
Masood Malekghassemi | 116982e | 2015-12-11 15:53:38 -0800 | [diff] [blame] | 51 | PYTHON_STEM = os.path.dirname(os.path.abspath(__file__)) |
Ken Payson | 707c9e2 | 2016-04-20 09:42:19 -0700 | [diff] [blame] | 52 | GRPC_STEM = os.path.abspath(PYTHON_STEM + '../../../../') |
| 53 | PROTO_STEM = os.path.join(GRPC_STEM, 'src', 'proto') |
| 54 | PROTO_GEN_STEM = os.path.join(GRPC_STEM, 'src', 'python', 'gens') |
Ken Payson | 7722245 | 2016-09-11 22:06:05 -0700 | [diff] [blame] | 55 | CYTHON_STEM = os.path.join(PYTHON_STEM, 'grpc', '_cython') |
Masood Malekghassemi | 116982e | 2015-12-11 15:53:38 -0800 | [diff] [blame] | 56 | |
Masood Malekghassemi | 7566c9a | 2015-10-21 20:29:23 -0700 | [diff] [blame] | 57 | CONF_PY_ADDENDUM = """ |
Masood Malekghassemi | d65632a | 2015-07-27 14:30:09 -0700 | [diff] [blame] | 58 | extensions.append('sphinx.ext.napoleon') |
| 59 | napoleon_google_docstring = True |
| 60 | napoleon_numpy_docstring = True |
Masood Malekghassemi | 48d07c6 | 2016-07-12 15:47:05 -0700 | [diff] [blame] | 61 | napoleon_include_special_with_doc = True |
Masood Malekghassemi | d65632a | 2015-07-27 14:30:09 -0700 | [diff] [blame] | 62 | |
| 63 | html_theme = 'sphinx_rtd_theme' |
Masood Malekghassemi | 25186ae | 2016-12-27 09:05:13 -0800 | [diff] [blame] | 64 | copyright = "2016, The gRPC Authors" |
Masood Malekghassemi | d65632a | 2015-07-27 14:30:09 -0700 | [diff] [blame] | 65 | """ |
| 66 | |
Ken Payson | f7f47a6 | 2016-07-11 11:09:27 -0700 | [diff] [blame] | 67 | API_GLOSSARY = """ |
| 68 | |
| 69 | Glossary |
| 70 | ================ |
| 71 | |
| 72 | .. glossary:: |
| 73 | |
| 74 | metadatum |
| 75 | A key-value pair included in the HTTP header. It is a |
| 76 | 2-tuple where the first entry is the key and the |
| 77 | second is the value, i.e. (key, value). The metadata key is an ASCII str, |
| 78 | and must be a valid HTTP header name. The metadata value can be |
| 79 | either a valid HTTP ASCII str, or bytes. If bytes are provided, |
| 80 | the key must end with '-bin', i.e. |
| 81 | ``('binary-metadata-bin', b'\\x00\\xFF')`` |
| 82 | |
| 83 | metadata |
| 84 | A sequence of metadatum. |
| 85 | """ |
| 86 | |
Masood Malekghassemi | fe8dc88 | 2015-07-27 15:30:33 -0700 | [diff] [blame] | 87 | |
Masood Malekghassemi | 59994bc | 2016-01-12 08:49:26 -0800 | [diff] [blame] | 88 | class CommandError(Exception): |
Masood Malekghassemi | cc79370 | 2017-01-13 19:20:10 -0800 | [diff] [blame] | 89 | """Simple exception class for GRPC custom commands.""" |
Masood Malekghassemi | 59994bc | 2016-01-12 08:49:26 -0800 | [diff] [blame] | 90 | |
| 91 | |
Masood Malekghassemi | 154b0ee | 2016-01-25 16:45:29 -0800 | [diff] [blame] | 92 | # TODO(atash): Remove this once PyPI has better Linux bdist support. See |
| 93 | # https://bitbucket.org/pypa/pypi/issues/120/binary-wheels-for-linux-are-not-supported |
Masood Malekghassemi | 334e9e6 | 2016-02-10 20:12:59 -0800 | [diff] [blame] | 94 | def _get_grpc_custom_bdist(decorated_basename, target_bdist_basename): |
Masood Malekghassemi | cc79370 | 2017-01-13 19:20:10 -0800 | [diff] [blame] | 95 | """Returns a string path to a bdist file for Linux to install. |
Masood Malekghassemi | 154b0ee | 2016-01-25 16:45:29 -0800 | [diff] [blame] | 96 | |
Masood Malekghassemi | 334e9e6 | 2016-02-10 20:12:59 -0800 | [diff] [blame] | 97 | If we can retrieve a pre-compiled bdist from online, uses it. Else, emits a |
Masood Malekghassemi | 154b0ee | 2016-01-25 16:45:29 -0800 | [diff] [blame] | 98 | warning and builds from source. |
| 99 | """ |
Masood Malekghassemi | cc79370 | 2017-01-13 19:20:10 -0800 | [diff] [blame] | 100 | # TODO(atash): somehow the name that's returned from `wheel` is different |
| 101 | # between different versions of 'wheel' (but from a compatibility standpoint, |
| 102 | # the names are compatible); we should have some way of determining name |
| 103 | # compatibility in the same way `wheel` does to avoid having to rename all of |
| 104 | # the custom wheels that we build/upload to GCS. |
Masood Malekghassemi | 334e9e6 | 2016-02-10 20:12:59 -0800 | [diff] [blame] | 105 | |
Masood Malekghassemi | cc79370 | 2017-01-13 19:20:10 -0800 | [diff] [blame] | 106 | # Break import style to ensure that setup.py has had a chance to install the |
| 107 | # relevant package. |
| 108 | from six.moves.urllib import request |
| 109 | decorated_path = decorated_basename + GRPC_CUSTOM_BDIST_EXT |
| 110 | try: |
| 111 | url = BINARIES_REPOSITORY + '/{target}'.format(target=decorated_path) |
| 112 | bdist_data = request.urlopen(url).read() |
| 113 | except IOError as error: |
| 114 | raise CommandError('{}\n\nCould not find the bdist {}: {}'.format( |
| 115 | traceback.format_exc(), decorated_path, error.message)) |
| 116 | # Our chosen local bdist path. |
| 117 | bdist_path = target_bdist_basename + GRPC_CUSTOM_BDIST_EXT |
| 118 | try: |
| 119 | with open(bdist_path, 'w') as bdist_file: |
| 120 | bdist_file.write(bdist_data) |
| 121 | except IOError as error: |
| 122 | raise CommandError('{}\n\nCould not write grpcio bdist: {}' |
| 123 | .format(traceback.format_exc(), error.message)) |
| 124 | return bdist_path |
Masood Malekghassemi | 154b0ee | 2016-01-25 16:45:29 -0800 | [diff] [blame] | 125 | |
| 126 | |
Masood Malekghassemi | d65632a | 2015-07-27 14:30:09 -0700 | [diff] [blame] | 127 | class SphinxDocumentation(setuptools.Command): |
Masood Malekghassemi | cc79370 | 2017-01-13 19:20:10 -0800 | [diff] [blame] | 128 | """Command to generate documentation via sphinx.""" |
Masood Malekghassemi | d65632a | 2015-07-27 14:30:09 -0700 | [diff] [blame] | 129 | |
Masood Malekghassemi | cc79370 | 2017-01-13 19:20:10 -0800 | [diff] [blame] | 130 | description = 'generate sphinx documentation' |
| 131 | user_options = [] |
Masood Malekghassemi | d65632a | 2015-07-27 14:30:09 -0700 | [diff] [blame] | 132 | |
Masood Malekghassemi | cc79370 | 2017-01-13 19:20:10 -0800 | [diff] [blame] | 133 | def initialize_options(self): |
| 134 | pass |
Masood Malekghassemi | d65632a | 2015-07-27 14:30:09 -0700 | [diff] [blame] | 135 | |
Masood Malekghassemi | cc79370 | 2017-01-13 19:20:10 -0800 | [diff] [blame] | 136 | def finalize_options(self): |
| 137 | pass |
Masood Malekghassemi | d65632a | 2015-07-27 14:30:09 -0700 | [diff] [blame] | 138 | |
Masood Malekghassemi | cc79370 | 2017-01-13 19:20:10 -0800 | [diff] [blame] | 139 | def run(self): |
| 140 | # We import here to ensure that setup.py has had a chance to install the |
| 141 | # relevant package eggs first. |
| 142 | import sphinx |
| 143 | import sphinx.apidoc |
| 144 | metadata = self.distribution.metadata |
| 145 | src_dir = os.path.join(PYTHON_STEM, 'grpc') |
| 146 | sys.path.append(src_dir) |
| 147 | sphinx.apidoc.main([ |
| 148 | '', '--force', '--full', '-H', metadata.name, '-A', metadata.author, |
| 149 | '-V', metadata.version, '-R', metadata.version, '-o', |
| 150 | os.path.join('doc', 'src'), src_dir |
| 151 | ]) |
| 152 | conf_filepath = os.path.join('doc', 'src', 'conf.py') |
| 153 | with open(conf_filepath, 'a') as conf_file: |
| 154 | conf_file.write(CONF_PY_ADDENDUM) |
| 155 | glossary_filepath = os.path.join('doc', 'src', 'grpc.rst') |
| 156 | with open(glossary_filepath, 'a') as glossary_filepath: |
| 157 | glossary_filepath.write(API_GLOSSARY) |
| 158 | sphinx.main( |
| 159 | ['', os.path.join('doc', 'src'), os.path.join('doc', 'build')]) |
Masood Malekghassemi | d65632a | 2015-07-27 14:30:09 -0700 | [diff] [blame] | 160 | |
Masood Malekghassemi | 5c14763 | 2015-07-31 14:08:19 -0700 | [diff] [blame] | 161 | |
| 162 | class BuildProjectMetadata(setuptools.Command): |
Masood Malekghassemi | cc79370 | 2017-01-13 19:20:10 -0800 | [diff] [blame] | 163 | """Command to generate project metadata in a module.""" |
Masood Malekghassemi | 5c14763 | 2015-07-31 14:08:19 -0700 | [diff] [blame] | 164 | |
Masood Malekghassemi | cc79370 | 2017-01-13 19:20:10 -0800 | [diff] [blame] | 165 | description = 'build grpcio project metadata files' |
| 166 | user_options = [] |
Masood Malekghassemi | 5c14763 | 2015-07-31 14:08:19 -0700 | [diff] [blame] | 167 | |
Masood Malekghassemi | cc79370 | 2017-01-13 19:20:10 -0800 | [diff] [blame] | 168 | def initialize_options(self): |
| 169 | pass |
Masood Malekghassemi | 5c14763 | 2015-07-31 14:08:19 -0700 | [diff] [blame] | 170 | |
Masood Malekghassemi | cc79370 | 2017-01-13 19:20:10 -0800 | [diff] [blame] | 171 | def finalize_options(self): |
| 172 | pass |
Masood Malekghassemi | 5c14763 | 2015-07-31 14:08:19 -0700 | [diff] [blame] | 173 | |
Masood Malekghassemi | cc79370 | 2017-01-13 19:20:10 -0800 | [diff] [blame] | 174 | def run(self): |
| 175 | with open(os.path.join(PYTHON_STEM, 'grpc/_grpcio_metadata.py'), |
| 176 | 'w') as module_file: |
| 177 | module_file.write('__version__ = """{}"""'.format( |
| 178 | self.distribution.get_version())) |
Masood Malekghassemi | 5c14763 | 2015-07-31 14:08:19 -0700 | [diff] [blame] | 179 | |
| 180 | |
| 181 | class BuildPy(build_py.build_py): |
Masood Malekghassemi | cc79370 | 2017-01-13 19:20:10 -0800 | [diff] [blame] | 182 | """Custom project build command.""" |
Masood Malekghassemi | 5c14763 | 2015-07-31 14:08:19 -0700 | [diff] [blame] | 183 | |
Masood Malekghassemi | cc79370 | 2017-01-13 19:20:10 -0800 | [diff] [blame] | 184 | def run(self): |
| 185 | self.run_command('build_project_metadata') |
| 186 | build_py.build_py.run(self) |
Masood Malekghassemi | 7566c9a | 2015-10-21 20:29:23 -0700 | [diff] [blame] | 187 | |
| 188 | |
Masood Malekghassemi | fd9cc10 | 2016-07-21 14:20:43 -0700 | [diff] [blame] | 189 | def _poison_extensions(extensions, message): |
Masood Malekghassemi | cc79370 | 2017-01-13 19:20:10 -0800 | [diff] [blame] | 190 | """Includes a file that will always fail to compile in all extensions.""" |
| 191 | poison_filename = os.path.join(PYTHON_STEM, 'poison.c') |
| 192 | with open(poison_filename, 'w') as poison: |
| 193 | poison.write('#error {}'.format(message)) |
| 194 | for extension in extensions: |
| 195 | extension.sources = [poison_filename] |
| 196 | |
Masood Malekghassemi | fd9cc10 | 2016-07-21 14:20:43 -0700 | [diff] [blame] | 197 | |
| 198 | def check_and_update_cythonization(extensions): |
Masood Malekghassemi | cc79370 | 2017-01-13 19:20:10 -0800 | [diff] [blame] | 199 | """Replace .pyx files with their generated counterparts and return whether or |
Masood Malekghassemi | fd9cc10 | 2016-07-21 14:20:43 -0700 | [diff] [blame] | 200 | not cythonization still needs to occur.""" |
Masood Malekghassemi | cc79370 | 2017-01-13 19:20:10 -0800 | [diff] [blame] | 201 | for extension in extensions: |
| 202 | generated_pyx_sources = [] |
| 203 | other_sources = [] |
| 204 | for source in extension.sources: |
| 205 | base, file_ext = os.path.splitext(source) |
| 206 | if file_ext == '.pyx': |
| 207 | generated_pyx_source = next((base + gen_ext |
Ken Payson | 2fa5f2f | 2017-02-06 10:27:09 -0800 | [diff] [blame] | 208 | for gen_ext in ('.c', '.cpp',) |
Masood Malekghassemi | cc79370 | 2017-01-13 19:20:10 -0800 | [diff] [blame] | 209 | if os.path.isfile(base + gen_ext)), |
| 210 | None) |
| 211 | if generated_pyx_source: |
| 212 | generated_pyx_sources.append(generated_pyx_source) |
| 213 | else: |
| 214 | sys.stderr.write('Cython-generated files are missing...\n') |
| 215 | return False |
| 216 | else: |
| 217 | other_sources.append(source) |
| 218 | extension.sources = generated_pyx_sources + other_sources |
| 219 | sys.stderr.write('Found cython-generated files...\n') |
| 220 | return True |
| 221 | |
Masood Malekghassemi | fd9cc10 | 2016-07-21 14:20:43 -0700 | [diff] [blame] | 222 | |
| 223 | def try_cythonize(extensions, linetracing=False, mandatory=True): |
Masood Malekghassemi | cc79370 | 2017-01-13 19:20:10 -0800 | [diff] [blame] | 224 | """Attempt to cythonize the extensions. |
Masood Malekghassemi | fd9cc10 | 2016-07-21 14:20:43 -0700 | [diff] [blame] | 225 | |
| 226 | Args: |
| 227 | extensions: A list of `distutils.extension.Extension`. |
| 228 | linetracing: A bool indicating whether or not to enable linetracing. |
| 229 | mandatory: Whether or not having Cython-generated files is mandatory. If it |
| 230 | is, extensions will be poisoned when they can't be fully generated. |
| 231 | """ |
Masood Malekghassemi | cc79370 | 2017-01-13 19:20:10 -0800 | [diff] [blame] | 232 | try: |
| 233 | # Break import style to ensure we have access to Cython post-setup_requires |
| 234 | import Cython.Build |
| 235 | except ImportError: |
| 236 | if mandatory: |
| 237 | sys.stderr.write( |
| 238 | "This package needs to generate C files with Cython but it cannot. " |
| 239 | "Poisoning extension sources to disallow extension commands...") |
| 240 | _poison_extensions( |
| 241 | extensions, |
| 242 | "Extensions have been poisoned due to missing Cython-generated code." |
| 243 | ) |
| 244 | return extensions |
| 245 | cython_compiler_directives = {} |
| 246 | if linetracing: |
| 247 | additional_define_macros = [('CYTHON_TRACE_NOGIL', '1')] |
| 248 | cython_compiler_directives['linetrace'] = True |
| 249 | return Cython.Build.cythonize( |
| 250 | extensions, |
| 251 | include_path=[ |
| 252 | include_dir |
| 253 | for extension in extensions |
| 254 | for include_dir in extension.include_dirs |
| 255 | ] + [CYTHON_STEM], |
| 256 | compiler_directives=cython_compiler_directives) |
Masood Malekghassemi | fd9cc10 | 2016-07-21 14:20:43 -0700 | [diff] [blame] | 257 | |
| 258 | |
Masood Malekghassemi | 14a0a93 | 2016-01-21 20:13:22 -0800 | [diff] [blame] | 259 | class BuildExt(build_ext.build_ext): |
Masood Malekghassemi | cc79370 | 2017-01-13 19:20:10 -0800 | [diff] [blame] | 260 | """Custom build_ext command to enable compiler-specific flags.""" |
Masood Malekghassemi | 1d17781 | 2016-01-12 09:21:57 -0800 | [diff] [blame] | 261 | |
Masood Malekghassemi | cc79370 | 2017-01-13 19:20:10 -0800 | [diff] [blame] | 262 | C_OPTIONS = { |
| 263 | 'unix': ('-pthread', '-std=gnu99'), |
| 264 | 'msvc': (), |
| 265 | } |
| 266 | LINK_OPTIONS = {} |
Masood Malekghassemi | 1d17781 | 2016-01-12 09:21:57 -0800 | [diff] [blame] | 267 | |
Masood Malekghassemi | cc79370 | 2017-01-13 19:20:10 -0800 | [diff] [blame] | 268 | def build_extensions(self): |
| 269 | compiler = self.compiler.compiler_type |
| 270 | if compiler in BuildExt.C_OPTIONS: |
| 271 | for extension in self.extensions: |
Masood Malekghassemi | 6b890d1 | 2017-01-23 12:02:08 -0500 | [diff] [blame] | 272 | extension.extra_compile_args += list( |
| 273 | BuildExt.C_OPTIONS[compiler]) |
Masood Malekghassemi | cc79370 | 2017-01-13 19:20:10 -0800 | [diff] [blame] | 274 | if compiler in BuildExt.LINK_OPTIONS: |
| 275 | for extension in self.extensions: |
Masood Malekghassemi | 6b890d1 | 2017-01-23 12:02:08 -0500 | [diff] [blame] | 276 | extension.extra_link_args += list( |
| 277 | BuildExt.LINK_OPTIONS[compiler]) |
Masood Malekghassemi | cc79370 | 2017-01-13 19:20:10 -0800 | [diff] [blame] | 278 | if not check_and_update_cythonization(self.extensions): |
| 279 | self.extensions = try_cythonize(self.extensions) |
| 280 | try: |
| 281 | build_ext.build_ext.build_extensions(self) |
| 282 | except Exception as error: |
| 283 | formatted_exception = traceback.format_exc() |
| 284 | support.diagnose_build_ext_error(self, error, formatted_exception) |
Masood Malekghassemi | 6b890d1 | 2017-01-23 12:02:08 -0500 | [diff] [blame] | 285 | raise CommandError( |
| 286 | "Failed `build_ext` step:\n{}".format(formatted_exception)) |
Masood Malekghassemi | 1d17781 | 2016-01-12 09:21:57 -0800 | [diff] [blame] | 287 | |
| 288 | |
Masood Malekghassemi | 7566c9a | 2015-10-21 20:29:23 -0700 | [diff] [blame] | 289 | class Gather(setuptools.Command): |
Masood Malekghassemi | cc79370 | 2017-01-13 19:20:10 -0800 | [diff] [blame] | 290 | """Command to gather project dependencies.""" |
Masood Malekghassemi | 7566c9a | 2015-10-21 20:29:23 -0700 | [diff] [blame] | 291 | |
Masood Malekghassemi | cc79370 | 2017-01-13 19:20:10 -0800 | [diff] [blame] | 292 | description = 'gather dependencies for grpcio' |
| 293 | user_options = [ |
| 294 | ('test', 't', 'flag indicating to gather test dependencies'), |
| 295 | ('install', 'i', 'flag indicating to gather install dependencies') |
| 296 | ] |
Masood Malekghassemi | 7566c9a | 2015-10-21 20:29:23 -0700 | [diff] [blame] | 297 | |
Masood Malekghassemi | cc79370 | 2017-01-13 19:20:10 -0800 | [diff] [blame] | 298 | def initialize_options(self): |
| 299 | self.test = False |
| 300 | self.install = False |
Masood Malekghassemi | 7566c9a | 2015-10-21 20:29:23 -0700 | [diff] [blame] | 301 | |
Masood Malekghassemi | cc79370 | 2017-01-13 19:20:10 -0800 | [diff] [blame] | 302 | def finalize_options(self): |
| 303 | # distutils requires this override. |
| 304 | pass |
Masood Malekghassemi | 7566c9a | 2015-10-21 20:29:23 -0700 | [diff] [blame] | 305 | |
Masood Malekghassemi | cc79370 | 2017-01-13 19:20:10 -0800 | [diff] [blame] | 306 | def run(self): |
| 307 | if self.install and self.distribution.install_requires: |
| 308 | self.distribution.fetch_build_eggs( |
| 309 | self.distribution.install_requires) |
| 310 | if self.test and self.distribution.tests_require: |
| 311 | self.distribution.fetch_build_eggs(self.distribution.tests_require) |