[Goodies-dev] RSS plugin: Properly detect the xfce4 Python module
Jannis Pohlmann
jannis at xfce.org
Wed Aug 2 22:13:06 CEST 2006
Hey Adriano,
after miserably failing to discuss with myself, here's some
constructive report on the xfce4 module detecting issue:
First of all, it's a known "problem" (some call it a feature) that on
some systems, you have to call "import pygtk.require('2.0')" before you
can run "import gtk" or import any gtk submodules. This has some
drawbacks, of course. Some authors forget to do this and it makes
detecting Python modules slightly more complicated.
The latter is the case in your RSS plugin, which tries to detect the
xfce4 Python module via AM_CHECK_PYMOD. AM_CHECK_PYMOD mainly
constructs a simple Python script which tries to import the passed
module and returns 0 on success or 1 when an ImportError occured.
So if you call AM_CHECK_PYMOD(xfce4, ...), the generated script will
roughly look like this:
try:
import xfce4
sys.exit(0)
except ImportError:
sys.exit(1)
As xfce4 needs the gtk module (and its submodules), the script needs to
look like this to work on all systems:
try:
try:
import pygtk
pygtk.require("2.0")
except: # Some systems (like Windows) don't need the pygtk stuff
pass
import gtk
import xfce4
sys.exit(0)
except ImportError:
sys.exit(1)
To achieve this, you have (at least) two possibilities: You can either
just execute this script inside of configure.ac(.in) and check its exit
code or you can tweak acinclude.m4 to add the needed stuff for you.
Here are two (slightly different) approaches to change AM_CHECK_PYMOD
to support the pygtk stuff:
http://numexp.cvs.sourceforge.net/numexp/gnumexp/acinclude.m4?revision=1.4&view=markup
and
http://svn.sourceforge.net/viewvc/ecell/ecell3/trunk/modeleditor/acinclude.m4?revision=2480&view=markup&pathrev=2558
I hope this helps and compensates my chaotic monolog I talked in a few
minutes ago.
Regards,
Jannis
More information about the Goodies-dev
mailing list