blob: 57acfd94d688b6edba4eab9ab0e1f65b5548476c [file] [log] [blame] [view]
temporal40ee5512008-07-10 02:12:20 +00001Protocol Buffers - Google's data interchange format
jessecd04e9b2015-03-16 15:15:59 -07002===================================================
3
4[![Build Status](https://travis-ci.org/google/protobuf.svg?branch=master)](https://travis-ci.org/google/protobuf)
5
temporal40ee5512008-07-10 02:12:20 +00006Copyright 2008 Google Inc.
7
8This directory contains the Python Protocol Buffers runtime library.
9
temporalcc930432008-07-21 20:28:30 +000010Normally, this directory comes as part of the protobuf package, available
11from:
12
Feng Xiaoe4288622014-10-01 16:26:23 -070013 https://developers.google.com/protocol-buffers/
temporalcc930432008-07-21 20:28:30 +000014
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
temporal742e4092008-08-27 19:25:48 +000022Development 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
temporal40ee5512008-07-10 02:12:20 +000030Installation
31============
32
Matt Iversen4186d4c2014-12-17 20:11:08 +1100331) Make sure you have Python 2.6 or newer. If in doubt, run:
temporal40ee5512008-07-10 02:12:20 +000034
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:
41
Matt Iversen4186d4c2014-12-17 20:11:08 +110042 https://packaging.python.org/en/latest/installing.html#setup-for-installing-packages
temporal40ee5512008-07-10 02:12:20 +000043
443) Build the C++ code, or install a binary distribution of protoc. If
45 you install a binary distribution, make sure that it is the same
46 version as this package. If in doubt, run:
47
48 $ protoc --version
49
[email protected]a36f1b42013-02-26 17:49:03 +0000504) Build and run the tests:
temporal40ee5512008-07-10 02:12:20 +000051
[email protected]a36f1b42013-02-26 17:49:03 +000052 $ python setup.py build
Tamir Duberstein9f42f5f2015-01-13 14:47:32 -050053 $ python setup.py test
[email protected]1eba9d92014-08-25 20:17:53 +000054
Tamir Dubersteind632bc72015-04-10 15:26:58 -040055 To build, test, and use the C++ implementation, you must first compile
56 libprotobuf.so:
57
58 $ (cd .. && make)
59
60 On OS X:
61
62 If you are running a homebrew-provided python, you must make sure another
63 version of protobuf is not already installed, as homebrew's python will
64 search /usr/local/lib for libprotobuf.so before it searches ../src/.libs
65 You can either unlink homebrew's protobuf or install the libprotobuf you
66 built earlier:
67
68 $ brew unlink protobuf
69 or
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 or
79 $ (cd .. && make install)
80
Josh Haberman2bd813b2015-04-09 16:41:58 -070081 To build the C++ implementation run:
Jisi Liuada65562015-02-25 16:39:11 -080082 $ python setup.py build --cpp_implementation
Josh Haberman2bd813b2015-04-09 16:41:58 -070083
Josh Haberman2bd813b2015-04-09 16:41:58 -070084 Then run the tests like so:
Tamir Duberstein9f42f5f2015-01-13 14:47:32 -050085 $ python setup.py test --cpp_implementation
temporal40ee5512008-07-10 02:12:20 +000086
87 If some tests fail, this library may not work correctly on your
88 system. Continue at your own risk.
89
90 Please note that there is a known problem with some versions of
91 Python on Cygwin which causes the tests to fail after printing the
92 error: "sem_init: Resource temporarily unavailable". This appears
93 to be a bug either in Cygwin or in Python:
94 http://www.cygwin.com/ml/cygwin/2005-07/msg01378.html
95 We do not know if or when it might me fixed. We also do not know
96 how likely it is that this bug will affect users in practice.
97
985) Install:
99
jessecd04e9b2015-03-16 15:15:59 -0700100 $ python setup.py install
101
102 or:
103
Josh Haberman2bd813b2015-04-09 16:41:58 -0700104 $ (cd .. && make install)
jessecd04e9b2015-03-16 15:15:59 -0700105 $ python setup.py install --cpp_implementation
temporal40ee5512008-07-10 02:12:20 +0000106
107 This step may require superuser privileges.
Josh Haberman2bd813b2015-04-09 16:41:58 -0700108 NOTE: To use C++ implementation, you need to export an environment
109 variable before running your program. See the "C++ Implementation"
110 section below for more details.
temporal40ee5512008-07-10 02:12:20 +0000111
112Usage
113=====
114
115The complete documentation for Protocol Buffers is available via the
116web at:
117
Feng Xiaoe4288622014-10-01 16:26:23 -0700118 https://developers.google.com/protocol-buffers/
[email protected]9b7f6c52010-12-08 03:45:27 +0000119
120C++ Implementation
121==================
122
[email protected]9b7f6c52010-12-08 03:45:27 +0000123The C++ implementation for Python messages is built as a Python extension to
124improve the overall protobuf Python performance.
125
Manjunath Kudlurcf828de2016-03-25 10:58:46 -0700126To use the C++ implementation, you need to install the C++ protobuf runtime
127library, please see instructions in the parent directory.