Windows porting questions

Peter Hansen peter at engcorp.com
Sat Feb 15 17:51:18 EST 2003


David McNab wrote:
> 
> Up till now I've been happily hacking with Python on Linux.
[...]
> But now, I'm looking at releasing some stuff on Windows.
> 
> I'm critically aware that the average Windows user expects everything to
> install and work straight out of a single EXE file - this is what they're
> used to. 

Actually, I'd say that's an out-of-date sentiment, or at least one
which has meaning only for tiny utilities or something.  Most 
Windows software has an "installer" which might itself be a single
executable (though the stuff distributed on a CD almost never is)
but which unpacks many many files onto the user's machine, changes
the registry, etc.

If you want a *single* EXE for something which does not have an
installer, you can do this most easily (in my opinion) using py2exe
and one of the readily available utilities which produce what
are called "self-extracting archives"... PowerZip has one of these
built in, for example.  This means when the EXE is run, the program
decompresses itself into a temporary folder under TEMP, then runs,
then (optionally) removes all the files when it completes.  Your
Python app itself doesn't need to be a single file, and forcing
yourself into this mould (except for a tiny utility) is pointless.

For an installer, there are many, including the one used to
produced the Python installation package itself, and you should
be able to find past discussion of this in the archives.

> Also, I'm aware of the Py2EXE program which can generate a turnkey
> executable binary from python code. This seems great, but there's a couple
> of concerns:
> 
> * Does Py2EXE build in all the needed binary modules? For instance, if I
> have a graphical toolkit written in C++, with Python bindings (eg FLTK),
> is Py2EXE smart enough to link in all the binary modules as well as the
> pure Python ones?

Yes, no, depends on the package.  It works fine with Tkinter or wxPython,
but it does *not* produce only a single executable, and cannot if there 
are any DLLs involved, which there certainly always will be.

> * Does it guarantee a single-file turnkey output, or can there be
> situations where the generated EXE requires some other software to be
> present on the target Windows box?

There are no guarantees for this free software... but it's almost
trivial to download it and try it out yourself.  So far we've had
great success at using it for (internal) distribution to machines
which do not have Python installed.

> * Is Py2EXE really the best approach for dumbing down the Windows
> installation process? If not, then what other approach would let me make a
> hunk of Python code, plus Python and 3rd party modules, easy to install
> and run for the average person's computer-illiterate great-aunt?

One of the installers.  Py2exe is not an installer, so if you 
don't try to treat it as such you'll be much happier under Windows.

-Peter




More information about the Python-list mailing list