[python-win32] Building win32 extensions to Python (OT)

Bill Burns billburns at pennswoods.net
Sat Jun 17 02:45:39 CEST 2006


Jim wrote:

<snip>

> My only hurdle is py2exe can't make a single executable
> out of it... Py2exe can create a package with a dozen files, but I was
> hoping for a nice tiny bundle.
> 

Hi Jim,

Have you tried bundling an app with py2exe and...

1). The resulting exe did not run properly or
2). You didn't know that py2exe can create single file executables?

If the the answer is #1 then I can't help, but if the answer is #2 then
keep reading ;-)

Using py2exe 0.6.5 (and python 2.4.3), I have a setup file like this:

<code>

setup(windows =
     [{'script':'ManageExe.py','icon_resources':[(1,'go-jump.ico')]}],
     zipfile=None))

</code>

Take note of the line 'zipfile=None'.

Then, from the command line I do this:

C:\ManageExe>python setup.py py2exe -b1

Note the bundle option '-b1' (you can use 1, 2 or 3).

Running the above will create a single file executable. It won't wind up
being 'nice & tiny' :-) but it will be bundled into one exe.

Also as a test - I just bundled the single file wxPython sample in
...\site-packages\py2exe\samples\singlefile\gui and it works fine.

If your resulting executable works OK, you could also try
running UPX [1] over it to make it even smaller.... Using UPX, I was
able to reduce the size of the wxPython sample (above) by 22%.

HTH,

Bill

[1] http://upx.sourceforge.net



More information about the Python-win32 mailing list