1*1b3f573fSAndroid Build Coastguard WorkerProtocol Buffers - Google's data interchange format 2*1b3f573fSAndroid Build Coastguard Worker=================================================== 3*1b3f573fSAndroid Build Coastguard Worker 4*1b3f573fSAndroid Build Coastguard WorkerCopyright 2008 Google Inc. 5*1b3f573fSAndroid Build Coastguard Worker 6*1b3f573fSAndroid Build Coastguard WorkerThis directory contains the Python Protocol Buffers runtime library. 7*1b3f573fSAndroid Build Coastguard Worker 8*1b3f573fSAndroid Build Coastguard WorkerNormally, this directory comes as part of the protobuf package, available 9*1b3f573fSAndroid Build Coastguard Workerfrom: 10*1b3f573fSAndroid Build Coastguard Worker 11*1b3f573fSAndroid Build Coastguard Worker https://developers.google.com/protocol-buffers/ 12*1b3f573fSAndroid Build Coastguard Worker 13*1b3f573fSAndroid Build Coastguard WorkerThe complete package includes the C++ source code, which includes the 14*1b3f573fSAndroid Build Coastguard WorkerProtocol Compiler (protoc). If you downloaded this package from PyPI 15*1b3f573fSAndroid Build Coastguard Workeror some other Python-specific source, you may have received only the 16*1b3f573fSAndroid Build Coastguard WorkerPython part of the code. In this case, you will need to obtain the 17*1b3f573fSAndroid Build Coastguard WorkerProtocol Compiler from some other source before you can use this 18*1b3f573fSAndroid Build Coastguard Workerpackage. 19*1b3f573fSAndroid Build Coastguard Worker 20*1b3f573fSAndroid Build Coastguard WorkerDevelopment Warning 21*1b3f573fSAndroid Build Coastguard Worker=================== 22*1b3f573fSAndroid Build Coastguard Worker 23*1b3f573fSAndroid Build Coastguard WorkerThe pure python performance is slow. For better performance please 24*1b3f573fSAndroid Build Coastguard Workeruse python c++ implementation. 25*1b3f573fSAndroid Build Coastguard Worker 26*1b3f573fSAndroid Build Coastguard WorkerInstallation 27*1b3f573fSAndroid Build Coastguard Worker============ 28*1b3f573fSAndroid Build Coastguard Worker 29*1b3f573fSAndroid Build Coastguard Worker1) Make sure you have Python 3.7 or newer. If in doubt, run: 30*1b3f573fSAndroid Build Coastguard Worker 31*1b3f573fSAndroid Build Coastguard Worker $ python -V 32*1b3f573fSAndroid Build Coastguard Worker 33*1b3f573fSAndroid Build Coastguard Worker2) If you do not have setuptools installed, note that it will be 34*1b3f573fSAndroid Build Coastguard Worker downloaded and installed automatically as soon as you run `setup.py`. 35*1b3f573fSAndroid Build Coastguard Worker If you would rather install it manually, you may do so by following 36*1b3f573fSAndroid Build Coastguard Worker the instructions on [this page](https://packaging.python.org/en/latest/installing.html#setup-for-installing-packages). 37*1b3f573fSAndroid Build Coastguard Worker 38*1b3f573fSAndroid Build Coastguard Worker3) Build the C++ code, or install a binary distribution of `protoc`. If 39*1b3f573fSAndroid Build Coastguard Worker you install a binary distribution, make sure that it is the same 40*1b3f573fSAndroid Build Coastguard Worker version as this package. If in doubt, run: 41*1b3f573fSAndroid Build Coastguard Worker 42*1b3f573fSAndroid Build Coastguard Worker $ protoc --version 43*1b3f573fSAndroid Build Coastguard Worker 44*1b3f573fSAndroid Build Coastguard Worker4) Build and run the tests: 45*1b3f573fSAndroid Build Coastguard Worker 46*1b3f573fSAndroid Build Coastguard Worker $ python setup.py build 47*1b3f573fSAndroid Build Coastguard Worker $ python setup.py test 48*1b3f573fSAndroid Build Coastguard Worker 49*1b3f573fSAndroid Build Coastguard Worker To build, test, and use the C++ implementation, you must first compile 50*1b3f573fSAndroid Build Coastguard Worker `libprotobuf.so`: 51*1b3f573fSAndroid Build Coastguard Worker 52*1b3f573fSAndroid Build Coastguard Worker $ (cd .. && make) 53*1b3f573fSAndroid Build Coastguard Worker 54*1b3f573fSAndroid Build Coastguard Worker On OS X: 55*1b3f573fSAndroid Build Coastguard Worker 56*1b3f573fSAndroid Build Coastguard Worker If you are running a Homebrew-provided Python, you must make sure another 57*1b3f573fSAndroid Build Coastguard Worker version of protobuf is not already installed, as Homebrew's Python will 58*1b3f573fSAndroid Build Coastguard Worker search `/usr/local/lib` for `libprotobuf.so` before it searches 59*1b3f573fSAndroid Build Coastguard Worker `../src/.libs`. 60*1b3f573fSAndroid Build Coastguard Worker 61*1b3f573fSAndroid Build Coastguard Worker You can either unlink Homebrew's protobuf or install the `libprotobuf` you 62*1b3f573fSAndroid Build Coastguard Worker built earlier: 63*1b3f573fSAndroid Build Coastguard Worker 64*1b3f573fSAndroid Build Coastguard Worker $ brew unlink protobuf 65*1b3f573fSAndroid Build Coastguard Worker 66*1b3f573fSAndroid Build Coastguard Worker or 67*1b3f573fSAndroid Build Coastguard Worker 68*1b3f573fSAndroid Build Coastguard Worker $ (cd .. && make install) 69*1b3f573fSAndroid Build Coastguard Worker 70*1b3f573fSAndroid Build Coastguard Worker On other *nix: 71*1b3f573fSAndroid Build Coastguard Worker 72*1b3f573fSAndroid Build Coastguard Worker You must make `libprotobuf.so` dynamically available. You can either 73*1b3f573fSAndroid Build Coastguard Worker install libprotobuf you built earlier, or set `LD_LIBRARY_PATH`: 74*1b3f573fSAndroid Build Coastguard Worker 75*1b3f573fSAndroid Build Coastguard Worker $ export LD_LIBRARY_PATH=../src/.libs 76*1b3f573fSAndroid Build Coastguard Worker 77*1b3f573fSAndroid Build Coastguard Worker or 78*1b3f573fSAndroid Build Coastguard Worker 79*1b3f573fSAndroid Build Coastguard Worker $ (cd .. && make install) 80*1b3f573fSAndroid Build Coastguard Worker 81*1b3f573fSAndroid Build Coastguard Worker To build the C++ implementation run: 82*1b3f573fSAndroid Build Coastguard Worker 83*1b3f573fSAndroid Build Coastguard Worker $ python setup.py build --cpp_implementation 84*1b3f573fSAndroid Build Coastguard Worker 85*1b3f573fSAndroid Build Coastguard Worker Then run the tests like so: 86*1b3f573fSAndroid Build Coastguard Worker 87*1b3f573fSAndroid Build Coastguard Worker $ python setup.py test --cpp_implementation 88*1b3f573fSAndroid Build Coastguard Worker 89*1b3f573fSAndroid Build Coastguard Worker If some tests fail, this library may not work correctly on your 90*1b3f573fSAndroid Build Coastguard Worker system. Continue at your own risk. 91*1b3f573fSAndroid Build Coastguard Worker 92*1b3f573fSAndroid Build Coastguard Worker Please note that there is a known problem with some versions of 93*1b3f573fSAndroid Build Coastguard Worker Python on Cygwin which causes the tests to fail after printing the 94*1b3f573fSAndroid Build Coastguard Worker error: `sem_init: Resource temporarily unavailable`. This appears 95*1b3f573fSAndroid Build Coastguard Worker to be a [bug either in Cygwin or in 96*1b3f573fSAndroid Build Coastguard Worker Python](http://www.cygwin.com/ml/cygwin/2005-07/msg01378.html). 97*1b3f573fSAndroid Build Coastguard Worker 98*1b3f573fSAndroid Build Coastguard Worker We do not know if or when it might be fixed. We also do not know 99*1b3f573fSAndroid Build Coastguard Worker how likely it is that this bug will affect users in practice. 100*1b3f573fSAndroid Build Coastguard Worker 101*1b3f573fSAndroid Build Coastguard Worker5) Install: 102*1b3f573fSAndroid Build Coastguard Worker 103*1b3f573fSAndroid Build Coastguard Worker $ python setup.py install 104*1b3f573fSAndroid Build Coastguard Worker 105*1b3f573fSAndroid Build Coastguard Worker or: 106*1b3f573fSAndroid Build Coastguard Worker 107*1b3f573fSAndroid Build Coastguard Worker $ (cd .. && make install) 108*1b3f573fSAndroid Build Coastguard Worker $ python setup.py install --cpp_implementation 109*1b3f573fSAndroid Build Coastguard Worker 110*1b3f573fSAndroid Build Coastguard Worker This step may require superuser privileges. 111*1b3f573fSAndroid Build Coastguard Worker NOTE: To use C++ implementation, you need to export an environment 112*1b3f573fSAndroid Build Coastguard Worker variable before running your program. See the "C++ Implementation" 113*1b3f573fSAndroid Build Coastguard Worker section below for more details. 114*1b3f573fSAndroid Build Coastguard Worker 115*1b3f573fSAndroid Build Coastguard WorkerUsage 116*1b3f573fSAndroid Build Coastguard Worker===== 117*1b3f573fSAndroid Build Coastguard Worker 118*1b3f573fSAndroid Build Coastguard WorkerThe complete documentation for Protocol Buffers is available via the 119*1b3f573fSAndroid Build Coastguard Workerweb at: 120*1b3f573fSAndroid Build Coastguard Worker 121*1b3f573fSAndroid Build Coastguard Worker https://developers.google.com/protocol-buffers/ 122*1b3f573fSAndroid Build Coastguard Worker 123*1b3f573fSAndroid Build Coastguard WorkerC++ Implementation 124*1b3f573fSAndroid Build Coastguard Worker================== 125*1b3f573fSAndroid Build Coastguard Worker 126*1b3f573fSAndroid Build Coastguard WorkerThe C++ implementation for Python messages is built as a Python extension to 127*1b3f573fSAndroid Build Coastguard Workerimprove the overall protobuf Python performance. 128*1b3f573fSAndroid Build Coastguard Worker 129*1b3f573fSAndroid Build Coastguard WorkerTo use the C++ implementation, you need to install the C++ protobuf runtime 130*1b3f573fSAndroid Build Coastguard Workerlibrary, please see instructions in the parent directory. 131