Hi All,
I am happy to announce the birth of GUI2Exe, that is (my) first
attemp to unify all the available "executable builders" for Python in
a single and simple to use graphical user interface. At the moment
only py2exe is supported (is the only one I ever used), but it
shouldn't be hard to extend it.
What is it?
···
----------------
The aim of GUI2Exe was (for me) to create a wxPython GUI tool that
unifies and simplifies various standalone executable builders for
Python, such as py2exe, py2app, cx_Freeze, etc. It may look like the
Holy Grail, but this is at least a small step toward the Great Theory
of Unification.
How it works?
--------------------
GUI2Exe is implemented as follows:
- It uses the bsddb module to store all the projects you have compiled
with GUI2Exe in a database, so you can always retrieve what you did in
the past. The project names are displayed in a wxPython tree control;
- The central window shows the options available to the user for a
particular executable builder (only py2exe at the moment). This
windows contains a set of widgets, the usage of most of them is very
simple. However, for the following py2exe options:
a) Includes;
b) Packages;
c) Excludes;
d) Dll Excludes;
e) Ignores;
f) Data Files;
g) Icon Resources, Bitmap Resources and Other Resources;
you will see a list control: if you want to add an item to these lists
(i.e., add an Includes module, or a Dll Excludes Windows dll), simply
click on the list and hit Ctrl+A. All the lists (except the Data Files
one) will add an item and allow you to edit it to insert the module
you wish. The Data File list will open a file dialog that allows you
to choose a bunch of data files you want to include in one shot;
- GUI2Exe starts the py2exe compilation as an external process
(calling Python -u and using wx.Process/wx.Execute) and it monitors
the output and error streams of this process;
- The bottom window is a log window, that shows messages, warnings,
errors and it contains 3 buttons: Dry-Run, Compile and Kill. The
Dry-Run button will call py2exe but no real compilation will take
place. The Compile button will actually build your executable, and the
Kill button will attempt to kill a running py2exe building process.
There are few caveats about the Dry-Run and Kill buttons, see below.
Features
-------------
GUI2Exe has a number of features, namely:
- Saves and store your work in a database, displaying all your
projects in a tree control. To load an existing projects, simply
double click on it;
- Possibility to export the Setup.py file (menu File => Export setup
file...), even though you shouldn't ever need anymore to have a
Setup.py file. Everything is done automagically inside GUI2Exe;
- Allows the user to insert custom Python code in the "in-memory"
Setup.py file, which will be properly included at runtime during the
building process (menu Options => Add custom code...);
- Ability to test the executable: if the executable crashes (for
whatever reason), GUI2Exe will notice it and report to you the
traceback for inspection (menu Options => Test executable);
- After a building process, choosing the menu View => Missing modules
or View => Binary dependencies, you will be presented respectively
with a list of modules py2exe thinks are missing or a list of binary
dependencies (dll) py2exe has found;
- I built also a page that tries to explain all the py2exe
switches/options available, and how they mix with GUI2Exe. You can see
it by choosing the menu View => Compiler switches;
- As all of my GUIs, GUI2Exe is based on wxAUI for the interface
design. You can save and load "perspectives" (i.e., interface
appearances);
- The GUI2Exe "user guide" is still a work in progress: the
documentation at the moment includes the epydoc-generated API for
GUI2Exe. The code is quite well commented, but there is no user guide
for GUI2Exe. See below for a couple of examples.
Caveats
------------
There are few caveats about py2exe and wxPython that I wasn't able to
solve till now.
py2exe
Assuming that the following events happen simultaneously:
-You never built the executable for your main script, so the file
YourScript.exe doesn't exist;
-You choose the Dry-Run option.
py2exe will crash with a system error saying that the file py2exe is
looking for (YourScript.exe) can not be found. Yes, I knew that, it's
a *Dry-Run*, so py2exe shouldn't look for any executable file.
However, if you apply the attached patch to
/site-packages/py2exe/build_exe.py, the problem should be fixed.
wxPython
It looks like it is impossible to kill the py2exe process once it
started. I tried with wx.Process.Kill(process_Id, wx.SIGTERM), but no
way. Trying with wx.Process.Kill(process_Id, wx.SIGKILL) cause Python
to crash with the classical Windows error dialog. Moreover, if the
process ends normally, calling wx.Process.Destroy() will crash Python
as above.
bsddb
Every time you restart the application, bsddb gives you back the
projects stored in the database sorted *by project name*. I was
convinced that it should have ordered them based on *when* they were
added, but this is easy to fix.
Interface
On the 2 Windows machines I tried GUI2Exe, the interface looked
reasonably good. I can not test it on my Ubuntu Virtual Machine
because, after the upgrade to Edgy 6.10, everything stopped working. I
can't obviously test it on Mac. I don't know if the GUI will even
start on GTK or Mac, but if someone manages to run it, please send me
a screenshot of it
Examples
---------------
Hereafter I show a couple of examples on how to use GUI2Exe.
Simple one
We will build the sample file that comes with py2exe, on:
/site-packages/py2exe/sample/singlefile/gui/test_wx.py
1) With the GUI opened, hit Ctrl+N or choose File => New project...
2) Enter a name for the new project, i.e. "pyexe sample file"
3) In the central window that appears, under Python Main Script,
browse to search for the aforementioned file;
4) On the Optimize, Compressed and Bundle Files drop down choices,
choose 2, 2, 1 respectively;
5) Scroll down the central window to the bottom and check the XP
Manifest File option;
6) Click on the Compile button.
And you're done. You can follow the compilation steps in the bottom
log window as py2exe builds your executable.
Less simpler one
We will build the wxPython demo as executable.
1) With the GUI opened, hit Ctrl+N or choose File => New project...
2) Enter a name for the new project, i.e. "wxPython demo"
3) In the central window that appears, under Python Main Script,
browse to search for the file /YourPathToTheDemo/demo/Main.py;
4) On the Optimize, Compressed and Bundle Files drop down choices,
choose 2, 2, 1 respectively;
5) On the Packages list, hit Ctrl+A twice and edit the items to be wx
and wx.lib respectively;
6) On the Data Files list, hit Ctrl+A, browse with the file dialog to
/YourPathToTheDemo/demo/bitmaps and select all the files. Do the same
thing for the folders bmp_source and data.
7) Scroll down the central window to the bottom and check the XP
Manifest File option;
8) Click on the Compile button.
And you're done. You can follow the compilation steps in the bottom
log window as py2exe builds your executable.
Source code (for those who use wxPython and py2exe, 400 KB) and a
Windows installer (for those who wants to try iit without having
wxPython, 7.1 MB) are available in the usual place:
http://xoomer.alice.it/infinity77/eng/freeware.html#gui2exe
Comments, suggestions, criticisms about the implementation, the
interface, the easiness (or uneasiness) of use and on the usefulness
(or uselessness) of this package are as always extremely welcome.
wxPython rules
Andrea.
"Imagination Is The Only Weapon In The War Against Reality."
http://xoomer.virgilio.it/infinity77/