anti-particle.com
Home  About  Old News  Links 
 Become The Media A "100% Vegan" Production 
. : py2exe how-to : .

. : Python : .
» pygtk / py2exe 0.4.x how-to
  How-to build standalone windows executables for GTK+2.0 using py2exe 0.4.x
» pygtk / py2exe 0.5.x how-to
  How-to build standalone windows executables for GTK+ 2.2 or 2.4 using py2exe 0.5.x
   
 
. : Overview : .
Here's a How-To on generating stand-alone executables for pygtk programs using py2exe 0.5.x.  This seems to work for at least pygtk 2.4.x and 2.6.x.   Any comments, please email me: py2exe at anti-particle dot com.
A big, big thanks to Nikos Kouremenos for providing 99.9% of the information for this how-to.
 
. : Initial Installation (Windows OS): .
1) Install the latest version of python. You may need to add the install location to your PATH environment variable...
  e.g. c:\python23
2) Install the latest version of GTK+ for windows.
3) Install the latest version of pygtk for windows.
4) Install py2exe 0.5.x.
5) Install the installer! Inno Setup.
6) A useful extra is ISTool which can edit and recompile the scripts Inno Setup produces.
 
. : Configure py2exe for your project : .
1) Build a setup.py file. Here is one I used for Jajouka:
# setup.py
from distutils.core import setup
import py2exe
import glob

opts = {
    "py2exe": {
        "includes": "pango,atk,gobject",
        "dll_excludes": [
        "iconv.dll","intl.dll","libatk-1.0-0.dll",
        "libgdk_pixbuf-2.0-0.dll","libgdk-win32-2.0-0.dll",
        "libglib-2.0-0.dll","libgmodule-2.0-0.dll",
        "libgobject-2.0-0.dll","libgthread-2.0-0.dll",
        "libgtk-win32-2.0-0.dll","libpango-1.0-0.dll",
        "libpangowin32-1.0-0.dll"],
        }
    }

setup(
    name = "Jajouka",
    description = "A nice GUI interface for those with GiantDisc jukebox systems.",
    version = "0.61",
    windows = [
        {"script": "jajouka.py",
        "icon_resources": [(1, "jajouka.ico")]
        }
    ],
    options=opts,
    data_files=[("jajouka.conf"),
                ("pixmaps", glob.glob("pixmaps/*.png")),
                ("glade", glob.glob("glade/*.*"))
    ],
)
 
. : Build the executable : .
From a command prompt in your project_name folder, run:
python setup.py py2exe
This should create a dist folder in your project folder.
 
. : GTK+ Runtime files : .
A GTK+ runtime for windows will also need to be installed for the standalone executable. Get that from here.
At this point you should have something that works. Try it out by copying the dist folder to a clean PC and giving it a go...
 
. : Build the installer : .
Start Inno Setup and use the wizard to build a project... More info to follow here soon (hopefully)...
 
. : Last update: Friday, 14-Jun-2013 16:11:26 BST : .
Initial Design: Copyleft © 02001 Jaden
The Rest: Copyleft © 02002-02006 Andy Balcombe