Mimicing intepreter import behaviour in embedded application
Gordon McMillan
gmcm at hypernet.com
Thu Sep 12 08:30:51 EDT 2002
Syver Enstad wrote:
>
> I have embedded python in a C++ application. Now I want python code
> running in this application to reach modules in the same way as code
> running in the standard interpreter. So I set up a test comparing the
> sys.path variable under python and my application with the intpreter
> embedded.
>
> Most of the two sys.path's are equal except:
> Regular python: Embedded:
> ('d:\\devtools\\python22\\DLLs', 'D:\\devtools\\Python22\\Lib'),
> ('d:\\devtools\\python22\\lib', 'D:\\devtools\\Python22\\DLLs'),
> ('d:\\devtools\\python22\\lib\\lib-tk',
> 'D:\\devtools\\Python22\\Lib\\lib-tk'),
> This line is caused by the differing locations of the .exe files
> ('d:\\devtools\\python22',
> 'h:\\mydocuments\\Kode\\C++\\Applications\\pyexe'),
> ('d:\\devtools\\python22\\lib\\site-packages\\Numeric',
> 'D:\\devtools\\Python22'),
> Here I miss the .pth file that I have for PIL.
> ('d:\\devtools\\python22\\lib\\site-packages\\PIL',
> 'D:\\devtools\\Python22\\lib\\site-packages\\Numeric')]
>
> Is there a way to more closely mimic "the real interpreter"?
Usually when you embed you need to provide your own getpath.c
so you can set things up as you want them (& most embeddres
want the opposite - they don't want their app screwed up if
the user has a different Python version installed).
As for .pth files, they are processed in site.py. There's a
C flag for that. You may also need to have your own site.py
in your exe's directory.
-- Gordon
http://www.mcmillan-inc.com/
More information about the Python-list
mailing list