crossplatform py2exe - would it be useful?

Thomas Heller theller at python.net
Thu Aug 7 08:41:43 EDT 2003


Oren Tirosh <oren-py-l at hishome.net> writes:

> On Wed, Aug 06, 2003 at 08:36:20PM +0200, Thomas Heller wrote:
>> I'm currently working on a new version of py2exe, which will require
>> Python 2.3 and later, because it uses the zipimport mechanism.
>
> Now that zipimport is part of Python the code required for bootstrapping 
> a py2exe runtime is just:
>
> myscript -c "import sys; sys.path.insert(0, sys.executable); import foo"
>

Yes, something like this is also what I am thinking now. And 'myscript'
is just a copy of the standard interpreter. Although the sys.path entry
must be present *before* Py_Initialize is called.

> This reduces the difference between the custom interpreter supplied with 
> py2exe and the standard interpreter to just a few lines of C.
>
> The obvious question is - why not go all the way and put this little
> hook into the standard Python distribution? This way py2exe could be a 
> platform-independent pure Python application. In fact, py2exe wouldn't 
> actually be necessary because anyone could create a zip file manually and 
> append it to the executable but it's more convenient to have a tool that 
> automates the process and finds the required dependencies.

Yes, and modulefinder is now in the standard library.

OTOH, py2exe does a little bit more: It has a mechanism to supply
modules to include which modulefinder doesn't find, exclude modules
which are unneeded although found, can detect whether Tkinter is used
and copy it, scan (on Windows) extensions for dlls they need (wxPython
needs the wxWindows dll, for example), handle hidden imports from C code
in Python itself and extensions, and so on.

And it works around the fact that extension modules cannot be loaded
from zipfiles, it creates a pure Python loader included in the zip for
them.

Having said that, I would have nothing against py2exe included in the
standard distribution, and the hooks in place.

Thanks,

Thomas




More information about the Python-list mailing list