tags 491848 patch
thanks
martin,
On Tue, 22 Jul 2008, martin f krafft wrote:
> jpilot_plugins/jppy.c:210:
> // we seem to have to do this, as well as just linking this plugin
> // to the python library, otherwise init_pygobject() causes the
> // plugin to stop-and-exit. If we only do this and don't link,
> // then we get··
> // error [/usr/lib/jpilot/plugins/libjppy.so: undefined symbol:
> PyExc_ImportError]
> if (!dlopen (PYTHON_SHARED_LIB, RTLD_NOW | RTLD_GLOBAL)) {·
> jp_logf(JP_LOG_FATAL, "\n%s\n", dlerror());·
> python_is_working = 0;·
> return 0;·
> }·
I never understood yet why this seemed to be required (until
today). It's been there forever -
http://jppy.zanu.org.uk/trac/browser/trunk/jpilot_plugin/jppy.c?rev=2#L209
> and SConstruct:194:
>
> jppyPluginEnv.Append(CPPDEFINES=['PYTHON_SHARED_LIB=\\"libpython${python_version}.so\\"'])
>
> If we remove all this code, the plugin fails to load and jpilot just
> says:
>
> Python is not running, unable to generate GUI!
If you run jpilot with -d, you'll see that it 'bombs out' in the
init_pygobject() here:
jp_logf(JP_LOG_DEBUG, "jppy: Imported os, sys\n");
init_pygobject();
jp_logf(JP_LOG_DEBUG, "jppy: Initialized pygobject\n");
I've improved the logging, now we see:
ImportError: could not import gobject (error was:
'/var/lib/python-support/python2.5/gtk-2.0/gobject/_gobject.so: undefined
symbol: _Py_ZeroStruct')
and that leads me to...
http://mail.gnome.org/archives/desktop-devel-list/2006-February/msg00192.html
which helps me understand what is actually wrong.
So it seems that we need one of these:
* jpilot to use RTLD_GLOBAL when loading the plugins
* our plugin to dlopen() python (this bug...)
* our python module to -lpython (disliked by Debian)
--- jpilot-1.6.0/plugins.c 2008-05-01 16:33:26.000000000 +0100
+++ jpilot-1.6.0.mine/plugins.c 2008-07-22 23:33:54.000000000 +0100
@@ -270,7 +270,7 @@
p->plugin_unpack_cai_from_ai = NULL;
p->plugin_pack_cai_into_ai = NULL;
- h = dlopen(path, RTLD_LAZY);
+ h = dlopen(path, RTLD_LAZY | RTLD_GLOBAL);
if (!h) {
jp_logf(JP_LOG_WARN, _("Open failed on plugin [%s]\n error
[%s]\n"), path,
dlerror());
And this works :-) along with the attached patch for jppy.
> but I could get it to say anything about PyExc_ImportError, even
> with jpilot's -d flag.
I assume you mean 'could not'.
> I'd say this is quite a horrible hack and we should try to get rid
> of it, but if that fails, then PYTHON_SHARED_LIB needs to be defined
> to point to the same .so.* file with which the plugin is linked,
> which I suppose has to be determined with
> readlink -f /usr/lib/libpython2.5.so
> (which would work during build on Debian at least).
This is what
http://jppy.zanu.org.uk/trac/browser/debian/trunk/find-python-library-name.sh?rev=322
used to do.
> With PYTHON_SHARED_LIB set to libpython2.5.so.1.0, stuff still
> doesn't work, however:
>
> jppy: Ready.
>
> (-v:22246): libglade-WARNING **: could not find glade file
> '@@python_module_prefix@@/gui/contacts.glade'
> Traceback (most recent call last):
> File "/usr/lib/jpilot/plugins/jpilot_site.py", line 6, in plugin_gui
> combined.notebook(hbox, control_mainloop=0)
> File "jppy/gui/combined.py", line 22, in __init__
> self.panes.append(contacts.pane(glade_path))
> File "jppy/gui/contacts.py", line 47, in __init__
> wTree = gtk.glade.XML(gladefile,"vpanedContacts")
> RuntimeError: could not create GladeXML object
> Warning! Failed during python version of plugin_gui().
This one looks like a build error, as the @@python_module_prefix@@
wasn't expanded.
Summary is that we need jpilot to change how they load plugins.
Nick
Index: ChangeLog
===================================================================
--- ChangeLog (revision 328)
+++ ChangeLog (working copy)
@@ -1,3 +1,10 @@
+2008-07-22 Nicholas Piper <[EMAIL PROTECTED]>
+
+ * jpilot_plugins/jppy.c (plugin_startup): Avoid dlopen() of python
+ ourselves, and switch away from the old API for initialising
+ gobject so we can get an error condition from it properly. This
+ depends on a jpilot patch to cause it to dlopen() plugins with
+
2008-06-28 Nicholas Piper <[EMAIL PROTECTED]>
* SConstruct: Add python_bin_module_prefix option to SCons, to
Index: jpilot_plugins/jppy.c
===================================================================
--- jpilot_plugins/jppy.c (revision 328)
+++ jpilot_plugins/jppy.c (working copy)
@@ -207,18 +207,6 @@
jp_init();
jp_logf(JP_LOG_INFO, "jppy: Starting...\n");
- // we seem to have to do this, as well as just linking this plugin
- // to the python library, otherwise init_pygobject() causes the
- // plugin to stop-and-exit. If we only do this and don't link,
- // then we get
- // error [/usr/lib/jpilot/plugins/libjppy.so: undefined symbol: PyExc_ImportError]
- if (!dlopen (PYTHON_SHARED_LIB, RTLD_NOW | RTLD_GLOBAL)) {
- jp_logf(JP_LOG_FATAL, "\n%s\n", dlerror());
- python_is_working = 0;
- return 0;
- }
- jp_logf(JP_LOG_DEBUG, "jppy: Opened python library\n");
-
Py_SetProgramName("jpilot");
Py_Initialize();
PySys_SetArgv(1, python_argv);
@@ -231,7 +219,12 @@
jp_logf(JP_LOG_DEBUG, "jppy: Imported os, sys\n");
- init_pygobject();
+ PyObject *gobject = pygobject_init(2,4,0);
+ if (gobject == NULL) {
+ PyErr_Print();
+ return 0;
+ }
+
jp_logf(JP_LOG_DEBUG, "jppy: Initialized pygobject\n");
PyRun_SimpleString("sys.path.insert(0,'%s/.jpilot/python' % (os.getenv('JPILOT_HOME') or os.getenv('HOME')))");
Index: SConstruct
===================================================================
--- SConstruct (revision 328)
+++ SConstruct (working copy)
@@ -191,7 +191,6 @@
pluginEnv.Append(CPPDEFINES=['JPILOT_PLUGIN_PREFIX=\\"$jpilot_plugin_prefix\\"'])
jppyPluginEnv = pluginEnv.Clone()
-jppyPluginEnv.Append(CPPDEFINES=['PYTHON_SHARED_LIB=\\"libpython${python_version}.so\\"'])
jppyPluginConfig = jppyPluginEnv.Configure()
if not jppyPluginConfig.CheckLibWithHeader("libpython%s" % env['python_version'],
'Python.h','C','PyErr_Clear();'):