plugin system

Alex Martelli aleax at aleax.it
Wed Apr 30 04:13:46 EDT 2003


<posted & mailed>

xam wrote:

> I am interested in writing a plugin system where the main app is python
> but it is capable of accepting helper "plugins" which can be either python
> or C++. I guess I want some sort of an interface spec for the plugins that
> can be implemented in either language. Which technologies should I
> research? Are there other projects that I can refer to as a model -

Boost Python (www.boost.org) lets you code Python-loadable modules in C++;
they will be basically undistinguishable from python-coded modules from
the point of view of the "main app in python" that imports them.

There are many other ways to achieve the same end-result (the "Python
C API", CXX, SWIG, SIP, ...) but if you're committed to C++ anyway for
the other language (i.e. don't care about being able to implement such
modules in C, Fortran, and so on), then I think Boost is the best.  And
anyway, when your specs are that the plugins must be "Python-extension
modules", then somebody else can later choose to implement plugins in
other ways, and "from the outside" (from your main Python app) they'll
work just fine.

So, I recommend you go with this choice, after exploring Boost Python
to convince yourself that it does make things as easy as pie for the
C++ coder.  Boost is a large library (mostly template-based) that also
offers a LOT of pluses to the C++ coder, by the way, in addition to
being able to interface with Python so easily.  Much of Boost may see
its way into the next release of the C++ standard, particularly given
that the population of Boost developers and the membership of the C++
standards committee have substantial overlap (the Boost Python part in
particular is of course unlikely to, given there is no ISO standard
for Python itself nor is any such thing likely to emerge!-).



Alex





More information about the Python-list mailing list