Advertisement

Distributing embedded python

Started by March 10, 2004 06:48 PM
2 comments, last by Uncivil 20 years, 8 months ago
I''ve written a small test app (windows) for embedding python 2.3.

Py_Initialize();

PyRun_SimpleString( "from time import time,ctime\n"
                    "print ''Today is'',ctime(time())\n" );

Py_Finalize();
Currently I only have python23.dll with my exe. It runs fine on a system that has python installed but on a system without python I get ''import site'' failed; use -v for traceback. But it prints the correct date/time. I can include python23/Lib with my exe but I''d rather not. What is the minimum that I can get away with?
It is a per-site configuration module. You can probably get away with providing an empty one. You might even be able to embed that module into the app itself (provide an initsite() and use PyImport_AppendInittab).

You will also need to provide any module you rely on, except for the ones which are built into the interpreter (check sys.builtin_module_names). The .pyc or .pyo files are sufficient.

[edited by - Fruny on March 10, 2004 8:19:21 PM]
"Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it." — Brian W. Kernighan
Advertisement
The dll if you don''t need anything that isn''t built-in.

You might want to look at things like McMillan''s installer which will make an exe out of your python and grab all the stuff it needs while it is at it.
quote: Original post by Anonymous Poster
The dll if you don''t need anything that isn''t built-in.

You might want to look at things like McMillan''s installer which will make an exe out of your python and grab all the stuff it needs while it is at it.


He''s embedding, not extending, but here''s the link anyway (the original page seems down).
"Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it." — Brian W. Kernighan

This topic is closed to new replies.

Advertisement