After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 622963 - Re-enable Python plugins
Re-enable Python plugins
Status: RESOLVED FIXED
Product: totem
Classification: Core
Component: Plugins
2.90.x
Other All
: Normal normal
: ---
Assigned To: General Totem maintainer(s)
General Totem maintainer(s)
Depends on: 551290 620062 620912 622882 622943 622951 622961 622987 623068 623229 625650
Blocks: 626218
 
 
Reported: 2010-06-27 17:08 UTC by Philip Withnall
Modified: 2010-11-14 15:24 UTC
See Also:
GNOME target: 3.0
GNOME version: ---


Attachments
Work around bgo#620912 (3.83 KB, patch)
2010-07-30 09:20 UTC, Philip Withnall
committed Details | Review

Description Philip Withnall 2010-06-27 17:08:55 UTC
Re-enabling Python plugins requires gobject-introspection support and some changes to pygobject.

The relevant work in Totem is all there in this branch: http://git.gnome.org/browse/totem/log/?h=introspection

This requires pygobject master with the patches from bug #622882 and bug #622951. It also requires the totem-pl-parser patch from bug #622961 and the GTK+ patch from bug #622943.

For some reason, Totem needs to be run from $libdir/python2.6/site-packages/gtk-2.0 for Python to be able to find and import the gi module. This might just be my setup, or it might be a bug in pygobject.

The branch contains commits to port all the Python plugins to the gobject-introspection New World Order, but the ones which use threading (iPlayer, Jamendo and OpenSubtitles) are all currently broken, as Python threading doesn't work in libpeas yet (bug #620062).

There's also a problem with sensitivity of the "Configure" button in the plugins dialogue for the Python plugins — it's always sensitive. This seems to be a problem with Python figuring out the interfaces that the plugin classes implement.

In a similar vein, the only plugin which needs configuration at the moment (the Jamendo plugin) crashes Totem when you try to open its configuration dialogue.

Other than that, Python plugins work again!
Comment 1 Philip Withnall 2010-06-27 17:59:32 UTC
(In reply to comment #0)
> The branch contains commits to port all the Python plugins to the
> gobject-introspection New World Order, but the ones which use threading
> (iPlayer, Jamendo and OpenSubtitles) are all currently broken, as Python
> threading doesn't work in libpeas yet (bug #620062).

Attachment #164759 [details] fixes this, and the threaded plugins work (modulo the remaining API change problems) with it applied.

> There's also a problem with sensitivity of the "Configure" button in the
> plugins dialogue for the Python plugins — it's always sensitive. This seems to
> be a problem with Python figuring out the interfaces that the plugin classes
> implement.

This has been fixed with http://git.gnome.org/browse/libpeas/commit/?id=907db927685896ea0b315c7e3efc8b65d9fbe067.
Comment 2 Philip Withnall 2010-06-27 22:22:09 UTC
The tree view stuff in the Jamendo plugin requires bug #622987 to be fixed.
Comment 3 Philip Withnall 2010-06-30 18:18:03 UTC
Before I can push this all, there's bug #623229 to stop Totem crashing when the Python plugin loader fails to load because of gi's path problems.
Comment 4 Philip Withnall 2010-06-30 18:27:12 UTC
commit bd9fd4fff3960ed9ba48bb42f69da33f263981e5
Merge: b87d5fa e5394da
Author: Philip Withnall <philip@tecnocode.co.uk>
Date:   Wed Jun 30 18:55:02 2010 +0100

    Merge branch 'introspection'

commit e5394da4d2b8025e4080eb35c170653a3c31051d
Author: Philip Withnall <philip@tecnocode.co.uk>
Date:   Sun Jun 27 23:20:45 2010 +0100

    Fix binding of TotemObject.action_error()

 src/plugins/screenshot/totem-screenshot-plugin.c |    4 +-
 src/totem-object.c                               |   34 +++++++++++-----------
 src/totem.h                                      |    6 ++--
 3 files changed, 22 insertions(+), 22 deletions(-)

commit 0d9e72a80eccc8b8f23e0aa8ec6049cf6cc3edc1
Author: Philip Withnall <philip@tecnocode.co.uk>
Date:   Sun Jun 27 23:20:35 2010 +0100

    More jamendo plugin fixes

 src/plugins/jamendo/jamendo.py |   23 ++++++++---------------
 1 files changed, 8 insertions(+), 15 deletions(-)

commit cfcf946c775172f98984e5c024e02ad71749c7c9
Author: Philip Withnall <philip@tecnocode.co.uk>
Date:   Sun Jun 27 16:57:27 2010 +0100

    Port sample-python plugin to libpeas

 src/plugins/sample-python/sample-python.py |   15 +++++++--------
 1 files changed, 7 insertions(+), 8 deletions(-)

commit 881dfe85a7d732b590312bebae440dfc753e3e4e
Author: Philip Withnall <philip@tecnocode.co.uk>
Date:   Sun Jun 27 16:49:42 2010 +0100

    Port pythonconsole plugin to libpeas
 src/plugins/pythonconsole/console.py       |   59 ++++++++++++++--------------
 src/plugins/pythonconsole/pythonconsole.py |   50 +++++++++++++----------
 2 files changed, 58 insertions(+), 51 deletions(-)

commit 1b43d0db44bedb684aee35556400e8ed3396b198
Author: Philip Withnall <philip@tecnocode.co.uk>
Date:   Sun Jun 27 15:51:04 2010 +0100

    Port opensubtitles plugin to libpeas
    
    The interface works, but downloading subtitles is untested due to it
    requiring threading.

 src/plugins/opensubtitles/opensubtitles.py |   84 ++++++++++++++-------------
 1 files changed, 44 insertions(+), 40 deletions(-)

commit 6806dd04450ced2095a09709fe5ce10b37cbe02a
Author: Philip Withnall <philip@tecnocode.co.uk>
Date:   Sun Jun 27 13:35:24 2010 +0100

    Port jamendo plugin to libpeas
    
    The configuration dialogue doesn't work and neither does searching, as it
    relies on Python threading.

 src/plugins/jamendo/jamendo.py |   83 ++++++++++++++++++++--------------------
 1 files changed, 41 insertions(+), 42 deletions(-)

commit 1a15a7120357cf715d874428192743237a5bdd91
Author: Philip Withnall <philip@tecnocode.co.uk>
Date:   Sun Jun 27 12:39:21 2010 +0100

    Port dbus-service plugin to libpeas

 src/plugins/dbus-service/dbus-service.py |   33 +++++++++++++++--------------
 1 files changed, 17 insertions(+), 16 deletions(-)

commit c8674f3da9a3bb6879ae0efb8da855efafe826dd
Author: Philip Withnall <philip@tecnocode.co.uk>
Date:   Sun Jun 27 11:53:26 2010 +0100

    Port coherence_upnp plugin to libpeas
    
    The code has been ported, but the plugin has to be disabled as it depends on
    the Coherence library, which still uses PyGTK.

 configure.in                                 |    5 +++++
 src/plugins/coherence_upnp/coherence_upnp.py |   19 +++++++++++--------
 2 files changed, 16 insertions(+), 8 deletions(-)

commit 8014ce3ff6aa7cf4fbf1fbcb8220c478feb4630c
Author: Philip Withnall <philip@tecnocode.co.uk>
Date:   Sun Jun 27 01:01:28 2010 +0100

    Port iplayer plugin to libpeas
    
    It doesn't currently work due to lack of support for Python threads, but the
    interface loads.

 src/plugins/iplayer/iplayer.py  |   24 ++++++++++++++++--------
 src/plugins/iplayer/iplayer2.py |   10 +++++++---
 2 files changed, 23 insertions(+), 11 deletions(-)

commit a6ad2e75b4023b717bda0ecadd62444106698d18
Author: Philip Withnall <philip@tecnocode.co.uk>
Date:   Sun Jun 27 16:57:55 2010 +0100

    Move methods from Totem to TotemObject for use in plugins
    
    g-ir-scanner will assign methods named "totem_foo" to the Totem record, so
    they all need to be renamed to "totem_object_foo" so that they're correctly
    assigned to the TotemObject class.
    
    This just changes the method declarations and definitions, and adds a #define
    for each method so that the old name continues to work in Totem code. This
    can be tidied up in a later commit, possibly at the same time as tidying up
    Totem's plugin-visible API.

 docs/reference/totem-sections.txt |   56 +++---
 src/totem-object.c                |  344 ++++++++++++++++++------------------
 src/totem.h                       |  136 +++++++++------
 3 files changed, 282 insertions(+), 254 deletions(-)

commit a23e06d4ea6eef6e00c7b633db37120cd022ff64
Author: Philip Withnall <philip@tecnocode.co.uk>
Date:   Sun Jun 27 01:01:15 2010 +0100

    Re-enable Python plugins support

 configure.in                       |    5 +----
 src/plugins/totem-plugins-engine.c |    6 ++----
 2 files changed, 3 insertions(+), 8 deletions(-)

commit a7f2c8abebae482c2225973c4f4d94dd31841648
Author: Philip Withnall <philip@tecnocode.co.uk>
Date:   Sun Jun 27 00:09:42 2010 +0100

    Remove Python and Vala bindings
    
    Python and Vala plugins should be ported to use the introspected bindings.

 Makefile.am                       |    2 +-
 bindings/Makefile.am              |    9 -
 bindings/python/Makefile.am       |   65 -----
 bindings/python/__init__.py       |   50 ----
 bindings/python/override_common.c |  189 -------------
 bindings/python/override_common.h |   50 ----
 bindings/python/totem.defs        |  537 -------------------------------------
 bindings/python/totem.override    |  117 --------
 bindings/python/totemmodule.c     |  230 ----------------
 bindings/vala/Makefile.am         |    3 -
 bindings/vala/totem.deps          |    1 -
 bindings/vala/totem.vapi          |  127 ---------
 configure.in                      |   62 +----
 13 files changed, 5 insertions(+), 1437 deletions(-)
Comment 5 Philip Withnall 2010-06-30 18:32:48 UTC
Totem master now has Python plugins re-enabled, although not all of them work. Notably, the Jamendo, OpenSubtitles and iPlayer plugins are still waiting on bindings fixes (and corresponding changes in the plugins themselves) before they work, although they should load and function partially at the moment.

The most pressing problem is that the Python plugin loader won't load at the moment unless Totem is run in $libdir/python2.6/site-packages/gtk-2.0, since it won't find the Python gi module.
Comment 6 Johan (not receiving bugmail) Dahlin 2010-07-06 13:54:10 UTC
(In reply to comment #5)
[..]
> The most pressing problem is that the Python plugin loader won't load at the
> moment unless Totem is run in $libdir/python2.6/site-packages/gtk-2.0, since it
> won't find the Python gi module.

That can be resolved by doing pygtk.require("2.0") before importing gi.
Comment 7 Philip Withnall 2010-07-07 19:51:57 UTC
(In reply to comment #6)
> (In reply to comment #5)
> [..]
> > The most pressing problem is that the Python plugin loader won't load at the
> > moment unless Totem is run in $libdir/python2.6/site-packages/gtk-2.0, since it
> > won't find the Python gi module.
> 
> That can be resolved by doing pygtk.require("2.0") before importing gi.

I thought we'd moved away from pygtk? Certainly none of the Totem plugins now require it. It would have to be pygtk.require("3.0") anyway, since Totem's moved to GTK+ 3.
Comment 8 Philip Withnall 2010-07-07 21:14:59 UTC
(In reply to comment #5)
> Totem master now has Python plugins re-enabled, although not all of them work.
> Notably, the Jamendo, OpenSubtitles and iPlayer plugins are still waiting on
> bindings fixes (and corresponding changes in the plugins themselves) before
> they work, although they should load and function partially at the moment.

Still problems.

> The most pressing problem is that the Python plugin loader won't load at the
> moment unless Totem is run in $libdir/python2.6/site-packages/gtk-2.0, since it
> won't find the Python gi module.

Turns out that this was a problem with my environment. Python's sys.prefix must point to the right place (in my case, my dev prefix) _or_ you need to manually add $(libdir)/python2.6/site-packages/gtk-2.0 to your PYTHONPATH to get the imports working in a dev environment. It should work fine if installed in the same prefix as your Python installation.
Comment 9 Philip Withnall 2010-07-30 09:15:05 UTC
We depend on bug #620912 for functions like Gtk.TreeModel.iter_parent(), which return an extraneous boolean success value.
Comment 10 Philip Withnall 2010-07-30 09:20:58 UTC
Created attachment 166815 [details] [review]
Work around bgo#620912

Hacky patch to work around bug #620912 in the iPlayer plugin. Not committed, but we can commit later if bug #620912 doesn't get fixed before release.
Comment 11 Philip Withnall 2010-07-30 12:03:07 UTC
Some more minor annotation problems: bug #625650.
Comment 12 Philip Withnall 2010-10-23 16:40:19 UTC
I've timed out and committed the workaround for bug #620912. Once the patch in bug #622987 is committed, I think this bug can be closed, since there'll just be some mopping up around the edges to do.

commit 03351c51014ce6cd00000beaf2aab632806ba23f
Author: Philip Withnall <philip@tecnocode.co.uk>
Date:   Sat Oct 23 17:37:09 2010 +0100

    UTF-8 encode strings in the iPlayer plugin
    
    Due to bgo#60579, PyGObject will no longer accept Python Unicode objects as
    strings, so we need to UTF-8 encode them explicitly. Helps: bgo#626399

 src/plugins/iplayer/iplayer.py |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)
Comment 13 Philip Withnall 2010-11-14 15:24:59 UTC
Since the patch in bug #622987 has now been committed, I've tidied up a few loose edges and this bug can be marked as fixed. Yay!