Using External Libraries with python?

O

Ognjen Bezanov

Hello,

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?

Thank you!
 
?

=?ISO-8859-1?Q?=22Martin_v=2E_L=F6wis=22?=

Ognjen said:
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
 
C

Chris Mellon

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

Don't forget calling the using the external library directly from
Python by using ctypes.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,432
Messages
2,571,680
Members
48,796
Latest member
Greg L.

Latest Threads

Top