GNOME Bugzilla – Bug 623105
gstpythonplugin.c does not import user's gobject module
Last modified: 2010-08-27 11:22:03 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.
This would require people to have pygtk installed (as opposed to only pygobject).
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.
(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.
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.
Created attachment 168845 [details] [review] New patch, adjusting for recent changes on master.
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.