Clone this wiki locally
Several people have created scripts to parse header files and automatically produce Cython bindings.
XDress is an automatic wrapper generator for C/C++ written in pure Python. Currently, xdress may generate Python bindings (via Cython) for C++ classes & functions and in-memory wrappers for C++ standard library containers (sets, vectors, maps). In the future, other tools and bindings will be supported.
This is a tool called cython-codegen or xml2cython.py written by David Cournapeau - download it with git (a version control tool, apt-get install git):
It requires gcc_xml and codegenlib from ctypeslib (apt get install python-ctypeslib)
- xml2cython - http://cournape.wordpress.com/2008/12/05/97/
- xml2cython - http://cournape.wordpress.com/2008/12/01/cython-codegen-cython-code-generator-from-gccxml-files/
- gcc_xml - http://www.gccxml.org/HTML/Download.html
- ctypes - http://docs.python.org/library/ctypes
- py_gcc_xml - http://sourceforge.net/projects/pygccxml/
Automatically generate bindings for fortran files: http://fwrap.sourceforge.net/
https://github.com/enthought/cwrap (original version; requires gcc_xml)
https://github.com/geggo/cwrap (fork which includes tests, documentation and requires libclang)
Script by Evan Buswell http://groups.google.com/group/cython-users/browse_thread/thread/67c3c4443a9c98ca
Philip Herron's 2012 GSoC project, using GCC plugins to generate pxd files. Code at
Requires a recent version of gcc and gcc-python-plugin.
autowrap automatically generates python extension modules for wrapping C++ libraries based on annotated (commented) cython pxd files. Current features include wrapping of template classes, enums, free functions and static methods as well as converters from Python data types to (many) STL containers and back. Finally, also manually written Cython code can be incorporated for wrapping code.
Automatically generate pxd from C headers. It uses pycparser to parse the definitions, so the only requirement beyond python dependencies is a C preprocessor on PATH.