[Pyrex] how to wrap libraries with nested include files

Josiah Carlson jcarlson at uci.edu
Mon Oct 16 00:32:32 UTC 2006


<Phil.Cummins at ga.gov.au> wrote:
> 
> I would like to access functions in a C library from Python, and it has been
> suggested to me that Pyrex is the way to go. My understanding is that to use
> Pyrex to wrap a C library, you need to re-write the library's include (.h)
> file in Pyrex - i.e. translate the structure definitions, etc., and write
> 'wrappers' for the functions you want to use.  However, like many .h files
> I've seen, the .h file for my library includes another .h file, and that file
> includes another .h file, and this chain continues through quite a few .h
> files. Do I have to re-write them all? 

You only need to rewritw/wrap the stuff that you want Python/Pyrex to
have access to.

If this is too much work, you may want to consider SWIG (which can do
much of the wrapping), or even ctypes.

 - Josiah




More information about the Pyrex mailing list