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 Python implementation of Protocol Buffers is not as mature as the C++ 26and Java implementations. It may be more buggy, and it is known to be 27pretty slow at this time. If you would like to help fix these issues, 28join the Protocol Buffers discussion list and let us know! 29 30Installation 31============ 32 331) Make sure you have Python 2.7 or newer. If in doubt, run: 34 35 $ python -V 36 372) If you do not have setuptools installed, note that it will be 38 downloaded and installed automatically as soon as you run `setup.py`. 39 If you would rather install it manually, you may do so by following 40 the instructions on [this page](https://packaging.python.org/en/latest/installing.html#setup-for-installing-packages). 41 423) Build the C++ code, or install a binary distribution of `protoc`. If 43 you install a binary distribution, make sure that it is the same 44 version as this package. If in doubt, run: 45 46 $ protoc --version 47 484) Build and run the tests: 49 50 $ python setup.py build 51 $ python setup.py test 52 53 To build, test, and use the C++ implementation, you must first compile 54 `libprotobuf.so`: 55 56 $ (cd .. && make) 57 58 On OS X: 59 60 If you are running a Homebrew-provided Python, you must make sure another 61 version of protobuf is not already installed, as Homebrew's Python will 62 search `/usr/local/lib` for `libprotobuf.so` before it searches 63 `../src/.libs`. 64 65 You can either unlink Homebrew's protobuf or install the `libprotobuf` you 66 built earlier: 67 68 $ brew unlink protobuf 69 70 or 71 72 $ (cd .. && make install) 73 74 On other *nix: 75 76 You must make `libprotobuf.so` dynamically available. You can either 77 install libprotobuf you built earlier, or set `LD_LIBRARY_PATH`: 78 79 $ export LD_LIBRARY_PATH=../src/.libs 80 81 or 82 83 $ (cd .. && make install) 84 85 To build the C++ implementation run: 86 87 $ python setup.py build --cpp_implementation 88 89 Then run the tests like so: 90 91 $ python setup.py test --cpp_implementation 92 93 If some tests fail, this library may not work correctly on your 94 system. Continue at your own risk. 95 96 Please note that there is a known problem with some versions of 97 Python on Cygwin which causes the tests to fail after printing the 98 error: `sem_init: Resource temporarily unavailable`. This appears 99 to be a [bug either in Cygwin or in 100 Python](http://www.cygwin.com/ml/cygwin/2005-07/msg01378.html). 101 102 We do not know if or when it might be fixed. We also do not know 103 how likely it is that this bug will affect users in practice. 104 1055) Install: 106 107 $ python setup.py install 108 109 or: 110 111 $ (cd .. && make install) 112 $ python setup.py install --cpp_implementation 113 114 This step may require superuser privileges. 115 NOTE: To use C++ implementation, you need to export an environment 116 variable before running your program. See the "C++ Implementation" 117 section below for more details. 118 119Usage 120===== 121 122The complete documentation for Protocol Buffers is available via the 123web at: 124 125 https://developers.google.com/protocol-buffers/ 126 127C++ Implementation 128================== 129 130The C++ implementation for Python messages is built as a Python extension to 131improve the overall protobuf Python performance. 132 133To use the C++ implementation, you need to install the C++ protobuf runtime 134library, please see instructions in the parent directory. 135