how does SWIG work? how do i make a python module out of a c function?
aa8vb at yahoo.com
Tue Mar 7 20:11:08 CET 2000
|<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
|<META content=3D"text/html; charset=3Diso-8859-1" =
|<META content=3D"MSHTML 5.00.2314.1000" name=3DGENERATOR>
Hi. First, turn off HTML in your mailer (Microsoft Outlook Express I
gather). You'll get more replies. Many folks ignore or filter out posts
formatted with HTML.
| looking at www.swig.org/tutorial.html
| i can see that this looks like what i need to do, however according to
| the tutorial "you need to write an "interface file" which is the input
| to SWIG.", then it gives an example interface file which looks okay to
| me to do, but my question is.....what application do i use to write
| this"interface file"?,
It's a text file. So you can use any ASCII text editor you wish. Since
you're on an MSWin box, use MSVC++, notepad, edit, whatever (just so long
as it's a text file when you're done).
| and what do i do with it when its wrote?,
You run "swig" on it. SWIG generates wrapper code (in C, for example) and
optionally Python wrapper classes (.py) if you tell it to. E.g. on UNIX:
swig -shadow -python -I/my/includes -o stuff.i
| and what do i do with it when its wrote?
Link the wrapper code with the code it's wrapping, and then load it into
Python using a standard "import <module>" statement. I could tell you
about UNIX, but you'll need to read the docs for MSWin directions. This
should all be in the SWIG docs:
See the Doc/ tree in the package.
| how do i know if i have written it correctly?
Call your wrapped methods and test them?
| further down the page it shows (apparently) how to turn c code into a
| python module for Irix.....i dont know what that is, im using IDLE and
| can anyone help me, ive been stuck with this problem for a week...and
| im going mad trying to figure it out.
I'm not sure what you're stuck on yet. Do you have an error message or
code snippet that's relevent?
aa8vb at yahoo.com
More information about the Python-list