Python embedding

G. David Kuhlman dkuhlman at netcom.com
Mon Sep 4 13:46:36 EDT 2000


I do not have the answer you want, in part because I do not think
that what you want is possible.  However, I'll explain what we did
in support of embedding Python in our application, and perhaps that
will help you figure out a solution for your problem.

When we install our product, we also install:

1. The Python .dll (on Win NT) or .so (on Solaris) in our bin
directory.  Why you do this: this is the Python compiler and
interpreter.  You need this in order to compile and interpret
scripts.  If you do not want this in a separate file, then you
should think about downloading the Python source code distribution
and compiling it on your user's platform (MS Windows in your case). 
Then create a project that statically links Python into your
application.

2. The Python standard library. We install everything you will find
in the lib directory in the standard Python installation.  We
install it under a lib directory in our installation directory.  As
I recall, we actually omit some platform specific stuff in some
sub-directories.  Why you do this: so that scripts interpreted by
your embedded Python can use modules from the standard library.

3. Add the path to the lib directory to the PYTHONPATH environment
variable.  Why you do this: so that when a script that your
embedded Python is interpreting imports a module from the standard
Python library, the import mechanism can find it.

Hope this helps you to devise a solution suited for your needs.

  - Dave

Daniel Andersson (daniel.andersson at centrumeh.com) wrote:
> Hi list/group
> 
> Im currently trying to embed python in my windows based
> irc-client (yes, the world needs yet another irc client :).
> Anyway I have some questions:
> 
> I would like to be able to distribute the client without
> installing python. I want to be able to send out basically
> two files, client.exe and script.py (script.py being a
> default implementation of the scriptable parts of the
> client) and have everything python needs included in
> client.exe. Is this possible? 
> 
> Another way would be to distribute client.exe, a python
> dll and the script.py, I think this would be ok too but
> I'd like to be able to do the first option.
> 
> In short, I want to be able to stuff everything that
> python needs (and some standard modules like string etc.)
> into my main exe.
> 
> /Daniel Andersson
> 



More information about the Python-list mailing list