Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Fix building when Gtk doesn't support version check #1900

Closed
wants to merge 1 commit into from

4 participants

@markvoorhies

This is a quick patch to fix a build problem that I ran into this morning when updating matplotlib via pyston on my Ubuntu 12 laptop. I haven't dug into this deeply, but this
is my current understanding (and the patch does fix the build problem on my laptop):

python setup.py install --user
fails with
AttributeError: 'gi.repository.Gtk' object has no attribute 'get_major_version'

for old versions of Gtk without support for introspection
(specifically, on Ubuntu 12 with python-gtk2 2.24.0-3)

This commit silently drops the associated exceptions for the two Gtk
version checks in setupext.py

@markvoorhies markvoorhies Patch for Gtk w/o introspection support
python setup.py install --user
fails with
AttributeError: 'gi.repository.Gtk' object has no attribute 'get_major_version'

for old versions of Gtk without support for introspection
(specifically, on Ubuntu 12 with python-gtk2 2.24.0-3)

This commit silently drops the associated exceptions for the two Gtk
version checks in setupext.py
627793f
@pelson
Collaborator

Thanks @markvoorhies. LGTM :+1:

@mdboom
Owner
@efiring
Owner

@markvoorhies, I suspect you don't actually have the full gtk3 dependencies installed. It works on my Ubuntu Precise VM. I suspect this is the version of Ubuntu you have. Have you installed the python-gobject package? It should pull in python-gi and python-gobject-2, and I think that is what it takes.

@mdboom
Owner

Sorry for not notating this earlier, but I think this is a duplicate of #1949. @markvoorhies: can you confirm that resolves the issue. #1949 explicitly says "I want Gtk 3 when using gobject introspection" -- it therefore should guarantee that the new version-getting API is there.

@markvoorhies

@mdboom Looks like that fixed it =)

Matplotlib 9e734b6 builds and runs while the build error reproduces for 9e477b3.

@efiring yep, the laptop is Ubuntu Precise amd64:

mvoorhie@virgil:~$ cat /etc/issue
Ubuntu 12.04.2 LTS \n \l

mvoorhie@virgil:~$ uname -a
Linux virgil 3.2.0-39-generic #62-Ubuntu SMP Thu Feb 28 00:28:53 UTC 2013 x86_64 x86_64 x86_64 GNU/Linux

mvoorhie@virgil:~$ dpkg -l | grep -i gobject | grep python
ii python-gi 3.2.2-1~precise Python 2.x bindings for gobject-introspection libraries
ii python-gobject 3.2.2-1~precise Python 2.x bindings for GObject - transitional package
ii python-gobject-2 2.28.6-10ubuntu1 deprecated static Python bindings for the GObject library

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Apr 12, 2013
  1. @markvoorhies

    Patch for Gtk w/o introspection support

    markvoorhies authored
    python setup.py install --user
    fails with
    AttributeError: 'gi.repository.Gtk' object has no attribute 'get_major_version'
    
    for old versions of Gtk without support for introspection
    (specifically, on Ubuntu 12 with python-gtk2 2.24.0-3)
    
    This commit silently drops the associated exceptions for the two Gtk
    version checks in setupext.py
This page is out of date. Refresh to see the latest.
Showing with 14 additions and 10 deletions.
  1. +14 −10 setupext.py
View
24 setupext.py
@@ -1408,11 +1408,13 @@ def backend_gtk3agg_internal_check(x):
if sys.version_info[0] >= 3:
return (False, "gtk3agg does not work on Python 3")
- return (True, "version %s.%s.%s" % (
- Gtk.get_major_version(),
- Gtk.get_micro_version(),
- Gtk.get_minor_version()))
-
+ try:
+ return (True, "version %s.%s.%s" % (
+ Gtk.get_major_version(),
+ Gtk.get_micro_version(),
+ Gtk.get_minor_version()))
+ except AttributeError:
+ return (True, "version unknown")
class BackendGtk3Agg(OptionalBackendPackage):
name = "gtk3agg"
@@ -1450,11 +1452,13 @@ def backend_gtk3cairo_internal_check(x):
except ImportError:
return (False, "Requires pygobject to be installed.")
- return (True, "version %s.%s.%s" % (
- Gtk.get_major_version(),
- Gtk.get_micro_version(),
- Gtk.get_minor_version()))
-
+ try:
+ return (True, "version %s.%s.%s" % (
+ Gtk.get_major_version(),
+ Gtk.get_micro_version(),
+ Gtk.get_minor_version()))
+ except AttributeError:
+ return (True, "version unknown")
class BackendGtk3Cairo(OptionalBackendPackage):
name = "gtk3cairo"
Something went wrong with that request. Please try again.