[Pythonmac-SIG] A question about embedding with Mac OS X Carbon

Alexandre Parenteau alexp@strata.com
Fri, 12 Jul 2002 16:21:07 -0700


Jack,

> is Python actually optional for MacCVS? Do you do some sort of
> dynamic loading of the Python framework? If you do I think the

Exactly, same thing on Windows, CFM and Mach-O.

For Windows it uses 'LoadLibrary', for CFM it uses the weak import
capability of CFM, and finally for Mach-O it uses CFBundleCreate,
CFBundleLoadExecutable and CFBundleGetFunctionPointerForName.

The problem with this method is that you have to overload all the Python
functions with macros that get function pointer instead.

This is especially bad for structures exported (like PyNone), because you
need to use an accessor instead.

One thing Guido should consider would be to do what did TCL at some point
(only it would be nice to make it so it works ;-)): provide from within the
Python headers some mean of using optionally a glue code executed on the
client side in order to provide dynamic loading.

I have all the source code to do that, it only is a huge change to the
Python headers.

Beside I was thinking this could lead to another development I have been
dreaming for months : being able to make a CFM Python module and use it
along with a Python Mach-O executable : would be awesome for legacy
components of companies like mine. But this is out of the figure for now.

> code would make a nice example, could it be separated out of
> Maccvs into a small sample program?

Not small, but separable yes ! I need to speak with you before in order to
get a sense of the kind of compiler environment you want that for.

In MacCvs: the dynamic loading for mac is inside
cvsgui/common/TclGlue.mac.cpp (nothing to do with TCL in fact, but it was my
first test for dynamic loading).

Now the macros that override a small amount of the Python functions are
inside cvsgui/common/PythonGlue.impl.h.

The ongoing Python integration for WinCvs/MacCvs is inside PythonGlue.cpp.

Alex.

> 
> And to Jay: I agree with Tony and Alexandre: forget about
> MacPython and go for the unix Python. If you're on OSX only
> there's no reason to bother with CFM and GUSI if you don't have
> to.
> --
> - Jack Jansen        <Jack.Jansen@oratrix.com>
> http://www.cwi.nl/~jack -
> - If I can't dance I don't want to be part of your revolution --
> Emma Goldman -
> 
>