Using External Libraries with python?

"Martin v. Löwis" martin at v.loewis.de
Thu Jan 4 11:47:10 EST 2007


Ognjen Bezanov schrieb:
> I have some external C libraries I would like to use with python.
> 
> I have been searching on the internet and found many such
> modules/bindings for libraries (e.g. Py-Lame) but have not yet
> come across any information of how to actually go about creating such
> bindings, so I was wondering if anybody here could point me in the right
> direction?

There are several methods. One is to write a Python C module by hand,
using the Python C API:

http://docs.python.org/ext/ext.html
http://docs.python.org/api/api.html

Essentially, all you need is a DLL/shared-object with an init
function.

Other solutions include tools that generate extension modules
automatically (such as SWIG or Pyrex), or using libraries on
top of the C API (such as Boost.Python).

I personally always use the C API directly.

Regards,
Martin



More information about the Python-list mailing list