OpenMS / autowrap

Generates Python Extension modules from Cythons PXD files
Other
76 stars 22 forks source link

autowrap build autowrap | Conda Version

Generates Python Extension modules from Cython PXD files.

Introduction

One important application of Cython is to wrap C++ classes for using them in Python. As Cythons syntax is quite similar to the syntax of Python writing a wrapper can be learned easily. Further Cython prevents you from many typical errors which might get in your way if you write such a wrapper in C++.

This wrapping process typically consist of four steps:

  1. Rewrite parts of the header files of your C++ library in so called .pxd files. These give Cython information for calling the library and for error checking the code written in the following step.

  2. Write Cython code which wraps the C++ library. This code resides in one or more .pyx files.

  3. Translate these .pyx files to C++ code with Cython.

  4. Use distutils to compile and link the C++ code to the final Python extension module.

Depending on the size of your library step 2 can be tedious and the code will consist of many similar code blocks with only minor differences.

This is where autowrap comes into play: autowrap replaces step 2 by analyzing the .pxd files with Cythons own parser and generating correct code for step 3. In order to steer and configure this process the .pxd files can be annotated using special formatted comments.

The main work which remains is writing the .pxd files. This is comparable to the declarations you have to provide if you use SIP or SWIG.

Documentation

We assume that you installed autowrap already, so running

$ autowrap --help

does not fail.

Please see docs/README.md for further documentation.

Features

Credits

Many thanks go to: