[C++-sig] embedded Python: Access an object defined previously in C++
seefeld at sympatico.ca
Wed Dec 28 16:51:37 CET 2005
Markus Heller wrote:
> Is it sufficient that the BOOST_PYTHON_MODULE block stands just below all the
> other functions in the according cpp file?
I don't understand the question. What do you mean by 'all the other functions' ?
The BOOST_PYTHON_MODULE block is used to export specific C++ types / functions
to python, and tells the python module loader how to find them.
> I want to call a Python script from within one of the functions of this class.
> This Python script will need to import the pipeline module. What are the
> necessare preconditions to allow the script to load my exported function?
> Do I need to reset the PYTHONPATH variable? Does this variable need to point
> to where the binary is? Notabene, it is not a shared object...
That depends. When you want to load it as an ordinary python module, it has to
be a shared object, and it must be in your PYTHONPATH. However:
* you may adjust your PYTHONPATH programmatically just before loading the
* you may be able to register the python module programmatically such that
the loader isn't involved at all, i.e. the module doesn't need to be in
a DSO. I have never done that myself, though, so I can't give any specific
advice. Some experimentation may be necessary.
More information about the Cplusplus-sig