embedding python

Gabriel Genellina gagsl-py2 at yahoo.com.ar
Sat Nov 15 00:56:02 EST 2008


En Thu, 13 Nov 2008 19:41:44 -0200, Alan Baljeu <alanbaljeu at yahoo.com>  
escribió:

> Thanks, I have 2.5 now and it works great with Nose.  Now for my next  
> project, I want to embed Python and Nose in a C++ program.  I know this  
> means using the python25.dll, and I know how to setup the calls.
> I think though I will not be installing Python on target systems, so I  
> don't want to rely on sys.path including "site-install".  I would have a  
> directory with appropriate python files, a subdir for nose, and keep  
> those relative to the application dir.
>
> For the Python interpreter, two questions:
> 1. What is the best way to manage the import paths?

If you mimic a tipical Python installation layout in your application  
(don't have to include everything, only what you need) and you call  
Py_SetProgramName at the very beginning of your program, then the default  
rules for building sys.path will work.
(Mmm, I can't find out where exactly those rules are explained).

> 2. How can I invoke an interactive console for this embedded python?   
> I'd like to play with things while my app is running.

Looks like PyRun_InteractiveOne and PyRun_InteractiveLoop should work for  
you, but I've never used them.

-- 
Gabriel Genellina




More information about the Python-list mailing list