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

Martin Casado casado2 at llnl.gov
Fri Jun 7 23:38:01 CEST 2002


One way is to simply call the bpl init methods from within your main
method, after Py_Initialize() is called. 

                            ~~martin



> 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
>
> _______________________________________________
> C++-sig mailing list
> C++-sig at python.org
> http://mail.python.org/mailman/listinfo/c++-sig





More information about the Cplusplus-sig mailing list