473,809 Members | 2,699 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Using External Libraries with python?

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
2 4006
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
On 1/4/07, "Martin v. Löwis" <ma****@v.loewi s.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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
7190
by: Carl Waldbieser | last post by:
I tried to adapt the instructions for building the M2Crypto module (http://sandbox.rulemaker.net/ngps/m2/INSTALL.html) to build a version compatible with Python2.3, but I've had some mixed results. I actually got everything to build and install, but when I try to import M2Crypto-- well, here is a sample session: >>> import M2Crypto Traceback (most recent call last): File "<interactive input>", line 1, in ? File...
1
1372
by: Laughlin, Joseph V | last post by:
Has anyone had any difficulties using C libraries / data structures with python? Are there any things I need to be aware of? Joe Laughlin Phantom Works - Integrated Technology Development Labs The Boeing Company
0
2508
by: Helmut Zeisel | last post by:
I want to build a static extension of Python using SWIG and VC++ 6.0 as described in http://www.swig.org/Doc1.3/Python.html#n8 for gcc. My file is testerl.i: ========================= %module testerl extern int hz(int i);
3
6082
by: We need more power captain | last post by:
Hi, I know less than a noob, I've been asked to do some compiles in VC++ 6 without knowing too much at all. (I'm a COBOL program normally so this is all too much for me) I open VC++6, open the workspace and then: Build>Batch Build
4
4978
by: Sivakumar Shanmugam | last post by:
Group.. We are running on db2 UDF V8 on Sun solaris platform. I created an UDF which calles a C-routine(SQL_API_FN). This C-routine in turn calls an external C-function. The C-function is provided to us by a vendor(PCMILER application). The C-Function does the following operations- Open the server,get distance between two points and close the server. It takes two input parameters(points). Whenever I call UDF via select statement it always...
15
2277
by: jackiechan | last post by:
I would like to test some things in C and make a graphical output when running them , something like in java for example http://www.cs.bell-labs.com/cm/cs/pearls/sortanim.html (without buttons just circles rectangles and such things) is there any extension (library) or any way to make similar (aplet-like but not web-like) output ?? (not ploting into a file but dynamic -> it changes like in that link when you click RUN)
1
1381
by: Alexandre Guimond | last post by:
Hi. I want to create a portable setup.py file for windows / linux for an extension package that i need to link with external libraries (gsl and boost). on windows i do something like this: imaging = Extension( 'pyag.imaging._imaging', sources = ( glob.glob( 'Source/pyag/imaging/Src/*.cpp' ) + glob.glob(
10
110339
true911m
by: true911m | last post by:
This is a simple walkthrough to get PyInstaller up and running. I decided to give PI a try, because it claims to be more selective about what it bundles into its executable files by default, and it also integrates UPX (Ultimate Packer for eXecutables) into the build process, if you have it installed. It also claims functionality on linux, as a bonus (I didn't test this). I highly recommend the UPX options, and will cover how to get it...
0
1027
by: Jean-Paul Calderone | last post by:
On Mon, 23 Jun 2008 13:30:55 -0400, John Salerno <johnjsal@nospamgmail.comwrote: Telnet and SSH are different things. There's nothing in the standard library for making an SSH connection (aside from the process control libraries, which let you run an external SSH client in a child process). There are several third-party SSH libraries, eg Twisted Conch and Paramiko. Jean-Paul
0
9721
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9603
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10376
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10387
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
7662
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5550
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5689
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3861
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3015
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.