compatibility_tests/v2.5.0/setup.py
Go to the documentation of this file.
1 #! /usr/bin/env python
2 #
3 import glob
4 import os
5 import subprocess
6 import sys
7 
8 from setuptools import setup, Extension, find_packages
9 
10 if sys.version_info[0] == 3:
11  # Python 3
12  from distutils.command.build_py import build_py_2to3 as _build_py
13 else:
14  # Python 2
15  from distutils.command.build_py import build_py as _build_py
16 from distutils.spawn import find_executable
17 
18 def generate_proto(source, code_gen):
19  """Invokes the Protocol Compiler to generate a _pb2.py from the given
20  .proto file."""
21  output = source.replace(".proto", "_pb2.py").replace("protos/src/proto/", "").replace("protos/python/", "")
22 
23  if not os.path.exists(source):
24  sys.stderr.write("Can't find required file: %s\n" % source)
25  sys.exit(-1)
26 
27  protoc_command = [ code_gen, "-Iprotos/src/proto", "-Iprotos/python", "--python_out=.", source ]
28  if subprocess.call(protoc_command) != 0:
29  sys.exit(-1)
30 
31 class build_py(_build_py):
32  def run(self):
33  # generate .proto file
34  protoc_1 = "./protoc_1"
35  protoc_2 = "./protoc_2"
36  generate_proto("protos/src/proto/google/protobuf/unittest.proto", protoc_2)
37  generate_proto("protos/src/proto/google/protobuf/unittest_custom_options.proto", protoc_1)
38  generate_proto("protos/src/proto/google/protobuf/unittest_import.proto", protoc_1)
39  generate_proto("protos/src/proto/google/protobuf/unittest_import_public.proto", protoc_1)
40  generate_proto("protos/src/proto/google/protobuf/unittest_mset.proto", protoc_1)
41  generate_proto("protos/src/proto/google/protobuf/unittest_no_generic_services.proto", protoc_1)
42  generate_proto("protos/python/google/protobuf/internal/factory_test1.proto", protoc_1)
43  generate_proto("protos/python/google/protobuf/internal/factory_test2.proto", protoc_1)
44  generate_proto("protos/python/google/protobuf/internal/more_extensions.proto", protoc_1)
45  generate_proto("protos/python/google/protobuf/internal/more_extensions_dynamic.proto", protoc_1)
46  generate_proto("protos/python/google/protobuf/internal/more_messages.proto", protoc_1)
47  generate_proto("protos/python/google/protobuf/internal/test_bad_identifiers.proto", protoc_1)
48 
49  # _build_py is an old-style class, so super() doesn't work.
50  _build_py.run(self)
51 
52 if __name__ == '__main__':
53  # Keep this list of dependencies in sync with tox.ini.
54  install_requires = ['six>=1.9', 'setuptools']
55  if sys.version_info <= (2,7):
56  install_requires.append('ordereddict')
57  install_requires.append('unittest2')
58 
59  setup(
60  name='protobuf',
61  description='Protocol Buffers',
62  download_url='https://github.com/protocolbuffers/protobuf/releases',
63  long_description="Protocol Buffers are Google's data interchange format",
64  url='https://developers.google.com/protocol-buffers/',
65  maintainer='protobuf@googlegroups.com',
66  maintainer_email='protobuf@googlegroups.com',
67  license='3-Clause BSD License',
68  classifiers=[
69  "Programming Language :: Python",
70  "Programming Language :: Python :: 2",
71  "Programming Language :: Python :: 2.6",
72  "Programming Language :: Python :: 2.7",
73  "Programming Language :: Python :: 3",
74  "Programming Language :: Python :: 3.3",
75  "Programming Language :: Python :: 3.4",
76  ],
77  packages=find_packages(
78  exclude=[
79  'import_test_package',
80  ],
81  ),
82  test_suite='tests.google.protobuf.internal',
83  cmdclass={
84  'build_py': build_py,
85  },
86  install_requires=install_requires,
87  )
setup
setup.build_py.run
def run(self)
Definition: compatibility_tests/v2.5.0/setup.py:32
setup.generate_proto
def generate_proto(source, code_gen)
Definition: compatibility_tests/v2.5.0/setup.py:18
setup.build_py
Definition: compatibility_tests/v2.5.0/setup.py:31


libaditof
Author(s):
autogenerated on Wed May 21 2025 02:06:58