setup.py 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. # Protocol Buffers - Google's data interchange format
  2. # Copyright 2008 Google Inc. All rights reserved.
  3. # https://developers.google.com/protocol-buffers/
  4. #
  5. # Redistribution and use in source and binary forms, with or without
  6. # modification, are permitted provided that the following conditions are
  7. # met:
  8. #
  9. # * Redistributions of source code must retain the above copyright
  10. # notice, this list of conditions and the following disclaimer.
  11. # * Redistributions in binary form must reproduce the above
  12. # copyright notice, this list of conditions and the following disclaimer
  13. # in the documentation and/or other materials provided with the
  14. # distribution.
  15. # * Neither the name of Google Inc. nor the names of its
  16. # contributors may be used to endorse or promote products derived from
  17. # this software without specific prior written permission.
  18. #
  19. # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  20. # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  21. # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  22. # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  23. # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  24. # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  25. # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  26. # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  27. # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  28. # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  29. # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  30. """Setuptools/distutils extension for generating Python protobuf code.
  31. This extension uses a prebuilt 'protoc' binary to generate Python types for
  32. protobuf sources. By default, it will use a system-installed protoc binary, but
  33. a custom protoc can be specified by flag.
  34. This command should usually be run before the 'build' command, so that the
  35. generated sources are treated the same way as the rest of the Python
  36. sources.
  37. Options:
  38. source_dir:
  39. This is the directory holding .proto files to be processed.
  40. The default behavior is to generate sources for all .proto files found
  41. under `source_dir`, recursively. This behavior can be controlled with
  42. options below.
  43. proto_root_path:
  44. This is the root path for resolving imports in source .proto files.
  45. The default is the shortest prefix of `source_dir` among:
  46. [source_dir] + self.extra_proto_paths
  47. extra_proto_paths:
  48. Specifies additional paths that should be used to find imports, in
  49. addition to `source_dir`.
  50. This option can be used to specify the path to other protobuf sources,
  51. which are imported by files under `source_dir`. No Python code will be
  52. generated for .proto files under `extra_proto_paths`.
  53. output_dir:
  54. Specifies where generated code should be placed.
  55. Typically, this should be the root package that generated Python modules
  56. should be below.
  57. The generated files will be named according to the relative source paths
  58. under `proto_root_path`. For example, this source .proto file:
  59. ${proto_root_path}/subdir/message.proto
  60. will correspond to this generated Python module:
  61. ${output_dir}/subdir/message_pb2.py
  62. proto_files:
  63. Specific .proto files can be specified for generating code, instead of
  64. searching for all .proto files under `source_path`.
  65. These paths are relative to `source_dir`. For example, to generate code
  66. for just ${source_dir}/subdir/message.proto, specify
  67. ['subdir/message.proto'].
  68. protoc:
  69. By default, the protoc binary (the Protobuf compiler) is found by
  70. searching the environment path. To use a specific protoc binary, its
  71. path can be specified.
  72. recurse:
  73. If `proto_files` are not specified, then the default behavior is to
  74. search `source_dir` recursively. This option controls the recursive
  75. search; if it is False, only .proto files immediately under `source_dir`
  76. will be used to generate sources.
  77. """
  78. __author__ = 'dlj@google.com (David L. Jones)'
  79. from setuptools import setup, find_packages
  80. setup(
  81. name='protobuf_distutils',
  82. version='1.0',
  83. packages=find_packages(),
  84. maintainer='protobuf@googlegroups.com',
  85. maintainer_email='protobuf@googlegroups.com',
  86. license='3-Clause BSD License',
  87. classifiers=[
  88. "Framework :: Setuptools Plugin",
  89. "Operating System :: OS Independent",
  90. # These Python versions should match the protobuf package:
  91. "Programming Language :: Python",
  92. "Programming Language :: Python :: 2",
  93. "Programming Language :: Python :: 2.7",
  94. "Programming Language :: Python :: 3",
  95. "Programming Language :: Python :: 3.3",
  96. "Programming Language :: Python :: 3.4",
  97. "Programming Language :: Python :: 3.5",
  98. "Programming Language :: Python :: 3.6",
  99. "Programming Language :: Python :: 3.7",
  100. "Programming Language :: Python :: 3.8",
  101. "Topic :: Software Development :: Code Generators",
  102. ],
  103. description=('This is a distutils extension to generate Python code for '
  104. '.proto files using an installed protoc binary.'),
  105. url='https://github.com/protocolbuffers/protobuf/',
  106. entry_points={
  107. 'distutils.commands': [
  108. ('generate_py_protobufs = '
  109. 'protobuf_distutils.generate_py_protobufs:generate_py_protobufs'),
  110. ],
  111. },
  112. )