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 623105 - gstpythonplugin.c does not import user's gobject module
gstpythonplugin.c does not import user's gobject module
Status: RESOLVED FIXED
Product: GStreamer
Classification: Platform
Component: gst-python
git master
Other All
: Normal normal
: 0.10.20
Assigned To: GStreamer Maintainers
GStreamer Maintainers
Depends on:
Blocks:
 
 
Reported: 2010-06-29 09:17 UTC by Leo Singer
Modified: 2010-08-27 11:22 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
proposed patch (1.01 KB, patch)
2010-06-29 09:17 UTC, Leo Singer
none Details | Review
New patch, adjusting for recent changes on master. (858 bytes, patch)
2010-08-26 21:55 UTC, Leo Singer
none Details | Review

Description Leo Singer 2010-06-29 09:17:18 UTC
Created attachment 164869 [details] [review]
proposed patch

If a user has his/her own installation of pygobject and pygtk, the Python plugin loader in plugin/gstpythonplugin.c will load the gobject module found in the top-level site-packages directory, instead of the user's version of gobject.

In Python modules, it appears to be common practice to import gobject using the following recipe:

import pygtk
pygtk.require("2.0")
import gobject

And doing this causes the user's version of gobject (which would be in a site-packages directory that occurs earlier in sys.path) to supersede the top-level site-packages directory.

This is, in fact, what is done in the "gst" module's __init__.py file.

This practice is also mentioned on the following two pages:
http://gstreamer.freedesktop.org/wiki/FAQ#Mypygstprogramismysteriouslycoredumping.2Chowtofixthis.3F
http://faq.pygtk.org/index.py?req=show&file=faq02.004.htp

The attached patch adds a C equivalent of this procedure to gstpythonplugins.c.  It does result in the "correct" version of gobject being loaded.
Comment 1 Edward Hervey 2010-06-29 09:22:50 UTC
This would require people to have pygtk installed (as opposed to only pygobject).
Comment 2 Leo Singer 2010-06-29 09:32:03 UTC
Actually, when you install pygobject, it puts "pygtk.py" and "gtk-2.0/gobject" inside the site-packages directory in your install prefix.

I think that this patch works even if the user has installed pygobject but not pygtk.
Comment 3 Leo Singer 2010-07-02 16:29:59 UTC
(In reply to comment #1)
> This would require people to have pygtk installed (as opposed to only
> pygobject).

I double checked, this patch requires **only** pygobject, **not** pygtk, to be installed.  To make certain, I installed pygobject in a fresh location, then I looked at the files and directories inside the newly created "site-packages" directory created "make install"ing pygobject.  Here's what I see:

$ tree site-packages
site-packages
|-- gtk-2.0
|   |-- dsextras.py
|   |-- dsextras.pyc
|   |-- dsextras.pyo
|   `-- gobject
|       |-- __init__.py
|       |-- __init__.pyc
|       |-- __init__.pyo
|       |-- _gobject.la
|       |-- _gobject.so
|       |-- constants.py
|       |-- constants.pyc
|       |-- constants.pyo
|       |-- option.py
|       |-- option.pyc
|       |-- option.pyo
|       |-- propertyhelper.py
|       |-- propertyhelper.pyc
|       `-- propertyhelper.pyo
|-- pygtk.pth
|-- pygtk.py
|-- pygtk.pyc
`-- pygtk.pyo

2 directories, 21 files

So the "pygtk" module, which is needed for doing the "pygtk.require" to prepare for importing the user's own version of gtk and gobject, is provided by the pygobject distribution.
Comment 4 Leo Singer 2010-07-30 14:38:31 UTC
I am absolutely positive that this proposed change does not require the user to have gtk or pygtk installed.  pygobject is sufficient.  Has anyone tried out this patch?

I am working on a system that has an old version of pygobject that is missing some limit symbols.  As a result, my Python plugins **do not work** if gstpythonplugin loads the system-wide gobject instead of the one that is in my user-specific site-packages directory.  I'm stuck with applying my own patch to be able to use gst-python at all.
Comment 5 Leo Singer 2010-08-26 21:55:33 UTC
Created attachment 168845 [details] [review]
New patch, adjusting for recent changes on master.
Comment 6 Alessandro Decina 2010-08-27 11:21:46 UTC
commit ca020b3dd7ae5e8f95bbcd2b6556f950a3586c60
Author: Alessandro Decina <alessandro.d@gmail.com>
Date:   Fri Aug 27 13:20:24 2010 +0200

    plugin: call pygtk.require("2.0") before importing pygobject. Fixes #623105.
    
    Based on a patch from Leo Singer.