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
actually..
The first exe I made was 15MB or so, and I managed to trim it down.
see this thread:
http://aspn.activestate.com/ASPN/Mail/Message/wxpython-users/3709957
--
Steven Sproat, BSc
http://www.basicrpg.com/
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.
First of all thanks from me too for all the work you are doing on the
wiki - very much appreciated.
- For a very simple python only script I get a dist folder of 3.58 MB
- For a simple wxPython script (see http://wiki.wxpython.org/py2exe) 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
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
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. :-(
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.
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)
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). :-(
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.
>>My application is pretty big and only 5MB, I don't know what you're
>>doing to make it 14MB!
Probably nothing intentional.
This has been a fundamental problem of py2exe for a long time.
It pulls in lots of stuff that isn't needed, and it's a pain to figure
out what you dont need.
On Sat, Jan 16, 2010 at 12:12 PM, Daniel Carrera <dcar...@gmail.com> wrote:
> 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 -
http://wiki.python.org/moin/GuiProgramming 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. ;-)
My $0.02.
Cheers,
Scott.
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 -
> http://wiki.python.org/moin/GuiProgramming 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. ;-)
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.
--
Robin Dunn
Software Craftsman
http://wxPython.org
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 Sat, Jan 16, 2010 at 3:38 PM, Daniel Carrera <dcar...@gmail.com> wrote:
> 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 -
>> http://wiki.python.org/moin/GuiProgramming 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. ;-)
> 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. ;-)
>
> 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. ;-)
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? http://www.grc.com/smgassembly.htm
:-)
HTH a little.
Cheers,
Scott.
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.
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
Yeah, I was thinking along similar lines. If what I want existed, it
should be popular and I should already know about it. :-P
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. :-(
Cheers,
Daniel.
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. :-(
I guess too that these times are gone. :-(
Werner
For people who really care about size, there's always C++ with FLTK.
Wikipedia says that Hello World in FLTK is 100kb. But on the other hand,
I just tried to write Hello World in FLTK and failed... shows how out
touch I am with C++ programming.
And there's the problem that FLTK won't look good on any platform and
won't support i18n (and I definitely want my program to be i18n-able). I
guess that a larger download size is the price you pay for a nice
looking application that supports international languages...
Daniel.
It's just that other people are quoting 15MB even after your post and I
don't know what to expect.
Can I run GUI2exe on Linux? I just tried and I got a segmentation fault. :-(
% python GUI2Exe.py
*** 17 January 2010 @ 14:40:25 ***
Traceback (most recent call last):
File
"/usr/lib/python2.6/dist-packages/wx-2.8-gtk2-unicode/wx/_misc.py", line
1342, in Notify
self.notify()
File
"/usr/lib/python2.6/dist-packages/wx-2.8-gtk2-unicode/wx/_core.py", line
14716, in Notify
self.result = self.callable(*self.args, **self.kwargs)
File "GUI2Exe.py", line 3874, in ShowMain
frame = GUI2Exe(None, -1, "", size=(xvideo, yvideo))
File "GUI2Exe.py", line 406, in __init__
self.SetAllFlags()
File "GUI2Exe.py", line 1312, in SetAllFlags
self.ManageMenuBar(useCustom, fmStyle, ribbonStyle)
File "GUI2Exe.py", line 1191, in ManageMenuBar
ribbon = self._mgr.GetPane(self._ribbon)
AttributeError: 'GUI2Exe' object has no attribute '_ribbon'
zsh: segmentation fault python GUI2Exe.py
With SVN now I get a slightly different segfault. :-(
% python GUI2Exe.py
*** 17 January 2010 @ 15:30:16 ***
Traceback (most recent call last):
File
"/usr/lib/python2.6/dist-packages/wx-2.8-gtk2-unicode/wx/_misc.py", line
1342, in Notify
self.notify()
File
"/usr/lib/python2.6/dist-packages/wx-2.8-gtk2-unicode/wx/_core.py", line
14716, in Notify
self.result = self.callable(*self.args, **self.kwargs)
File "GUI2Exe.py", line 3905, in ShowMain
frame = GUI2Exe(None, -1, "", size=(xvideo, yvideo))
File "GUI2Exe.py", line 434, in __init__
self.ReadConfigurationFile()
File "GUI2Exe.py", line 1555, in ReadConfigurationFile
self.ribbonChecks1[ID_MSW_Provider][0] =
preferences["Ribbon_Style"][0] == 0
KeyError: 'Ribbon_Style'
zsh: segmentation fault python GUI2Exe.py
I updated the ticket on Google Code.
Daniel.
2010/1/17 Daniel Carrera:
I have added a small change in SVN, could you please let me know if it
works now?
Thank you.
Andrea.
"Imagination Is The Only Weapon In The War Against Reality."
http://xoomer.alice.it/infinity77/
http://thedoomedcity.blogspot.com/
Steven,
When you say to get "it" to around 5 MB, what is "it"? The MB of your
.exe file + all the added-up MB of the various .dll and .pyd files in
that directory? It would be great if you could attach a screenshot of
that directory showing the filesizes. I'm attaching mine and if you
add all that up, it comes to 15 MB.
Also, does anyone (Andrea?) know how to take the list of excludes that
Steven wrote in his previous email and quickly introduce that into
GUI2Exe? (I cut-and-pasted most of them in and re-compiled and I'm
still at 15 MB). There is probably a way to quickly cut and past the
whole list into the script, but I don't know how to do that from
within GUI2Exe or if you can yet.
Lastly, how does one UPX compression? I see there is a menu check
item for it, but I believe one has to get and install it first? Any
certain way that has to happen in order to work with GUI2Exe?
Thanks,
Che
(I should mention that I removed the w9xpopen file as I find this
unnecessary, but I see it is only 5 kb anyway)
"it" being the exe created by py2exe :)
I added in my excludes one-by-one, I'm not sure how to paste them over.
To use UPX, download the utility, and from the command line:
upx your_exe --best
it'll take half a minute or so and show how much it reduced the file by;
usually takes off a MB or so from my EXE. My application increases in
size, a bit then because of the included images/localisation files I use.
Here are my gui2exe options:
optimize: 2
compressed: 2
bundle: 1
here's my setup script, with comments removed:
#-------------
# Let's start with some default (for me) imports...
from distutils.core import setup
from py2exe.build_exe import py2exe
import glob
import os
import zlib
import shutil
# Remove the build folder
shutil.rmtree("build", ignore_errors=True)
class Target(object):
""" A simple class that holds information on our executable file. """
def __init__(self, **kw):
""" Default class constructor. Update as you need. """
self.__dict__.update(kw)
data_files = [] ## ignored for this paste
includes = ['HTMLParser', 'markupbase', 'subprocess',
'wx.lib.embeddedimage']
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']
packages = ['encodings', 'wx.media']
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']
icon_resources = [(1, 'E:\\Downloads\\whyteboard\\whyteboard.ico')]
bitmap_resources = []
other_resources = []
# No custom code added
# Ok, now we are going to build our target class.
# I chose this building strategy as it works perfectly for me :-D
GUI2Exe_Target_1 = Target(
# what to build
script = "gui.py",
icon_resources = icon_resources,
bitmap_resources = bitmap_resources,
other_resources = other_resources,
dest_base = "whyteboard",
version = "0.39.35",
company_name = "Steven Sproat",
copyright = "Steven Sproat",
name = "Whyteboard",
)
setup(
# No UPX or Inno Setup
data_files = data_files,
options = {"py2exe": {"compressed": 2,
"optimize": 2,
"includes": includes,
"excludes": excludes,
"packages": packages,
"dll_excludes": dll_excludes,
"bundle_files": 1,
"dist_dir": "dist",
"xref": False,
"skip_archive": False,
"ascii": False,
"custom_boot_script": '',
}
},
zipfile = None,
console = [],
windows = [GUI2Exe_Target_1],
service = [],
com_server = [],
ctypes_com_server = []
)
Hope that helps a bit :)
Thanks very much! Even before I got this email I started playing with
the compression settings and now I can get something that is just two
files with a total size of 5.7 MB (for my tiny sample text
application). And this is before using the UPX compression, so I'm
hoping to see about 5 MB then. That your program, which actually does
something (instead of my sample app which is just a few widgets) comes
in under 6 MB is encouraging.
I had begun to get the mistaken impression that you were saying that
the .exe file itself was only 5 MB with your tweaks, but that when
everything else was added in the dist folder was still about 15 MB--as
if you weren't "counting" the .dll or .pyd files, which of course
should count. But you *are* counting it (of course you are--it was
dumb of me to assume you weren't), and so this is encouraging.
I will get UPX per your instructions and see how that goes.
So Daniel, now if it is down to 5 MB, that's like a minute download on
DSL. C'mon, that can't be a dealbreaker, can it?
Che
>
>
> --
> Steven Sproat, BSc
> http://www.basicrpg.com/
>
>
> --
> To unsubscribe, send email to wxPython-user...@googlegroups.com
> or visit http://groups.google.com/group/wxPython-users?hl=en
>
Whoops, it's just over 6 MB (6.25) but close enough.
pretty good if you ask me - previous versions of my program were ~4.5mb,
but that was with no images/i8n, and I'm always using extra bits of wx,
which adds to the file size (e.g. the MediaCtrl added ~200kb)
:-)
I think I'll stick with wxPython then :-)
It's cool that it can go down to 5MB. I don't think I could beat that
unless I program with C++ and FLTK or similar.
Cheers,
Daniel.
On Sun, Jan 17, 2010 at 2:29 PM, Daniel Carrera <dcar...@gmail.com> wrote:
> C M wrote:
>>
>> So Daniel, now if it is down to 5 MB, that's like a minute download on
>> DSL. C'mon, that can't be a dealbreaker, can it?
>
> :-)
>
> I think I'll stick with wxPython then :-)
Woot!
> It's cool that it can go down to 5MB. I don't think I could beat that unless
> I program with C++ and FLTK or similar.
Or Assembly. ;-)
Cheers,
Scott.
Steven, thanks again for the encouragement and information on this. I
was able to make a sample .exe at around 5ish MB, and then, more
importantly, was inspired to .exe up an actual app that I'm working
on, and then went all the way through to Inno Setup and created a
setup file and have it mostly working on XP and Vista, which is really
nice to see. Inno Setup itself reduced the size of the single file
more, from about 19 MB to about 13 MB (although then it unpacks back
to the full 19 MB, but at least this cuts down on download time).
Pretty pleased with the whole experience.
And of course, continued thank yous to Andrea for GUI2Exe which is a
thing of beauty! :D
Che
I've got one with wx and not much else, the exe is 6.8MB, and the Inno
Setup installer including a couple Windows dlls, is 5.8MB.
Huge by the standards of a few years ago, but not anymore!
Note that the Mac version is much larger (16MB as a compressed disk
image), mostly due to the dual architectures.
-Chris
--
Christopher Barker, Ph.D.
Oceanographer
Emergency Response Division
NOAA/NOS/OR&R (206) 526-6959 voice
7600 Sand Point Way NE (206) 526-6329 fax
Seattle, WA 98115 (206) 526-6317 main reception
odd -- mine really is 6.7MB, with the final installer (including dlls
and help) smaller.
> Would you say that it'd be the same if I tried Tkinter?
could be -- for that you need all of TCL. But wx is pretty darn big --
it has the entire wx C++ library, plus the wrappers -- that adss up to a
lot.
You could, in theory strip it out a lot more, but that would be a pain
to do, and disk space and bandwidth really are pretty cheap now
(particularly disk space), so no one has bothered to do it.
> If most of those
> 15MB are the Python runtime,
nope -- wx is bigger than Python.
It's not hard to test. write a couple simple samples, one "hello world"
with just python, and one with a "import wx" at the top -- run py2exe
and you'll see what the minimum sizes are.
I doubt that the difference in size between Tk and wx is enough that you
should choose based on that.