Wrappyr is a collection of tools designed to provide tight integration between Python and C/C++ with as little work as possible.

The commonly used Python interpreter (CPython implementation) has a nice C API that you can use to interface with your C/C++ code. You can manually write the code for this interface, or use the SWIG toolkit to get the job done. This code will be compiled to a dynamic library - called a Python C extension.

However, if you use another interpreter (like PyPy), you can run into problems, because Python C extensions are incompatible with most other interpreters. In this way a lot of libraries will become unusable. Here Wrappyr comes in, to take most of the pain away.

The Wrappyr project will extract API information about a C/C++ library, generate a C interface if needed and finally generate Ctypes based Python code which serves as an interface between the C code and your Python application. In this way, Wrappyr enables you to use C/C++ libraries with just about any Python implementation.

Project layout

The Wrappyr project is a collection of tools, composed of the following three parts:

  1. The Wrappyr project takes advantage of the Clang C/C++ compiler, to extract and export information about the C/C++ code.
    A Clang plugin dumps classes, functions, etc. from a header file to XML.
  2. A tool that imports the XML file produced by the Clang plugin and does two things:
    1. Generate a C API for your C++ code.
    2. Generate an XML file describing how the Python API should look, which C calls should be made where, etc.
  3. A tool that creates the Ctypes-based Python API from an XML file.

For more information, see the GitHub project page.
For updates on the progress of this project, see the news page.

Would you like to learn (more about) Python? Have a look at our Dutch or English language Python training which we provide in European countries...