Embedding Python Engine into a windows executable

Bjorn Pettersen BPettersen at NAREX.com
Wed Apr 16 12:48:31 CEST 2003

> From: Karam Chand [mailto:karam_chand02 at yahoo.com] 
> Hello,
> Is is possible to embed Python engine completely into a windows
> executable? 

Yes (all it involves is linking with a third party library and calling
functions in it -- unless I'm misunderstanding your question...) You'll
have to use Boost.Python if you insist on the static requirement below.
Note: you _will_ need to extend Python with modules too, to make your
datatypes available to Python (it's the extension part Boost.Python can
do statically vs the others).

> Basically, I want to give some kind of python scripting to
> allow users extend my applicaion and I dont want to ship python*.dll
> separately.

First reconsider. If you're creating a traditional windows executable,
you allready have a collection of files to distribute. If you're doing
this for the sole purpose of getting a single executable file, I'd
suggest going the other way: develop in Python, extend with
Boost.Python, and use McMillan's Installer or py2exe to create your
executable (I've used Installer, but not py2exe, so someone correct me
if I'm wrong... :-)

If you're trying to create a singular executable to make distribution
and installation easier, you're headed in the wrong direction. I haven't
met many GUI applications that doesn't need to set up its "environment"
before it can start running, most logically in a separate initialization
program, ...

The only valid reason I can come up with is "production environment
policy" (which seems to be quite common although mostly misguided
<wink>). If this is the case, you'll need to recompile Python from
sources yourself as a static library. AFAIK this is never done on
Windows, but is done on various other OSen so I can't imagine it to be
too hard (though terribly boring compared to real coding <wink>).

-- bjorn

More information about the Python-list mailing list