beginner questions on embedding/extending python with C++

Hoop jcollett at oshtruck.com
Wed Aug 9 10:51:58 EDT 2006


Hi All,
I am in the process also of trying to call Python script from a C++
windows app.
I have looked at the Boost site and am currently reading over the
Embedding portion of the tutorial. A question I have is that there
appear to be about 4 or 5 Boost items avaiable for download. Which one
should be downloaded to do the embedding?
Thanks
Jeff
Qun Cao wrote:
> Thanks for all the good pointers!
> I am still reading throught them, but Boost seems to be the way to go!
>
> Roman Yakovenko wrote:
> > On 8 Aug 2006 02:28:31 -0700, Qun Cao <quncao at gmail.com> wrote:
> > > Hi Everyone,
> > >
> > > I am a beginner on cross language development. My problem at hand is to
> > > build a python interface for a C++ application built on top of a 3D
> > > game engine.  The purpose of this python interface is providing a
> > > convenient scripting toolkit for the application.
> >
> > As for me, Boost.Python is the way to go.
> >
> > Fortunately you are not the first one, and I hope not the last one :-) :
> >
> > http://language-binding.net/pyplusplus/quotes.html#who-is-using-pyplusplus
> > 1. Python-OGRE
> >   * http://lakin.weckers.net/index_ogre_python.html
> >   * http://tinyurl.com/mvj8d
> >
> > 2. http://cgkit.sourceforge.net/ - contains Python bindings for Maya C++ SDK
> >
> > 3. PyOpenSG - https://realityforge.vrsource.org/view/PyOpenSG/WebHome
> >    The goal of PyOpenSG is to provide python bindings for the OpenSG
> >    scene graph.
> >
> > > Since the main program is still going to be the C++ application, I
> > > guess we need to embedding the python scripts in the C++ code.
> >
> > Boost.Python is the only tool that provides complete functionality(
> > extending and
> >   embedding ). Also I think cgkit is dealing with the problem too.
> >
> > > But for this to work, the python code needs to know the Player class,
> > > is it right?
> >
> > Right.
> >
> > Does that mean I need to build a python wrapper class for
> > > Player and "import Player" in the python code?  But because this
> > > application is built on top of a game engine, Player class inherits
> > > many classes from there, I cannot possibly wrapping them all, right?
> >
> > It depends on how much functionality you want to export.
> >
> > > Also, some global objects are probably needed in this code of adding
> > > players, how can the python code access them?
> >
> > Boost.Python provides the functionality you need.
> >
> > > Btw, if you can point me to any source code of non-trivial projects
> > > utilizing SWIG/Boost.Python, that would be very helpful.  I found the
> > > examples on the tutorials are far too simple.
> >
> > Those are tutorials, they should be simple, right :-) ?
> >
> > --
> > Roman Yakovenko
> > C++ Python language binding
> > http://www.language-binding.net/




More information about the Python-list mailing list