[Pythonmac-SIG] Embedding on Mac (recently?)

Just van Rossum just@letterror.com
Thu, 13 Jan 2000 12:39:27 +0100


At 9:14 AM +0000 13-01-2000, Paul-Michael Agapow wrote:
>Has anyone embedded Python as an internal scripting language in a Mac
>application recently?

I have a big C project which embeds MacPython. But I must admit that I'm
not up-to-date with the CVS tree, but am using a version slightly newer
than 1.5.2c.

>There was some traffic on the list about this exact
>issue but that was quite some time ago. I've got a simulation package
>(macro-evolution for those that are interested) that I'd like users to be
>able to program up scenarios for and Python seems like the tool of choice.
>Any available examples or source code?

Look at the Extending & embedding doco, as well as the C/C++ API reference.
Both are available at http://www.python.org/doc/.

The easiest setup for embedding MacPython is to build upon a standard
distribution. This takes almost nothing: include PythonCore shared lib in
your project, plus possibly some of the preferences resources. All set! You
don't even need the source distribution to do this, just make sure you
installed the dev-kit.

This is very easy from a developers' standpoint, but it's not so great for
end users, since they'll be confronted with installing Python and the
headaches that may arise when that goes wrong... So in the end it might be
better to include the Python interpreter statically, which I've also done
in the past, by compiling Python as a static library from the source. The
PythonCore CW project files or the Standalone project files could be used
as an example. Shouldn't be too hard either, althought it definitely takes
more effort than the shared lib method.

Hope this helps,

Just