| temporal | 40ee551 | 2008-07-10 02:12:20 +0000 | [diff] [blame] | 1 | Protocol Buffers - Google's data interchange format |
| 2 | Copyright 2008 Google Inc. |
| 3 | |
| 4 | This directory contains the Python Protocol Buffers runtime library. |
| 5 | |
| temporal | cc93043 | 2008-07-21 20:28:30 +0000 | [diff] [blame] | 6 | Normally, this directory comes as part of the protobuf package, available |
| 7 | from: |
| 8 | |
| Feng Xiao | e428862 | 2014-10-01 16:26:23 -0700 | [diff] [blame^] | 9 | https://developers.google.com/protocol-buffers/ |
| temporal | cc93043 | 2008-07-21 20:28:30 +0000 | [diff] [blame] | 10 | |
| 11 | The complete package includes the C++ source code, which includes the |
| 12 | Protocol Compiler (protoc). If you downloaded this package from PyPI |
| 13 | or some other Python-specific source, you may have received only the |
| 14 | Python part of the code. In this case, you will need to obtain the |
| 15 | Protocol Compiler from some other source before you can use this |
| 16 | package. |
| 17 | |
| temporal | 742e409 | 2008-08-27 19:25:48 +0000 | [diff] [blame] | 18 | Development Warning |
| 19 | =================== |
| 20 | |
| 21 | The Python implementation of Protocol Buffers is not as mature as the C++ |
| 22 | and Java implementations. It may be more buggy, and it is known to be |
| 23 | pretty slow at this time. If you would like to help fix these issues, |
| 24 | join the Protocol Buffers discussion list and let us know! |
| 25 | |
| temporal | 40ee551 | 2008-07-10 02:12:20 +0000 | [diff] [blame] | 26 | Installation |
| 27 | ============ |
| 28 | |
| 29 | 1) Make sure you have Python 2.4 or newer. If in doubt, run: |
| 30 | |
| 31 | $ python -V |
| 32 | |
| 33 | 2) If you do not have setuptools installed, note that it will be |
| 34 | downloaded and installed automatically as soon as you run setup.py. |
| 35 | If you would rather install it manually, you may do so by following |
| 36 | the instructions on this page: |
| 37 | |
| 38 | http://peak.telecommunity.com/DevCenter/EasyInstall#installation-instructions |
| 39 | |
| 40 | 3) 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 | |
| xiaofeng@google.com | a36f1b4 | 2013-02-26 17:49:03 +0000 | [diff] [blame] | 46 | 4) Build and run the tests: |
| temporal | 40ee551 | 2008-07-10 02:12:20 +0000 | [diff] [blame] | 47 | |
| xiaofeng@google.com | a36f1b4 | 2013-02-26 17:49:03 +0000 | [diff] [blame] | 48 | $ python setup.py build |
| jieluo@google.com | 5dd5f0d | 2014-08-13 23:26:54 +0000 | [diff] [blame] | 49 | $ python setup.py google_test |
| jieluo@google.com | 1eba9d9 | 2014-08-25 20:17:53 +0000 | [diff] [blame] | 50 | |
| jieluo@google.com | a21bf2e | 2014-08-25 23:26:40 +0000 | [diff] [blame] | 51 | If you want to test c++ implementation, run: |
| 52 | $ python setup.py test --cpp_implementation |
| temporal | 40ee551 | 2008-07-10 02:12:20 +0000 | [diff] [blame] | 53 | |
| 54 | If some tests fail, this library may not work correctly on your |
| 55 | system. Continue at your own risk. |
| 56 | |
| 57 | Please note that there is a known problem with some versions of |
| 58 | Python on Cygwin which causes the tests to fail after printing the |
| 59 | error: "sem_init: Resource temporarily unavailable". This appears |
| 60 | to be a bug either in Cygwin or in Python: |
| 61 | http://www.cygwin.com/ml/cygwin/2005-07/msg01378.html |
| 62 | We do not know if or when it might me fixed. We also do not know |
| 63 | how likely it is that this bug will affect users in practice. |
| 64 | |
| 65 | 5) Install: |
| 66 | |
| 67 | $ python setup.py install |
| jieluo@google.com | 5dd5f0d | 2014-08-13 23:26:54 +0000 | [diff] [blame] | 68 | or: |
| jieluo@google.com | a21bf2e | 2014-08-25 23:26:40 +0000 | [diff] [blame] | 69 | $ python setup.py install --cpp_implementation |
| temporal | 40ee551 | 2008-07-10 02:12:20 +0000 | [diff] [blame] | 70 | |
| 71 | This step may require superuser privileges. |
| liujisi@google.com | 03aaa04 | 2011-04-29 02:12:48 +0000 | [diff] [blame] | 72 | NOTE: To use C++ implementation, you need to install C++ protobuf runtime |
| 73 | library of the same version and export the environment variable before this |
| 74 | step. See the "C++ Implementation" section below for more details. |
| temporal | 40ee551 | 2008-07-10 02:12:20 +0000 | [diff] [blame] | 75 | |
| 76 | Usage |
| 77 | ===== |
| 78 | |
| 79 | The complete documentation for Protocol Buffers is available via the |
| 80 | web at: |
| 81 | |
| Feng Xiao | e428862 | 2014-10-01 16:26:23 -0700 | [diff] [blame^] | 82 | https://developers.google.com/protocol-buffers/ |
| liujisi@google.com | 9b7f6c5 | 2010-12-08 03:45:27 +0000 | [diff] [blame] | 83 | |
| 84 | C++ Implementation |
| 85 | ================== |
| 86 | |
| liujisi@google.com | 9b7f6c5 | 2010-12-08 03:45:27 +0000 | [diff] [blame] | 87 | The C++ implementation for Python messages is built as a Python extension to |
| 88 | improve the overall protobuf Python performance. |
| 89 | |
| liujisi@google.com | 03aaa04 | 2011-04-29 02:12:48 +0000 | [diff] [blame] | 90 | To use the C++ implementation, you need to: |
| 91 | 1) Install the C++ protobuf runtime library, please see instructions in the |
| 92 | parent directory. |
| 93 | 2) Export an environment variable: |
| liujisi@google.com | 9b7f6c5 | 2010-12-08 03:45:27 +0000 | [diff] [blame] | 94 | |
| 95 | $ export PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION=cpp |
| jieluo@google.com | bde4a32 | 2014-08-12 21:10:30 +0000 | [diff] [blame] | 96 | $ export PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION_VERSION=2 |
| liujisi@google.com | 9b7f6c5 | 2010-12-08 03:45:27 +0000 | [diff] [blame] | 97 | |
| 98 | You need to export this variable before running setup.py script to build and |
| 99 | install the extension. You must also set the variable at runtime, otherwise |
| 100 | the pure-Python implementation will be used. In a future release, we will |
| 101 | change the default so that C++ implementation is used whenever it is available. |
| jieluo@google.com | 1eba9d9 | 2014-08-25 20:17:53 +0000 | [diff] [blame] | 102 | It is strongly recommended to run `python setup.py test` after setting the |
| liujisi@google.com | 9b7f6c5 | 2010-12-08 03:45:27 +0000 | [diff] [blame] | 103 | variable to "cpp", so the tests will be against C++ implemented Python |
| 104 | messages. |
| 105 | |