General organizationΒΆ

c++2py works in two steps, illustrated in Fig. `c++2py.png`_.

  1. The analysis of the C++ code (header) abc.hpp of the functions and classes to be exposed to Python produces a file This file is a description of the objects to be exposed from C++ to Python. This description is itself written in Python, with an API presented in _documentation/manual/cpp2py.
  2. From the description file, the tool generate the C wrapping code, which is then compiled with the C++ code to produce the Python module ready to be imported in Python.

This is illustrated on the Figure.


  • Some advanced features are obtained by modifying (or writing from scratch) the file.
  • The first step requires the use of the Clang compiler (libClang to be precise), while the second step does not. Typically the is generated by the developer and distributed along with the source to compile in non-clang environment.