PyGTK and pyexe

Discussion in 'Python' started by Viktor, Mar 18, 2005.

  1. Viktor

    Viktor Guest

    Did anybody managed to "pack", a program that uses pygtk with pyexe?

    The best result I got was:

    Pango-ERROR **: file shape.c: line 75 (pango_shape): assertion faled:
    (glyphs->num_glyphs > 0) aborting...

    I'm using python2.4, pygtk-2.6.1-1.win32-py2.4, gtk-win32-2.6.4-rc1.

    Thanks in advance.
    Viktor, Mar 18, 2005
    #1
    1. Advertising

  2. Viktor

    Tom Cocagne Guest

    I used the instructions in the PyGTK FAQ and managed to get it working.
    Take a look at:

    http://www.async.com.br/faq/pygtk/index.py?req=show&file=faq21.005.htp

    Cheers,

    Rakis

    Viktor wrote:

    > Did anybody managed to "pack", a program that uses pygtk with pyexe?
    >
    > The best result I got was:
    >
    > Pango-ERROR **: file shape.c: line 75 (pango_shape): assertion faled:
    > (glyphs->num_glyphs > 0) aborting...
    >
    > I'm using python2.4, pygtk-2.6.1-1.win32-py2.4, gtk-win32-2.6.4-rc1.
    >
    > Thanks in advance.
    Tom Cocagne, Mar 19, 2005
    #2
    1. Advertising

  3. Viktor

    Viktor Guest

    Nope, it doesn't work... I've tried that and the only thing I got was:

    ImportError: could not import pango
    ImportError: could not import pango
    Traceback (most recent call last):
    File "test.py", line 5, in ?
    File "gtk\__init__.pyc", line 113, in ?
    AttributeError: 'module' object has no attribute 'Font'

    But it has:

    >>> import pango
    >>> dir(pango).index('Font')

    71


    The only way it works is with this setup.py:

    .........................................................................

    from distutils.core import setup
    import py2exe
    import glob

    opts = {
    "py2exe": {
    "includes": ["pango", "atk", "gobject", "gtk"],
    "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 = "test",
    description = "Test GUI programm",
    version = "0.1",
    windows = [{
    "script": "test.py",
    "icon_resources": [(1, "test.ico")]
    }],
    options=opts,
    data_files=[("pixmaps", glob.glob("pixmaps/*.png")),
    ("glade", glob.glob("glade/*.*"))
    ],
    )

    .........................................................................

    But it's not stand-alone, it needs GTK, and when I copy all the dlls
    needed in the dist directory, I get the same message as before.

    Pango-ERROR **: file shape.c: line 75 (pango_shape): assertion faled:
    (glyphs->num_glyphs > 0) aborting...

    By the way, I'm allways getting this message at the end:

    The following modules appear to be missing
    ['gdk', 'ltihooks']
    Viktor, Mar 19, 2005
    #3
  4. Viktor

    Tom Cocagne Guest

    Hmmmm. Well, the way I did it, if I remember correctly (the files are at
    work), was to run the line "python setup.py py2exe --force --excludes gtk,
    gobject,pango" and then copied the entire GTK directory into the
    distribution directory. Just copying the DLLs doesn't suffice since there
    are other files required for GTK to operate properly (config files, icons,
    etc, etc). Once I got it working, I tried removing files from the GTK tree
    that didn't look important and was able to halve the size of the resulting
    package.

    It took a while to figure out the first time but all subsequent builds have
    been as simple as running that one python command and copying my custom GTK
    directory into the dist directory.

    Without being at my desk, that's the best I explanation I can give. If
    Monday rolls around and you still don't have it working, send an e-mail to
    my work account: tom [dot] cocagne [at] navy [dot] mil and I'll give you a
    few more specifics.

    Cheers,

    Tom


    Viktor wrote:

    > Nope, it doesn't work... I've tried that and the only thing I got was:
    >
    > ImportError: could not import pango
    > ImportError: could not import pango
    > Traceback (most recent call last):
    > File "test.py", line 5, in ?
    > File "gtk\__init__.pyc", line 113, in ?
    > AttributeError: 'module' object has no attribute 'Font'
    >
    > But it has:
    >
    >>>> import pango
    >>>> dir(pango).index('Font')

    > 71
    >
    >
    > The only way it works is with this setup.py:
    >
    > ........................................................................
    >
    > from distutils.core import setup
    > import py2exe
    > import glob
    >
    > opts = {
    > "py2exe": {
    > "includes": ["pango", "atk", "gobject", "gtk"],
    > "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 = "test",
    > description = "Test GUI programm",
    > version = "0.1",
    > windows = [{
    > "script": "test.py",
    > "icon_resources": [(1, "test.ico")]
    > }],
    > options=opts,
    > data_files=[("pixmaps", glob.glob("pixmaps/*.png")),
    > ("glade", glob.glob("glade/*.*"))
    > ],
    > )
    >
    > ........................................................................
    >
    > But it's not stand-alone, it needs GTK, and when I copy all the dlls
    > needed in the dist directory, I get the same message as before.
    >
    > Pango-ERROR **: file shape.c: line 75 (pango_shape): assertion faled:
    > (glyphs->num_glyphs > 0) aborting...
    >
    > By the way, I'm allways getting this message at the end:
    >
    > The following modules appear to be missing
    > ['gdk', 'ltihooks']
    Tom Cocagne, Mar 20, 2005
    #4
  5. Viktor

    Viktor Guest

    I succeeded :)))

    And the winner is:

    .........................................................................

    from distutils.core import setup
    import py2exe

    opts = {
    "py2exe": {
    "includes": ["pango", "atk", "gobject", "gtk","gtk.glade"],
    "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",
    "libxml2", "libglade-2.0-0", "zlib1"]
    }
    }

    setup(
    name = "PyGTKTest",
    description = "PyGTK Test Application",
    version = "0.1",
    windows = [{"script": "test.py", "icon_resources": [(1,
    "test.ico")]}],
    options=opts,
    data_files=[("", ["test.glade"])]
    )

    ........................................................................

    Py2exe reports an error if I try to use --force (the command doesn't
    exist), so I use only:

    python setup.py py2exe --exclude
    gobject,glib,gtk,glade,pango,atk,libglade,xml2,zlib

    After that I make a new directory, say MyApp, copy the entire content
    of
    the GTK folder (I'm using the GTK Runtime Enviroment from
    gladewin32.sourceforge.net) in MyApp, and then copy the content of the
    dist folder into MyApp\bin.

    Now I can uninstall GTK Runtime Enviroment, and Python, and it works
    :).

    But it's pretty big, what files can I remove? (OK, I know... locales,
    man
    pages, examples :), but what more - it's still > 20 MB?)
    Viktor, Mar 21, 2005
    #5
  6. Viktor

    Tom Cocagne Guest

    I remember removing the locales and all of the documentation. Beyond that
    I can't remember. If your app falls under the common case of running on
    machines with ample disk space, I wouldn't worry too much about the size.
    WinZip does a pretty good job of shrinking my distribution file to a
    managable size for network transfer.

    Tom

    Viktor wrote:

    > I succeeded :)))
    >
    > And the winner is:
    >
    > ........................................................................
    >
    > from distutils.core import setup
    > import py2exe
    >
    > opts = {
    > "py2exe": {
    > "includes": ["pango", "atk", "gobject", "gtk","gtk.glade"],
    > "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",
    > "libxml2", "libglade-2.0-0", "zlib1"]
    > }
    > }
    >
    > setup(
    > name = "PyGTKTest",
    > description = "PyGTK Test Application",
    > version = "0.1",
    > windows = [{"script": "test.py", "icon_resources": [(1,
    > "test.ico")]}],
    > options=opts,
    > data_files=[("", ["test.glade"])]
    > )
    >
    > .......................................................................
    >
    > Py2exe reports an error if I try to use --force (the command doesn't
    > exist), so I use only:
    >
    > python setup.py py2exe --exclude
    > gobject,glib,gtk,glade,pango,atk,libglade,xml2,zlib
    >
    > After that I make a new directory, say MyApp, copy the entire content
    > of
    > the GTK folder (I'm using the GTK Runtime Enviroment from
    > gladewin32.sourceforge.net) in MyApp, and then copy the content of the
    > dist folder into MyApp\bin.
    >
    > Now I can uninstall GTK Runtime Enviroment, and Python, and it works
    > :).
    >
    > But it's pretty big, what files can I remove? (OK, I know... locales,
    > man
    > pages, examples :), but what more - it's still > 20 MB?)
    Tom Cocagne, Mar 21, 2005
    #6
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Tad Marko

    PyGTK and fonts

    Tad Marko, Sep 9, 2003, in forum: Python
    Replies:
    2
    Views:
    4,957
  2. Luca Masini

    freezy.py and pygtk

    Luca Masini, Oct 4, 2003, in forum: Python
    Replies:
    0
    Views:
    341
    Luca Masini
    Oct 4, 2003
  3. Hans Deragon
    Replies:
    2
    Views:
    438
    GrayGeek
    Oct 11, 2003
  4. Fulko van Westrenen

    pyGTK, Buttons and Pixmaps problem

    Fulko van Westrenen, Nov 27, 2003, in forum: Python
    Replies:
    2
    Views:
    371
    Fulko van Westrenen
    Nov 28, 2003
  5. hg

    pyexe "format"

    hg, Jun 10, 2007, in forum: Python
    Replies:
    4
    Views:
    735
Loading...

Share This Page