OLD | NEW |
1 #! /usr/bin/python | 1 #! /usr/bin/python |
2 # | 2 # |
3 # See README for usage instructions. | 3 # See README for usage instructions. |
4 | 4 |
5 # We must use setuptools, not distutils, because we need to use the | 5 # We must use setuptools, not distutils, because we need to use the |
6 # namespace_packages option for the "google" package. | 6 # namespace_packages option for the "google" package. |
7 from ez_setup import use_setuptools | 7 from ez_setup import use_setuptools |
8 use_setuptools() | 8 use_setuptools() |
9 | 9 |
10 from setuptools import setup | 10 from setuptools import setup, Extension |
11 from distutils.spawn import find_executable | 11 from distutils.spawn import find_executable |
12 import sys | 12 import sys |
13 import os | 13 import os |
14 import subprocess | 14 import subprocess |
15 | 15 |
16 maintainer_email = "protobuf@googlegroups.com" | 16 maintainer_email = "protobuf@googlegroups.com" |
17 | 17 |
18 # Find the Protocol Compiler. | 18 # Find the Protocol Compiler. |
19 if os.path.exists("../src/protoc"): | 19 if os.path.exists("../src/protoc"): |
20 protoc = "../src/protoc" | 20 protoc = "../src/protoc" |
21 elif os.path.exists("../src/protoc.exe"): | 21 elif os.path.exists("../src/protoc.exe"): |
22 protoc = "../src/protoc.exe" | 22 protoc = "../src/protoc.exe" |
| 23 elif os.path.exists("../vsprojects/Debug/protoc.exe"): |
| 24 protoc = "../vsprojects/Debug/protoc.exe" |
| 25 elif os.path.exists("../vsprojects/Release/protoc.exe"): |
| 26 protoc = "../vsprojects/Release/protoc.exe" |
23 else: | 27 else: |
24 protoc = find_executable("protoc") | 28 protoc = find_executable("protoc") |
25 | 29 |
26 def generate_proto(source): | 30 def generate_proto(source): |
27 """Invokes the Protocol Compiler to generate a _pb2.py from the given | 31 """Invokes the Protocol Compiler to generate a _pb2.py from the given |
28 .proto file. Does nothing if the output already exists and is newer than | 32 .proto file. Does nothing if the output already exists and is newer than |
29 the input.""" | 33 the input.""" |
30 | 34 |
31 output = source.replace(".proto", "_pb2.py").replace("../src/", "") | 35 output = source.replace(".proto", "_pb2.py").replace("../src/", "") |
32 | 36 |
(...skipping 16 matching lines...) Expand all Loading... |
49 if subprocess.call(protoc_command) != 0: | 53 if subprocess.call(protoc_command) != 0: |
50 sys.exit(-1) | 54 sys.exit(-1) |
51 | 55 |
52 def MakeTestSuite(): | 56 def MakeTestSuite(): |
53 # This is apparently needed on some systems to make sure that the tests | 57 # This is apparently needed on some systems to make sure that the tests |
54 # work even if a previous version is already installed. | 58 # work even if a previous version is already installed. |
55 if 'google' in sys.modules: | 59 if 'google' in sys.modules: |
56 del sys.modules['google'] | 60 del sys.modules['google'] |
57 | 61 |
58 generate_proto("../src/google/protobuf/unittest.proto") | 62 generate_proto("../src/google/protobuf/unittest.proto") |
| 63 generate_proto("../src/google/protobuf/unittest_custom_options.proto") |
59 generate_proto("../src/google/protobuf/unittest_import.proto") | 64 generate_proto("../src/google/protobuf/unittest_import.proto") |
60 generate_proto("../src/google/protobuf/unittest_mset.proto") | 65 generate_proto("../src/google/protobuf/unittest_mset.proto") |
61 generate_proto("../src/google/protobuf/unittest_no_generic_services.proto") | 66 generate_proto("../src/google/protobuf/unittest_no_generic_services.proto") |
62 generate_proto("google/protobuf/internal/more_extensions.proto") | 67 generate_proto("google/protobuf/internal/more_extensions.proto") |
63 generate_proto("google/protobuf/internal/more_messages.proto") | 68 generate_proto("google/protobuf/internal/more_messages.proto") |
64 | 69 |
65 import unittest | 70 import unittest |
66 import google.protobuf.internal.generator_test as generator_test | 71 import google.protobuf.internal.generator_test as generator_test |
67 import google.protobuf.internal.descriptor_test as descriptor_test | 72 import google.protobuf.internal.descriptor_test as descriptor_test |
68 import google.protobuf.internal.reflection_test as reflection_test | 73 import google.protobuf.internal.reflection_test as reflection_test |
(...skipping 14 matching lines...) Expand all Loading... |
83 | 88 |
84 return suite | 89 return suite |
85 | 90 |
86 if __name__ == '__main__': | 91 if __name__ == '__main__': |
87 # TODO(kenton): Integrate this into setuptools somehow? | 92 # TODO(kenton): Integrate this into setuptools somehow? |
88 if len(sys.argv) >= 2 and sys.argv[1] == "clean": | 93 if len(sys.argv) >= 2 and sys.argv[1] == "clean": |
89 # Delete generated _pb2.py files and .pyc files in the code tree. | 94 # Delete generated _pb2.py files and .pyc files in the code tree. |
90 for (dirpath, dirnames, filenames) in os.walk("."): | 95 for (dirpath, dirnames, filenames) in os.walk("."): |
91 for filename in filenames: | 96 for filename in filenames: |
92 filepath = os.path.join(dirpath, filename) | 97 filepath = os.path.join(dirpath, filename) |
93 if filepath.endswith("_pb2.py") or filepath.endswith(".pyc"): | 98 if filepath.endswith("_pb2.py") or filepath.endswith(".pyc") or \ |
| 99 filepath.endswith(".so") or filepath.endswith(".o"): |
94 os.remove(filepath) | 100 os.remove(filepath) |
95 else: | 101 else: |
96 # Generate necessary .proto file if it doesn't exist. | 102 # Generate necessary .proto file if it doesn't exist. |
97 # TODO(kenton): Maybe we should hook this into a distutils command? | 103 # TODO(kenton): Maybe we should hook this into a distutils command? |
98 generate_proto("../src/google/protobuf/descriptor.proto") | 104 generate_proto("../src/google/protobuf/descriptor.proto") |
| 105 generate_proto("../src/google/protobuf/compiler/plugin.proto") |
| 106 |
| 107 ext_module_list = [] |
| 108 |
| 109 # C++ implementation extension |
| 110 if os.getenv("PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION", "python") == "cpp": |
| 111 print "Using EXPERIMENTAL C++ Implmenetation." |
| 112 ext_module_list.append(Extension( |
| 113 "google.protobuf.internal._net_proto2___python", |
| 114 [ "google/protobuf/pyext/python_descriptor.cc", |
| 115 "google/protobuf/pyext/python_protobuf.cc", |
| 116 "google/protobuf/pyext/python-proto2.cc" ], |
| 117 include_dirs = [ "../src", ".", ], |
| 118 libraries = [ "protobuf" ], |
| 119 runtime_library_dirs = [ "../src/.libs" ], |
| 120 library_dirs = [ "../src/.libs" ])) |
99 | 121 |
100 setup(name = 'protobuf', | 122 setup(name = 'protobuf', |
101 version = '2.3.1-pre', | 123 version = '2.4.0-pre', |
102 packages = [ 'google' ], | 124 packages = [ 'google' ], |
103 namespace_packages = [ 'google' ], | 125 namespace_packages = [ 'google' ], |
104 test_suite = 'setup.MakeTestSuite', | 126 test_suite = 'setup.MakeTestSuite', |
105 # Must list modules explicitly so that we don't install tests. | 127 # Must list modules explicitly so that we don't install tests. |
106 py_modules = [ | 128 py_modules = [ |
| 129 'google.protobuf.internal.api_implementation', |
107 'google.protobuf.internal.containers', | 130 'google.protobuf.internal.containers', |
| 131 'google.protobuf.internal.cpp_message', |
108 'google.protobuf.internal.decoder', | 132 'google.protobuf.internal.decoder', |
109 'google.protobuf.internal.encoder', | 133 'google.protobuf.internal.encoder', |
110 'google.protobuf.internal.message_listener', | 134 'google.protobuf.internal.message_listener', |
| 135 'google.protobuf.internal.python_message', |
111 'google.protobuf.internal.type_checkers', | 136 'google.protobuf.internal.type_checkers', |
112 'google.protobuf.internal.wire_format', | 137 'google.protobuf.internal.wire_format', |
113 'google.protobuf.descriptor', | 138 'google.protobuf.descriptor', |
114 'google.protobuf.descriptor_pb2', | 139 'google.protobuf.descriptor_pb2', |
| 140 'google.protobuf.compiler.plugin_pb2', |
115 'google.protobuf.message', | 141 'google.protobuf.message', |
116 'google.protobuf.reflection', | 142 'google.protobuf.reflection', |
117 'google.protobuf.service', | 143 'google.protobuf.service', |
118 'google.protobuf.service_reflection', | 144 'google.protobuf.service_reflection', |
119 'google.protobuf.text_format' ], | 145 'google.protobuf.text_format' ], |
| 146 ext_modules = ext_module_list, |
120 url = 'http://code.google.com/p/protobuf/', | 147 url = 'http://code.google.com/p/protobuf/', |
121 maintainer = maintainer_email, | 148 maintainer = maintainer_email, |
122 maintainer_email = 'protobuf@googlegroups.com', | 149 maintainer_email = 'protobuf@googlegroups.com', |
123 license = 'New BSD License', | 150 license = 'New BSD License', |
124 description = 'Protocol Buffers', | 151 description = 'Protocol Buffers', |
125 long_description = | 152 long_description = |
126 "Protocol Buffers are Google's data interchange format.", | 153 "Protocol Buffers are Google's data interchange format.", |
127 ) | 154 ) |
OLD | NEW |