Single-file executables

K

Kevin Walzer

Which of the Windows/Unix package builders for Python applications is
capable of creating single-file executables? I'm thinking of:

1. py2exe
2. Mcmillan Installer/PyInstaller
3. cxfreeze

The apps I've seen created by py2exe aren't single-file at all, the
install folder is full of files besides the main program. I'm looking
for a solution that stuffs all libraries, scripts, and the Python
runtime into one file.
 
?

=?ISO-8859-1?Q?=22Martin_v=2E_L=F6wis=22?=

Kevin said:
The apps I've seen created by py2exe aren't single-file at all, the
install folder is full of files besides the main program. I'm looking
for a solution that stuffs all libraries, scripts, and the Python
runtime into one file.

For full control, and truly single-binary executables, I recommend
to use freeze itself. It takes a bit more work, but also gives better
results.

Regards,
Martin
 
R

Ravi Teja

Actually, py2exe (from version 0.6.1) onwards does create single file
exes without ANY additional dependencies.
 
J

James Stroud

Kevin said:
Which of the Windows/Unix package builders for Python applications is
capable of creating single-file executables? I'm thinking of:

1. py2exe
2. Mcmillan Installer/PyInstaller
3. cxfreeze

The apps I've seen created by py2exe aren't single-file at all, the
install folder is full of files besides the main program. I'm looking
for a solution that stuffs all libraries, scripts, and the Python
runtime into one file.

I use pyinstaller. Its easy and makes a single file, even if you have
compiled dependencies like pycrypto (I don't think freeze handles these
so well). If you want ease of installation for windows, check out Inno
Setup. It gives a single downloadable installer that helps get around
the "unknown publisher" problem, and system registry editing. In
summary: pyinstaller + inno setup.

James
 
G

Giovanni Bajo

Ravi said:
Actually, py2exe (from version 0.6.1) onwards does create single file
exes without ANY additional dependencies.

They still require an external MSVCR71.DLL if made with Python 2.4. PyInstaller
1.1 (to be released today) does not have this problem.
 
P

Peter Hansen

Giovanni said:
They still require an external MSVCR71.DLL if made with Python 2.4. PyInstaller
1.1 (to be released today) does not have this problem.

Can you describe how they get around that issue? As far as I know, the
reason py2exe requires the external DLL is that the licensing of that
file does not permit completely free redistribution. Does PyInstaller
actually bundle it, or does it include an interpreter without any
dependency on that file?

-Peter
 
R

Ravi Teja

As Peter later pointed out, that is a licencing issue rather than a
tool issue. After browsing through the PyInstaller documentation, I
came across a curious snippet.

"On Windows, this provides support for doing in-process COM servers. It
is not generalized. However, embedders can follow the same model to
build a special purpose DLL so the Python support in their app is
hidden. You will need to write your own dll, but thanks to Allan Green
for refactoring the C code and making that a managable task."

I am assuming that this means it makes it easy to expose my Python code
as a plain dll. Just what I was looking for. I don't see any more
elaboration on this. Anyone tried this?
 
T

Thomas Heller

Usually the bundle=1 option in py2exe can create a single file exe, but it also
allows to have a separate shared library.zip file, which is useful if you need more than
one exe-file. With python 2.4, MSVCR71.dll is still required and not bundled. There are
technical reasons ('booting' the exe) and maybe legal reasons for that.

For full control, and truly single-binary executables, I recommend to
use freeze itself. It takes a bit more work, but also gives better
results.


I wonder if anyone is actually using freeze on Windows, with scripts that use,
say, pywin32 and wxPython.

I've said it before, and say it again: Creating real single-file exes or dlls
was a non-goal for py2exe. The goal was to be able to create in-process COM
servers which provide a python interpreter that is totally isolated from possible
other interpreters running in the same process.

py2exe simulates a statically linked python interpreter together with statically
linked extension modules. So, it is very similar to what freeze creates.

Thomas
 
?

=?ISO-8859-1?Q?=22Martin_v=2E_L=F6wis=22?=

Thomas said:
I wonder if anyone is actually using freeze on Windows, with scripts
that use, say, pywin32 and wxPython.

Interesting question. I've never done so myself (only on Linux and
Solaris), and given the relatively small interest in having a static
Python library on Windows, I guess the answer is no (or: everybody
doing that has managed to deal with the build process themselves).

I would probably go for a mingw static build if I had to attempt this.

Regards,
Martin
 
?

=?ISO-8859-1?Q?=22Martin_v=2E_L=F6wis=22?=

Thomas said:
I wonder if anyone is actually using freeze on Windows, with scripts
that use, say, pywin32 and wxPython.

Interesting question. I've never done so myself (only on Linux and
Solaris), and given the relatively small interest in having a static
Python library on Windows, I guess the answer is no (or: everybody
doing that has managed to deal with the build process themselves).

I would probably go for a mingw static build if I had to attempt this.

Regards,
Martin
 
C

Cameron Laird

.
.
.
Usually the bundle=1 option in py2exe can create a single file exe, but it also
allows to have a separate shared library.zip file, which is useful if
you need more than
one exe-file. With python 2.4, MSVCR71.dll is still required and not
.
.
.
For some of our projects, we provide a single executable, which
takes a command-line argument (or, rarely, environment variable)
to tell the executable whether to come up as server or client,
or GUI or command-line version, or ... The result is that, even
for an architecturally-sophisticated development, the end-user
experiences a unitary delivery; he has just one file to install,
remove, archive, ...
 
T

Thomas Heller

Cameron said:
.
.
.
.
.
.
For some of our projects, we provide a single executable, which
takes a command-line argument (or, rarely, environment variable)
to tell the executable whether to come up as server or client,
or GUI or command-line version, or ... The result is that, even
for an architecturally-sophisticated development, the end-user
experiences a unitary delivery; he has just one file to install,
remove, archive, ...

Ok, so you're down to about 0.2 files per application ;-)

Thomas
 
L

Larry Bates

Kevin said:
Which of the Windows/Unix package builders for Python applications is
capable of creating single-file executables? I'm thinking of:

1. py2exe
2. Mcmillan Installer/PyInstaller
3. cxfreeze

The apps I've seen created by py2exe aren't single-file at all, the
install folder is full of files besides the main program. I'm looking
for a solution that stuffs all libraries, scripts, and the Python
runtime into one file.

I use py2exe and Inno Installer and get to a single file installation
that way. Inno creates setup.exe as a single file. That file may
actually expand into several files upon installation (which is
typical as you want readme.txt, history.txt, other documentation,
maybe example .ini file, etc.). IMHO the fact that py2exe doesn't
create a single exe is a non-problem. What other Windows app when
installed only installs <progname>.exe and NO OTHER FILES. Inno
solves the problem of only having a single .exe to DISTRIBUTE
which I think is the real goal. Inno also lets you automate the
creation of desktop/quicklaunch/startbutton icons, insertion of
items into the registry, and a whole host of other "stuff" that
normally must be done to complete a proper installation. With some
plug-ins, you can even have it get updates from a website (I have
not tested this, but I've read about it).

If you want to "obscure" your programs use the bundle option and
py2exe imbeds the .ZIP file inside the .EXE file (making it
somewhat harder to hack).

-Larry Bates
 
K

Kevin Walzer

Larry said:
I use py2exe and Inno Installer and get to a single file installation
that way. Inno creates setup.exe as a single file. That file may
actually expand into several files upon installation (which is
typical as you want readme.txt, history.txt, other documentation,
maybe example .ini file, etc.). IMHO the fact that py2exe doesn't
create a single exe is a non-problem. What other Windows app when
installed only installs <progname>.exe and NO OTHER FILES. Inno
solves the problem of only having a single .exe to DISTRIBUTE
which I think is the real goal. Inno also lets you automate the
creation of desktop/quicklaunch/startbutton icons, insertion of
items into the registry, and a whole host of other "stuff" that
normally must be done to complete a proper installation. With some
plug-ins, you can even have it get updates from a website (I have
not tested this, but I've read about it).

If you want to "obscure" your programs use the bundle option and
py2exe imbeds the .ZIP file inside the .EXE file (making it
somewhat harder to hack).

-Larry Bates

It's not so much for "obscurity" as simplicity.

Tcl/Tk allows you to pack everything into a single file: it's called a
"starpack." You can use an installer, but it's not necessary--the file
can be uninstalled by moving it to the recycle bin.

On Mac OS X, applications are typically deployed as a "bundle"--the .app
extension is actually a directory that looks like a single file. All the
libraries, etc. can be placed inside.

The install directories that are created by py2exe, at least the ones
I've seen in the past, seem messy by comparison. As I understand it, the
latest version allows you to do "one-file-deployment," which is what I'm
looking for. PyInstaller also does this, from what I'm told.

So, I'm interested in that type of functionality.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,576
Members
45,054
Latest member
LucyCarper

Latest Threads

Top