reflection_commands.py
Go to the documentation of this file.
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 """Provides distutils command classes for the GRPC Python setup process."""
15 
16 import os
17 import shutil
18 
19 import setuptools
20 
21 ROOT_DIR = os.path.abspath(os.path.dirname(os.path.abspath(__file__)))
22 REFLECTION_PROTO = os.path.join(
23  ROOT_DIR, '../../proto/grpc/reflection/v1alpha/reflection.proto')
24 LICENSE = os.path.join(ROOT_DIR, '../../../LICENSE')
25 
26 
27 class Preprocess(setuptools.Command):
28  """Command to copy proto modules from grpc/src/proto and LICENSE from
29  the root directory"""
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  if os.path.isfile(REFLECTION_PROTO):
42  shutil.copyfile(
43  REFLECTION_PROTO,
44  os.path.join(ROOT_DIR,
45  'grpc_reflection/v1alpha/reflection.proto'))
46  if os.path.isfile(LICENSE):
47  shutil.copyfile(LICENSE, os.path.join(ROOT_DIR, 'LICENSE'))
48 
49 
50 class BuildPackageProtos(setuptools.Command):
51  """Command to generate project *_pb2.py modules from proto files."""
52 
53  description = 'build grpc protobuf modules'
54  user_options = []
55 
56  def initialize_options(self):
57  pass
58 
59  def finalize_options(self):
60  pass
61 
62  def run(self):
63  # due to limitations of the proto generator, we require that only *one*
64  # directory is provided as an 'include' directory. We assume it's the '' key
65  # to `self.distribution.package_dir` (and get a key error if it's not
66  # there).
67  from grpc_tools import command
68  command.build_package_protos(self.distribution.package_dir[''])
reflection_commands.Preprocess.finalize_options
def finalize_options(self)
Definition: reflection_commands.py:37
reflection_commands.BuildPackageProtos.run
def run(self)
Definition: reflection_commands.py:62
reflection_commands.Preprocess
Definition: reflection_commands.py:27
reflection_commands.Preprocess.run
def run(self)
Definition: reflection_commands.py:40
reflection_commands.BuildPackageProtos
Definition: reflection_commands.py:50
reflection_commands.BuildPackageProtos.finalize_options
def finalize_options(self)
Definition: reflection_commands.py:59
reflection_commands.Preprocess.initialize_options
def initialize_options(self)
Definition: reflection_commands.py:34
reflection_commands.BuildPackageProtos.initialize_options
def initialize_options(self)
Definition: reflection_commands.py:56


grpc
Author(s):
autogenerated on Thu Mar 13 2025 03:01:07