GUI2Exe - 0.2alpha

(01-Apr-2007)

Warning: This GUI2Exe version is now obsolete! You should use the Python source code hosted at googlecode, and specifically here: http://code.google.com/p/gui2exe/

GUI2Exe is (my) first attempt to unify all the available "executable builders" for Python in a single and simple to use graphical user interface. The new version of GUI2Exe supports the following compilers:

  • py2exe (Windows)
  • py2app (Mac OS)
  • PyInstaller (all platforms)
  • cx_Freeze (Windows and Linux)
  • bbFreeze (Windows and Linux)

If you wish to jump straight ahead to the download section, please click this link.



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 step toward the Great Theory of Unification.

 

How does it work?

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. This window contains a set of widgets, the usage of most of them is very simple. However, some of the other options require a bit more UI interaction with the user. For example, for py2exe, for the following options:
    1. Includes
    2. Packages
    3. Excludes
    4. Dll Excludes
    5. Ignores
    6. Data Files
    7. 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, or right-click on the list and select the popup menu "Add item(s)". 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, or to choose a directory, recurse on it and include all the files and sub-folders in that directory;

  • GUI2Exe starts the building process 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 is implemented only for py2exe. By clicking it, GUI2Exe 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 building process. There are few caveats about the Dry-Run action, see below.

 

Features

GUI2Exe has a number of features, namely:

  • Saves and stores your work in a database, displaying all your projects in a tree control. To load an existing project, 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;
  • Ability to change the Python version to use to build the executable (menu Options => Change Python version);
    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...);
  • Allows the user to add post-processing custom code, which will be executed at the end of the building process. Useful for cleaning up (menu Options => Insert post compilation code);
  • Possibility to view the full build output coming from the compiler (menu Builds => Show full build output);
  • Allows the user to add data_files (for the executable builders that support this option) either by selecting a bunch of files all together or using a directory-recursive approach, which will include all files and sub-folders in the selected folders as data_files (menu Options => Recurse sub-dirs for data_files option);
  • "Super" tooltips for Windows & GTK users to better understand the various options (menu Options => Show tooltips);
  • GUI2Exe projects can be saved also to a file (and not only in the database): the exported project may then be checked into version control software like CVS or SVN, modified and then reloaded intoGUI2Exe (menu File => Save project as...);
  • [py2exe-only]: 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 Builds => Test executable);
  • [py2exe-only]: After a building process, choosing the menu Builds => Missing modules or Builds => 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, py2app, PyInstaller, cx_Freeze and bbFreeze switches/options available, and how they mix with GUI2Exe. You can see it by choosing the menu Help => 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 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 this patch to /site-packages/py2exe/build_exe.py, the problem should be fixed.


Interface

On the 2 Windows PCs and on the Ubuntu Hardy Virtual Machine I tried GUI2Exe, , the interface looked reasonably good. I can't obviously test it on Mac. I don't know if the GUI will start on Mac, and if the code I wrote for py2app will work. In any case, screenshots from other platforms (GTK and Mac) are always very welcome.

 

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 the Target Class box, right click on the list control and select "Add item(s)";
  4. Left click on the new item in Exe Kind column and select "windows";
  5. Left click on the new item in the Python Main Script column and browse to search for the aforementioned file;
  6. On the Optimize, Compressed and Bundle Files drop down choices, choose 2, 2, 1 respectively;
  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.

Less simpler one

We will build the wxPython demo as executable, using py2exe.

  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 the Target Class box, right click on the list control and select "Add item(s)";
  4. Left click on the new item in Exe Kind column and select "windows";
  5. Left click on the new item in the Python Main Script column and browse to search for the file /YourPathToTheDemo/demo/Main.py;
  6. On the Optimize, Compressed and Bundle Files drop down choices, choose 2, 2, 1 respectively;
  7. Check the Dist Directory checkbox and write a new name for the distribution directory in the text box below (i.e., "py2exe");
  8. On the Packages list, hit Ctrl+A twice and edit the items to be wx and wx.lib respectively;
  9. 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.
  10. On the Data Files list, hit Ctrl+A, browse with the file dialog to /YourPathToTheDemo/demo and select all the files. In the dialog which will appear next simply write "." (a dot);
  11. Scroll down the central window to the bottom and check the XP Manifest File option;
  12. 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.





Download GUI2Exe Source

Download GUI2Exe Installer

Python/Executable Files



Screenshots on Mac

(Courtesy of John Jackson And Paulo Nuin)