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