[Pythonmac-SIG] creating python importable dll's

Jack Jansen jack@oratrix.nl
Thu, 13 Jul 2000 10:37:43 +0200


> I could really use some help with a project i'm working on.  I've been using
> Phil Thompson's SIP tool to generate python importable dll's on my pc, But
> my attempts to do the equivalent on the mac have been rather unsuccessful.
> I'm a novice mac programmer and would like to know if creating wrappers
> around a C++ dll (or shared library) on the mac is even plausible.

Definitely possible, there are numerous ways to do it:

1. Use calldll. This will only work for DLLs that export only routines with 
integer/float/char/string/etc arguments, but the advantage is that you don't 
have to build any C code.
2. Use bgen or swig. These are tools that read C/C++ .h header files and 
produce the C source code for an extension module. Both of these are difficult 
to use, bgen even more so than swig (but bgen is a lot more powerful than 
swig, too). But the difficulty is offset by the amount of work: once you get 
the hang of them you can produce modules with hundreds of methods in a matter 
of minutes.
3. Use modulator. This will only generate the framework of your module, but 
for small libraries you want to export to Python the framework is 80% of the 
code anyway, and implementing 4 or 5 methods in C is a lot less work than 
getting bgen or swig setup.
4. Write it by hand.

For all of these except case 1 you will need a C compiler. CodeWarrior is 
preferred, but some success for extension modules has been booked with Apple's 
free MPW C compiler, check out the pythonmac-sig archives for details.

Could you tell a bit more about the SIP tool? If it's a nifty idea we should 
implement something similar for the mac...
--
Jack Jansen             | ++++ stop the execution of Mumia Abu-Jamal ++++
Jack.Jansen@oratrix.com | ++++ if you agree copy these lines to your sig ++++
www.oratrix.nl/~jack    | see http://www.xs4all.nl/~tank/spg-l/sigaction.htm