[Python-Dev] Improve Python for embedding

Martin v. Loewis martin at v.loewis.de
Mon Dec 22 15:39:20 EST 2003

Guido van Rossum wrote:

> Not quite -- I don't understand why *you* don't want the environment
> variables to be used, if all you want is a better pythonw.exe.

I haven't embedded Python for a while, but I can sympathize with the
desire to ignore environment variables.

One approach to embedding is to provide a complete (stripped) copy
of Python, inside the target directory of the application. You might
even directly link with a static python23.lib, and freeze all
modules, instead of linking with python23.dll, and providing a copy
of all .py files.

In such an environment, you don't want a regular Python installation
to interfere with your embedded environment. For example, you may
have incorporated the library Foo, but the target system has another
(older) copy of Foo in PYTHONPATH. If your embedded application now
picks up the older copy of Foo, it fails, and all your testing goes
to hell (*) since arbitrary pieces of the library might get arbitrarily
replaced with something else.

So to allow reproducable results, you need a guarantee that nothing
on the target system is incorporated in your application.


(*) DLL hell, to be precise.

More information about the Python-Dev mailing list