Debian Codegraph @

README.rst

raw
1 About
2 =====
3 PyBindGen is (surprise!) a python bindings generator. The main features are:
4
5 * Generates clean C or C++ code, nearly as readable as code written
6 manually by a developer;
7 * Generated code is self contained and does not require any external
8 libraries or macros; after generating the python module only python
9 header files are required, nothing else;
10 * Does not require Boost.Python (no C++ template magic, also works in C);
11 * The interface for code generation is a simple Python API, not some
12 obscure interface definition language. Additionally PyBindGen can
13 parse header files with gccxml, if gccxml and pygccxml are
14 installed in the system (note: pygccxml has not been ported to Python 3 yet);
15 * Can be easily extended with new type handlers;
16 * Type handlers can allocate memory and register cleanup code to free;
17 * Supports in, out, and inout parameters (e.g. with pointers or C++ references);
18 * Supports multiple return values (e.g. due to out/inout parameters);
19 * Supports wrapping of simple C++ classes;
20 * Supports virtual methods in classes;
21 * Supports reference counted classes and, to some extent, smart pointers;
22 * Multiple inheritance;
23 * Wrapping templated classes;
24
25 Notable features NOT implemented:
26
27 * Converting exceptions from Python to C++ (only from C++ to Python is currently supported);
28 * Callbacks.
29
30 Supported Python versions
31 =========================
32
33 See the `documentation <http://pybindgen.readthedocs.org/en/latest/tutorial/#supported-python-versions>`_.
34
35 Installation
36 ============
37
38 NOTE: if checking out pybindgen from bazaar, do not forget to see the
39 file HACKING for additional instructions.
40
41 Before proceeding make sure the system requirements are met. PyBindGen requires:
42
43 1. Python (http://www.python.org)
44 2. Python development files (the `python-dev` package in Ubuntu/Debian, for example)
45 3. A C/C++ Compilation tool-chain (`apt-get install build-essential`)
46 4. (optional) GCCXML and `PyGCCXML <http://www.language-binding.net/pygccxml/download.html>`_
47
48 You can install PyBindGen using either the `setup.py` or WAF. Note: to
49 be able to run all tests, which involve code generation, and
50 subsequent compilation, you need to use WAF.
51
52 Installation using setup.py:
53 ----------------------------
54
55 python setup.py install
56
57 Installation using WAF
58 ----------------------
59
60 PyBindGen uses `WAF <http://code.google.com/p/waf/>`_ as main build system.
61 However, WAF does not have to be previously installed, as it is
62 shipped with PyBindGen in a single `waf` script.
63
64 To install PyBindGen, issue the following commands (win32 users should omit the ./ prefix in commands):
65
66 1. ./waf configure
67 - optionally you may add the option --prefix /foo/bar. To select a non-defaul python version, use the PYTHON environment variable, e.g.::
68
69 PYTHON=/usr/bin/python2.4 ./waf configure
70
71 2. ./waf
72 - possible options: `-jN` for parallel build, `-p` for progress bar
73 3. ./waf check
74 - optional step, runs the unit tests
75 4. ./waf --examples
76 - optional step, compiles the examples
77 5. ./waf install
78 - may require sudo
79
80
81 Windows specific notes
82 ----------------------
83
84 WAF concurrency bugs
85 ++++++++++++++++++++
86
87
88 WAF automatically detects the number of cores and tries to activate
89 multiple build threads accordingly. However, this concurrency support
90 appears to be buggy on Windows, therefore you should disable it with the
91 -j1 option, if you have multiple CPUs:
92
93 waf check -j1
94
95 Compiler selection
96 ++++++++++++++++++
97
98 Note that if you are compiling on win32, WAF will look for MSVC
99 (MicroSoft Visual C) by default and give up on finding a C/C++
100 compiler if not found. If you do not have MSVC installed but instead
101 have MinGW or CygWin GCC, you have to tell WAF to look for GCC in the
102 configure stage:
103
104 waf configure --check-c-compiler=gcc --check-cxx-compiler=g++
105
106 Installation
107 ++++++++++++
108
109 On win32, `waf install` installs to a Temp folder by default. To have
110 it install for a certain Python version, use the --prefix option to
111 waf configure. For instance:
112
113 waf configure --prefix C:\Python26
114 waf install
115
116
117
118 Installation failsafe
119 ---------------------
120
121 If by any chance you have trouble with WAF and are just looking to
122 install PyBindGen, you should know that PyBindGen is entirely
123 self-contained in the `pybindgen` directory. You can simply
124 recursively copy the entire pybindgen folder into Python's
125 site-packages directory, and that's it! PyBindGen is a pure Python
126 package and does not actually require a C/C++ compiler; a C++ compiler is only
127 used for code generation unit tests and compiling the example modules, and it is not needed to generate code.
128
129
130 Documentation
131 =============
132
133 The following documentation is available:
134
135 1. `API docs (with introductory tutorial) <http://pybindgen.readthedocs.org/en/latest/>`_
136 2. Many simple examples in the `examples` directory
137 3. Advanced examples in the unit tests (`tests/`)
138 4. The source code!
139
140 .. image:: https://travis-ci.org/gjcarneiro/pybindgen.svg?branch=master
141 :target: https://travis-ci.org/gjcarneiro/pybindgen
142