GUI2exe / py2exe - executable size.

Hello,

Suppose I write a simple program in wxPython (e.g. a dictionary application), and I make an executable with py2exe. Can anyone give me an idea of how large the final executable will be? A rough idea?

Thanks,
Daniel.

Hi Daniel,

I have a small test GUI that is just 4 widgets, one of which is a
button with a small image on it. The .exe file on Windows is 14.9 MB
in size.

A larger app that makes use of some outside libraries is ~35 MB.

Che

···

On Sat, Jan 16, 2010 at 10:33 AM, Daniel Carrera <dcarrera@gmail.com> wrote:

Hello,

Suppose I write a simple program in wxPython (e.g. a dictionary
application), and I make an executable with py2exe. Can anyone give me an
idea of how large the final executable will be? A rough idea?

C M wrote:

···

On Sat, Jan 16, 2010 at 10:33 AM, Daniel Carrera <dcarrera@gmail.com> wrote:
  

Hello,

Suppose I write a simple program in wxPython (e.g. a dictionary
application), and I make an executable with py2exe. Can anyone give me an
idea of how large the final executable will be? A rough idea?
    
Hi Daniel,

I have a small test GUI that is just 4 widgets, one of which is a
button with a small image on it. The .exe file on Windows is 14.9 MB
in size.

A larger app that makes use of some outside libraries is ~35 MB.

Che
  

My application is pretty big and only 5MB, I don't know what you're doing to make it 14MB!

actually..
The first exe I made was 15MB or so, and I managed to trim it down.

see this thread: ActiveState Community - Boosting coder and team productivity with ready-to-use open source languages and tools.

--
Steven Sproat, BSc
http://www.basicrpg.com/

Steven Sproat wrote:

Hi Daniel,

I have a small test GUI that is just 4 widgets, one of which is a
button with a small image on it. The .exe file on Windows is 14.9 MB
in size.

A larger app that makes use of some outside libraries is ~35 MB.

Che
  

My application is pretty big and only 5MB, I don't know what you're doing to make it 14MB!

Phew! I was just about to write to say "15MB!!!!". I sure don't want the app 15MB, it's just a simple dictionary app!

I was hoping to hear something more in the 2MB range for a very simple app.

Daniel,

First of all thanks from me too for all the work you are doing on the wiki - very much appreciated.

Daniel Carrera wrote:

Hello,

Suppose I write a simple program in wxPython (e.g. a dictionary application), and I make an executable with py2exe. Can anyone give me an idea of how large the final executable will be? A rough idea?

- For a very simple python only script I get a dist folder of 3.58 MB
- For a simple wxPython script (see py2exe - wxPyWiki) I get a dist folder of 12.7 MB
- Above dist folder InnoSetup'ed is 4.8 MB

- My own application (The Wine Cellar Book) creates a dist folder of: 24.2 MB (using SQLAlchemy, MatPlotlLib, Amara XML, ReportManager and some other smaller libs) and an InnoSetup installer for it is 32.8 MB (it includes a Firebird SQL database plus embedded engine, some images and the help file for three languages).

Above is all on Windows 7, Python 2.5.4, wxPython 2.8.10.1 without trying to optimize it much - excludes are basically what is shown on the above wiki page).

Werner

It’s mainly the dlls that you need to include that can pump the size of the program up. I use bundle option 3 in py2exe with the other options set to 2. The exe itself tends to be in the 2-5 MB size range, but if you add in the other files it can be several megabytes larger.

···

On Sat, Jan 16, 2010 at 10:16 AM, Daniel Carrera dcarrera@gmail.com wrote:

Steven Sproat wrote:

Hi Daniel,

I have a small test GUI that is just 4 widgets, one of which is a

button with a small image on it. The .exe file on Windows is 14.9 MB

in size.

A larger app that makes use of some outside libraries is ~35 MB.

Che

My application is pretty big and only 5MB, I don’t know what you’re doing to make it 14MB!

Phew! I was just about to write to say “15MB!!!”. I sure don’t want the app 15MB, it’s just a simple dictionary app!

I was hoping to hear something more in the 2MB range for a very simple app.


Mike Driscoll

Blog: http://blog.pythonlibrary.org

Yes, I just re-GUI2Exe'd my tiny sample app with bundle_files = 3 (the default)
and now the .exe file is about 2 MB, BUT, and this is an important but, the
.dll files and .pyd files are in the folder and they, when added
together, come up
to the ~15 MB I originally had when it was a single .exe file (with everything
included inside it).

I think if Daniel wants a simple wxPython app and a single file to distribute
to people, he will have a 15 MB application. This is because what .exe does
is it puts the entire Python runtime in there for the user, so of course it has
to be kind of big.

Che

···

On Sat, Jan 16, 2010 at 11:21 AM, Mike Driscoll <mike@pythonlibrary.org> wrote:

On Sat, Jan 16, 2010 at 10:16 AM, Daniel Carrera <dcarrera@gmail.com> wrote:

Steven Sproat wrote:

Hi Daniel,

I have a small test GUI that is just 4 widgets, one of which is a
button with a small image on it. The .exe file on Windows is 14.9 MB
in size.

A larger app that makes use of some outside libraries is ~35 MB.

Che

My application is pretty big and only 5MB, I don't know what you're doing
to make it 14MB!

Phew! I was just about to write to say "15MB!!!!". I sure don't want the
app 15MB, it's just a simple dictionary app!

I was hoping to hear something more in the 2MB range for a very simple
app.

It's mainly the dlls that you need to include that can pump the size of the
program up. I use bundle option 3 in py2exe with the other options set to 2.
The exe itself tends to be in the 2-5 MB size range, but if you add in the
other files it can be several megabytes larger.

C M wrote:

Yes, I just re-GUI2Exe'd my tiny sample app with bundle_files = 3 (the default)
and now the .exe file is about 2 MB, BUT, and this is an important but, the
.dll files and .pyd files are in the folder and they, when added
together, come up
to the ~15 MB I originally had when it was a single .exe file (with everything
included inside it).

I think if Daniel wants a simple wxPython app and a single file to distribute
to people, he will have a 15 MB application. This is because what .exe does
is it puts the entire Python runtime in there for the user, so of course it has
to be kind of big.

I want something that anybody can install. It looks like I'm looking at 15MB. It doesn't matter if it's a 2MB exe with a lot of DLLs or if it's a single exe - either way it's 15MB and that's too much. :frowning:

Would you say that it'd be the same if I tried Tkinter? If most of those 15MB are the Python runtime, the it doesn't matter what toolkit I pick, the problem is with Python.

Cheers,
Daniel.

Daniel Carrera wrote:

C M wrote:

Yes, I just re-GUI2Exe'd my tiny sample app with bundle_files = 3 (the default)
and now the .exe file is about 2 MB, BUT, and this is an important but, the
.dll files and .pyd files are in the folder and they, when added
together, come up
to the ~15 MB I originally had when it was a single .exe file (with everything
included inside it).

I think if Daniel wants a simple wxPython app and a single file to distribute
to people, he will have a 15 MB application. This is because what .exe does
is it puts the entire Python runtime in there for the user, so of course it has
to be kind of big.

I want something that anybody can install. It looks like I'm looking at 15MB. It doesn't matter if it's a 2MB exe with a lot of DLLs or if it's a single exe - either way it's 15MB and that's too much. :frowning:

Would you say that it'd be the same if I tried Tkinter? If most of those 15MB are the Python runtime, the it doesn't matter what toolkit I pick, the problem is with Python.

Cheers,
Daniel.

15MB is still small. 5MB is small. 2MB is tiny.
Regardless, the Python exe is 2 - 2.5MB by itself. What I do is use GUI2exe and specify many excludes for Python modules / DLLs that I don't need.
I'm not sure about tkinter's size, probably something out there on google.

in my setup script:

excludes = ['_ctypes', '_gtkagg', '_imaging', '_imagingft', '_ssl',
            '_tkagg', 'bsddb', 'bz2', 'calendar', 'comtypes',
            'ctypes', 'curses', 'decimal', 'difflib', 'difflib',
            'doctest', 'email', 'hashlib', 'imaging', 'inspect',
            'logging', 'mailbox', 'numpy', 'optparse', 'pdb',
            'PIL', 'pydoc', 'pythonwin', 'pywin.debugger',
            'pywin.debugger.dbgcon', 'pywin.dialogs', 'subprocess',
            'tcl', 'test', 'Tkconstants', 'Tkinter', 'unicodedata',
            'unittest', 'urllib2', 'win32api', 'win32com',
            'win32con', 'win32gui', 'win32ui', 'win32uiole',
            'winxpgui', 'wxPython', 'xml', 'xmllib', 'xmlrpclib']
dll_excludes = ['libgdk-win32-2.0-0.dll', 'libgobject-2.0-0.dll', 'pythoncom25.dll',
                'pywintypes25.dll', 'sqlite3.dll', 'tcl84.dll',
                'tix84.dll', 'tk84.dll', 'wxbase28uh_xml_vc.dll',
                'wxmsw28uh_aui_vc.dll', 'wxmsw28uh_gl_vc.dll',
                'wxmsw28uh_stc_vc.dll', 'wxmsw28uh_xrc_vc.dll']

I got this list by examining the "build" directory that is generated, and filtering through all the large modules that I don't use.
Afterwards, I use the UPX tool on my exe to reduce its size by around 1MB. (6mb->5)

···

--
Steven Sproat, BSc
http://www.basicrpg.com/

Steven Sproat wrote:

15MB is still small. 5MB is small. 2MB is tiny.

There is this dude who wants to write the program in PureBasic. That's a closed source, proprietary language, but it is compiled and it actually makes cross-platform GUIs. His program is 1MB (500KB gzip download). :frowning:

Oh, and did I mention that BASIC is yucky?

Anyways, I'm sure I could get away with a 2-3MB alternative, but 15MB for just a dictionary sounds like a lot. Especially in the context of an evil proprietary language that makes a 500KB download.

Anyone want to recommend a compiled language that's easy to use? I don't care enough about this project to learn C++. I'd be willing to learn D, but now we're moving toward more obscure, probably poorly supported languages.

Dang! I can't believe that there isn't a free open source alternative to PureBasic. I hate proprietary stuff.

I got this list by examining the "build" directory that is generated, and filtering through all the large modules that I don't use.
Afterwards, I use the UPX tool on my exe to reduce its size by around 1MB. (6mb->5)

Thanks. Now I have an idea of how far down I can go with Python and what it takes to get there.

Cheers,
Daniel.

You may be correct. I don’t usually pay too much attention since I put it all into an Inno installer. Oh well.

···

On Sat, Jan 16, 2010 at 10:28 AM, C M cmpython@gmail.com wrote:

On Sat, Jan 16, 2010 at 11:21 AM, Mike Driscoll mike@pythonlibrary.org wrote:

On Sat, Jan 16, 2010 at 10:16 AM, Daniel Carrera dcarrera@gmail.com wrote:

Steven Sproat wrote:

Hi Daniel,

I have a small test GUI that is just 4 widgets, one of which is a

button with a small image on it. The .exe file on Windows is 14.9 MB

in size.

A larger app that makes use of some outside libraries is ~35 MB.

Che

My application is pretty big and only 5MB, I don’t know what you’re doing

to make it 14MB!

Phew! I was just about to write to say “15MB!!!”. I sure don’t want the

app 15MB, it’s just a simple dictionary app!

I was hoping to hear something more in the 2MB range for a very simple

app.

It’s mainly the dlls that you need to include that can pump the size of the

program up. I use bundle option 3 in py2exe with the other options set to 2.

The exe itself tends to be in the 2-5 MB size range, but if you add in the

other files it can be several megabytes larger.

Yes, I just re-GUI2Exe’d my tiny sample app with bundle_files = 3 (the default)

and now the .exe file is about 2 MB, BUT, and this is an important but, the

.dll files and .pyd files are in the folder and they, when added

together, come up

to the ~15 MB I originally had when it was a single .exe file (with everything

included inside it).

I think if Daniel wants a simple wxPython app and a single file to distribute

to people, he will have a 15 MB application. This is because what .exe does

is it puts the entire Python runtime in there for the user, so of course it has

to be kind of big.

Che

Mike Driscoll

Blog: http://blog.pythonlibrary.org

Hi Daniel, Steven and All,

Steven Sproat wrote:

15MB is still small. 5MB is small. 2MB is tiny.

Yes.

Anyone want to recommend a compiled language that's easy to use? I don't
care enough about this project to learn C++. I'd be willing to learn D, but
now we're moving toward more obscure, probably poorly supported languages.

Dang! I can't believe that there isn't a free open source alternative to
PureBasic. I hate proprietary stuff.

Interpreted languages will almost always have larger "footprints" than
compiled languages - it's the nature of the beast. Interpreted
languages are often easier to read and faster for development.
There's a trade-off.

Given the speed of reasonably modern machines, there is much less need
for a fully-compiled executable than there was. (Even interpreted
Python is fast for computation with the proper libraries.)

Why do you need a compiled language? Why is 15MB too big? Some
digital cameras can easily generate RAW files that are bigger than
that.

There are other cross-platform GUI toolkits for Python -
GuiProgramming - Python Wiki Some of them are
substantially smaller than wxPython.

If you have multiple python projects in mind, you can have your users
install Python, wxPython (or whatever GUI toolkit you choose), and any
other requirements once and be done with it. Your (interpreted) code
that you needed to distribute would then be very small. (If you're
worried about users taking your code, then any interpreted language
probably isn't a good choice.)

If you have to have a compiled language, with a good, cross-platform,
GUI that's well supported and free, you're ultimately probably looking
at some version of C/C++. Of course other languages are available,
but everything is a tradeoff. :wink:

My $0.02.

Cheers,
Scott.

···

On Sat, Jan 16, 2010 at 12:12 PM, Daniel Carrera <dcarrera@gmail.com> wrote:

grunculus wrote:

Given the speed of reasonably modern machines, there is much less need
for a fully-compiled executable than there was. (Even interpreted
Python is fast for computation with the proper libraries.)

Why do you need a compiled language? Why is 15MB too big? Some
digital cameras can easily generate RAW files that are bigger than
that.

The speed wouldn't be a problem. But it seems a lot to ask people to download a 15MB file for what is just a very simple dictionary application. I have a medium-speed connection (not dialup, but not fast) and here a 15MB file takes a little while to download. I'd be disappointed if a very trivial application took so long to download. We are not talking about OpenOffice here.

There are other cross-platform GUI toolkits for Python -
GuiProgramming - Python Wiki Some of them are
substantially smaller than wxPython.

Which one is smaller than wxPython? How much of the 15MB do you think is Python itself and how much is wxPython? I'm happy to try a different toolkit. I don't have my heart set on any technology (other than "open source" and preferably "easy"). Would Tkinter be much smaller? FLTK? Do you have any idea if FLTK is hard to package with py2exe?

If you have to have a compiled language, with a good, cross-platform,
GUI that's well supported and free, you're ultimately probably looking
at some version of C/C++. Of course other languages are available,
but everything is a tradeoff. :wink:

Hmm. I guess I'm frustrated that a proprietary language, and one based on *BASIC*, would outperform open source options.

Daniel.

You can do an estimate of that yourself without too much hassle. The Python parts will be an executable about the same size as python.exe, plus the Python DLL, plus a zipped version of whichever .pyc files you are using from the standard library. The wxPython portion will be the size of the wx DLLs, the wxPython .pyd files that your app uses, and a zipped version of the .pyc files from the wx package and library that you are using.

If you have the wxPython samples there is a simple example of how to use py2exe and other bundling tools in samples/doodle that you can experiment with. It's probably not totally up to date, but it should be enough to get you started.

···

On 1/16/10 12:38 PM, Daniel Carrera wrote:

How much of the 15MB do you think is
Python itself and how much is wxPython?

--
Robin Dunn
Software Craftsman

I've had better luck with pyinstaller making smaller executables - it
also supports UPX.

If you want to package everything up for the user you can't get around
the interpreter and dlls.

For one of my recent projects, with pyinstaller and the single file +
UPX, I get an exe about 7.5mb, and the application is not totally
trivial, it uses quite a few libraries, wxpython included.

(side note: UPX actually does a very good job, when i tried to 7zip
the file on 'Ultra' just for kicks, the file actually gets a few KB
larger)

This is with no tweaking of settings or included libraries as well,
which might reduce the size a little more..

I recommend using the SVN version of pyinstaller if you use python
2.6.

- michael

···

On Jan 16, 2:38 pm, Daniel Carrera <dcarr...@gmail.com> wrote:

grunculus wrote:
> Given the speed of reasonably modern machines, there is much less need
> for a fully-compiled executable than there was. (Even interpreted
> Python is fast for computation with the proper libraries.)

> Why do you need a compiled language? Why is 15MB too big? Some
> digital cameras can easily generate RAW files that are bigger than
> that.

The speed wouldn't be a problem. But it seems a lot to ask people to
download a 15MB file for what is just a very simple dictionary
application. I have a medium-speed connection (not dialup, but not fast)
and here a 15MB file takes a little while to download. I'd be
disappointed if a very trivial application took so long to download. We
are not talking about OpenOffice here.

> There are other cross-platform GUI toolkits for Python -
>GuiProgramming - Python Wiki Some of them are
> substantially smaller than wxPython.

Which one is smaller than wxPython? How much of the 15MB do you think is
Python itself and how much is wxPython? I'm happy to try a different
toolkit. I don't have my heart set on any technology (other than "open
source" and preferably "easy"). Would Tkinter be much smaller? FLTK? Do
you have any idea if FLTK is hard to package with py2exe?

> If you have to have a compiled language, with a good, cross-platform,
> GUI that's well supported and free, you're ultimately probably looking
> at some version of C/C++. Of course other languages are available,
> but everything is a tradeoff. :wink:

Hmm. I guess I'm frustrated that a proprietary language, and one based
on *BASIC*, would outperform open source options.

Daniel.

Hi Daniel,

grunculus wrote:

The speed wouldn't be a problem. But it seems a lot to ask people to
download a 15MB file for what is just a very simple dictionary application.
I have a medium-speed connection (not dialup, but not fast) and here a 15MB
file takes a little while to download. I'd be disappointed if a very trivial
application took so long to download. We are not talking about OpenOffice
here.

Ok.

There are other cross-platform GUI toolkits for Python -
GuiProgramming - Python Wiki Some of them are
substantially smaller than wxPython.

Which one is smaller than wxPython?

Dunno. Note that many of those toolkits are orphans, etc. People
(sensibly) get tired of reinventing the wheel after a while. :wink:

How much of the 15MB do you think is
Python itself and how much is wxPython?

[ Robin addressed that ]

I'm happy to try a different
toolkit. I don't have my heart set on any technology (other than "open
source" and preferably "easy"). Would Tkinter be much smaller? FLTK? Do you
have any idea if FLTK is hard to package with py2exe?

No idea. Sorry.

If you have to have a compiled language, with a good, cross-platform,
GUI that's well supported and free, you're ultimately probably looking
at some version of C/C++. Of course other languages are available,
but everything is a tradeoff. :wink:

Hmm. I guess I'm frustrated that a proprietary language, and one based on
*BASIC*, would outperform open source options.

46 years of development and optimization will do that. :wink:

Seriously, BASIC is a fine language and does many things very well.
IMHO, if it serves all your needs for your simple cross-platform
Dictionary application, then use it. It always makes the most sense
to try to use the right tool for the job. 79 Euros isn't that much
(especially compared to your time).

Presumably, though, you're not investing all this time and effort on
wxPython just for a single, simple program. Otherwise, why not just
write it in Assembly? GRC | Assembly Language Windows Applications  

:slight_smile:

HTH a little.

Cheers,
Scott.

···

On Sat, Jan 16, 2010 at 3:38 PM, Daniel Carrera <dcarrera@gmail.com> wrote:

grunculus wrote:

Seriously, BASIC is a fine language and does many things very well.
IMHO, if it serves all your needs for your simple cross-platform
Dictionary application, then use it. It always makes the most sense
to try to use the right tool for the job. 79 Euros isn't that much
(especially compared to your time).

Presumably, though, you're not investing all this time and effort on
wxPython just for a single, simple program. Otherwise, why not just
write it in Assembly? GRC | Assembly Language Windows Applications  

I don't have clearly defined goals. In the near term I'm only thinking of a single, simple program. But in general, I think I would like to have the ability to make cross-platform desktop applications without too much hassle for me or the users, without a huge download size, and without using anything proprietary. I don't know if this would be useful to me or not.

To an extent, I kind of like learning programming languages and toolkits. I have various amounts of experience with C, Perl, PHP, Ruby, JavaScript, Python, MATLAB/Octave, Haskell, etc. I like to learn tools (esp languages) that add something new (for me). I like a language that adds something I could not easily do before.

Cheers,
Daniel.

The speed wouldn't be a problem. But it seems a lot to ask people to
download a 15MB file for what is just a very simple dictionary application.
I have a medium-speed connection (not dialup, but not fast) and here a 15MB
file takes a little while to download. I'd be disappointed if a very trivial
application took so long to download. We are not talking about OpenOffice
here.

15 MB might take 2-3 min to download on consumer level DSL If it is a
very simple app, yes, this is disproportionate to the size of the .py
file or to the functionality of the app. Oh well. I've convinced
myself that if an app does something useful and needed, no one is
going to care if it takes a few minutes to get it, particularly since
they can start the download and then do other things while it is
going. And the nice thing is if you make a more complex app, like 10x
bigger, the download size of the .exe won't be 10x bigger, and you can
trim things down with various tips people have offered here.

I guess if there were a programming language that was easy to write,
easy to read, had lots of libraries, was free, open source, had a
great community, and was a compiled language that produced small and
fast-running executable files, it'd be pretty popular. I don't think
there is such a creature yet (is there?), and so choosing a language
is a process of weighing trade-offs. Something about Python and
wxPython felt comfortable to me, so I just ignore the larger .exe
issue (if it ever even is an issue).

Che

C M wrote:

I guess if there were a programming language that was easy to write,
easy to read, had lots of libraries, was free, open source, had a
great community, and was a compiled language that produced small and
fast-running executable files, it'd be pretty popular. I don't think
there is such a creature yet (is there?), and so choosing a language
is a process of weighing trade-offs. Something about Python and
wxPython felt comfortable to me, so I just ignore the larger .exe
issue (if it ever even is an issue).

Yeah, I was thinking along similar lines. If what I want existed, it should be popular and I should already know about it. :stuck_out_tongue:

Other options I'm considering include Mono/C# and wxLua.

* Mono/C#: There is a packager to make a single file executable. You can expect a file size of maybe 9MB. I'm not sure how easy it is to get wx.NET working though. I also feel slightly uneasy with Microsoft technologies, but I'm probably worrying too much. C# is a nice language.

* wxLua: This one can probably take me down to 7MB. Lua is a smaller community. I've never written anything with Lua, so I'd have more to learn, but it resembles JavaScript a lot, and I know JavaScript well.

But no matter what I pick, I don't see the program going down to the ~2MB region I was hoping for. :frowning:

Cheers,
Daniel.

Daniel,

Daniel Carrera wrote:

C M wrote:

I guess if there were a programming language that was easy to write,
easy to read, had lots of libraries, was free, open source, had a
great community, and was a compiled language that produced small and
fast-running executable files, it'd be pretty popular. I don't think
there is such a creature yet (is there?), and so choosing a language
is a process of weighing trade-offs. Something about Python and
wxPython felt comfortable to me, so I just ignore the larger .exe
issue (if it ever even is an issue).

Yeah, I was thinking along similar lines. If what I want existed, it should be popular and I should already know about it. :stuck_out_tongue:

Other options I'm considering include Mono/C# and wxLua.

* Mono/C#: There is a packager to make a single file executable. You can expect a file size of maybe 9MB. I'm not sure how easy it is to get wx.NET working though. I also feel slightly uneasy with Microsoft technologies, but I'm probably worrying too much. C# is a nice language.

* wxLua: This one can probably take me down to 7MB. Lua is a smaller community. I've never written anything with Lua, so I'd have more to learn, but it resembles JavaScript a lot, and I know JavaScript well.

I guess you run into the same issues here as with wxPython - see my post from the 16th in this thread. It is not Python which takes a lot of space it is wxPython and mainly because of the wx wrapping dll's and a little for the MS run time.

But no matter what I pick, I don't see the program going down to the ~2MB region I was hoping for. :frowning:

I guess too that these times are gone. :frowning:

Werner