[C++-sig] Re: baking boost inside the main application instead of creating an extension module

Dave Hawkes daveh at cadlink.com
Sat Jun 8 04:53:48 CEST 2002


Or you could adapt something like iu (http://www.mcmillan-inc.com/iu.html),
or imputils, so that when python imports it always 'links to itself' but
uses the module name to find the entry point function as usual.

Dave Hawkes

"David Abrahams" <david.abrahams at rcn.com> wrote in message
news:21b101c20e67$e38d16d0$6601a8c0 at boostconsulting.com...
> Please post follow-ups to c++-sig at python.org.
>
> I know there are people who are using Boost.Python this way; I don't think
> it's terribly complicated, but I don't know the steps off the top of my
> head. Asking in a wider forum would probably get you better results. It
> would be super if someone would knows could write an "embedding Python
with
> Boost.Python" guide for the docs.
>
> -Dave
>
> ----- Original Message -----
> From: "Mike Dickheiser" <miked at sinistergames.com>
> To: <david.abrahams at rcn.com>
> Sent: Friday, June 07, 2002 2:41 PM
> Subject: baking boost inside the main application instead of creating an
> extension module
>
>
> > Hello Mr. Abrahams,
> >
> > (Please feel free to disgregard if you don't have time ;)
> >
> > I'm brand-spanking-new to Boost (and Python), so please forgive any
> > ignorance exhibited in the text below.
> >
> > Currently I'm working on a gaming project that is to be ported to the
> XBox.
> > XBox doesn't support the use of .dll's, so in order to use Python I had
> to
> > build it as a static library (of course meaning the interpreter itself
is
> > embedded in the main application's executable. This has so far worked
> very
> > well, and I can use python just fine.
> >
> > However, I recently downloaded and built the Boost library, have used it
> to
> > wrap some C++ classes in my (Windows) application, but soon realized
that
> my
> > Python scripts can't access these wrapped classes because I didn't
create
> an
> > extension module out of my Boost code (as it's part of the main
> > application).
> >
> > My question is: is there a way to use Boost in the manner I'm
attempting?
> > That is, when I use
> >
> > BOOST_PYTHON_MODULE_INIT(someClassWrapperModule)
> > {
> > ...
> > }
> >
> > inside the application (main.cpp), is there a way to expose the
generated
> > module to my python scripts such that I can do:
> >
> > import someClassWrapperModule
> > ... do stuff ...
> >
> > I was expecting to be able to do this because I AM able to create
modules
> > inside the application using the standard Python mechanism:
> >
> > static PyMethodDef PyInterfaceMethods[] = { stuff };
> > Py_InitModule("PythonInterfaceModule", PyInterfaceMethods);
> >
> > which I can then import as above without problems.
> >
> >
> > So, my question restated is: can the module created by
> > BOOST_PYTHON_MODULE_INIT be exposed to my Python scripts in a manner
> similar
> > to the module created by Py_InitModule, given that the code for both is
> in
> > the same file in the main application?
> >
> > Thanks for any help you can offer,
> > Mike Dickheiser
> >









More information about the Cplusplus-sig mailing list