By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
444,002 Members | 1,020 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 444,002 IT Pros & Developers. It's quick & easy.

Using External Libraries with python?

P: n/a
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!

Jan 4 '07 #1
Share this Question
Share on Google+
2 Replies


P: n/a
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
Jan 4 '07 #2

P: n/a
On 1/4/07, "Martin v. Lwis" <ma****@v.loewis.dewrote:
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
Don't forget calling the using the external library directly from
Python by using ctypes.
Jan 4 '07 #3

This discussion thread is closed

Replies have been disabled for this discussion.