[Python-Dev] hook for standalone executable

Thomas Heller theller at python.net
Fri Aug 8 20:19:54 EDT 2003


There has been a discussion on comp.lang.python about a cross-platform
py2exe-like tool:
<http://groups.google.com/groups?hl=en&lr=&ie=UTF-8&safe=off&threadm=ptji8wgr.fsf%40python.net>

The basic idea is, now that the zipimport feature is in place, to make
it easy to convert the Python interpreter itself into a standalone
executable by a simple operation (which can well be platform dependend,
but on some platforms, at least, a zipfile can be appended to a copy of
the interpreter executable itself).

Alex Martelli and Oren Tirosh also came up with ideas how to do this,
and it seems a hook in Py_Main() would be able to do the trick.

This hook could be triggered by examining the filename of the executable
itself. If the basename starts (case-insensitive) with the
characters 'python', everything continues as it is now.

In the other case, the default command line processing would not be
executed, instead the command line flags would be inserted into
sys.argv. Also the default environment variables would not be used to
set flags like Py_OptimizeFlag and so on, instead a special data section
in the executable would be searched and used to set these.  Some code
would be run to insert the executable filename itself at the front of
sys.path, and finally an import of a special module, maybe named
'__boot__', would be done. Another possibility would be to execute some
Python code with PyRun_SimpleString() found in this special data area.

Thomas




More information about the Python-Dev mailing list