martin,
On Wed, 23 Jul 2008, martin f krafft wrote:
> also sprach Nicholas Piper <[EMAIL PROTECTED]> [2008.07.23.0045 +0200]:
> > * jpilot to use RTLD_GLOBAL when loading the plugins
> Unfortunately, I think RTLD_GLOBAL is disabled on Debian.
> 22 14:13 < pusling> and it opens with RTLD_GLOBAL - that's patched
> out of debian libltdl packages.
> 22 14:14 < pusling> does jppy ships own copy of libltdl ?
> I don't know why.
I don't understand this - I use Debian (my /etc/debian_version says
lenny/sid) and the patch which makes jpilot load the plugins with
RTLD_GLOBAL appeared to work.
> > * our python module to -lpython (disliked by Debian)
> Reference for that dislike? And why? Sorry, I am in a dozen
> different projects right now and kinda lost overview.
#445379 , but I mis-thought and actually this doesn't help (I tried
it.)
> > This is what
> > http://jppy.zanu.org.uk/trac/browser/debian/trunk/find-python-library-name.sh?rev=322
> > used to do.
> Hm, I suppose this seems like the way we need to head.
Ok, new patch attached for your consideration that dlopen()'s the
right shared python library - but note we still must use RTLD_GLOBAL
to have success... otherwise python modules that jppy uses don't have
the libpython symbols:
calling plugin_startup for [jppy 0.46pre]
jppy: Starting...
jppy: Opened python library
jppy: Initialized python
jppy: Imported os, sys
ImportError: could not import gobject (error was:
'/var/lib/python-support/python2.5/gtk-2.0/gobject/_gobject.so:
undefined symbol: _Py_ZeroStruct')
Nick
Index: ChangeLog
===================================================================
--- ChangeLog (revision 328)
+++ ChangeLog (working copy)
@@ -1,3 +1,12 @@
+2008-07-25 Nicholas Piper <[EMAIL PROTECTED]>
+
+ * jpilot_plugins/jppy.c (plugin_startup): Remove deprecated
+ init_pygobject() call
+
+ * SConstruct: Set PYTHON_SHARED_LIB to a better filename for
+ libpython - see Debian bug
+ http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=491848
+
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,11 +207,10 @@
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]
+ // This is because python modules don't -lpython, combined with
+ // jpilot not loading the plugins with RTLD_GLOBAL, so the plugin's
+ // -lpython isn't then available to the python modules that it
+ // uses... See http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=491848
if (!dlopen (PYTHON_SHARED_LIB, RTLD_NOW | RTLD_GLOBAL)) {
jp_logf(JP_LOG_FATAL, "\n%s\n", dlerror());
python_is_working = 0;
@@ -231,7 +230,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)
@@ -10,6 +10,7 @@
from helpers import *
import dbhash
import SCons
+import commands
print """Please remember that SCons does NOT automatically use your shell
environment variables. This script uses PKG_CONFIG_PATH explicitly."""
@@ -190,15 +191,17 @@
pluginEnv.Append(CPPDEFINES=['JPILOT_PLUGIN_PREFIX=\\"$jpilot_plugin_prefix\\"'])
+
jppyPluginEnv = pluginEnv.Clone()
-jppyPluginEnv.Append(CPPDEFINES=['PYTHON_SHARED_LIB=\\"libpython${python_version}.so\\"'])
+jppyPluginEnv.Append(LINKFLAGS=distutils.sysconfig.get_config_var('LINKFORSHARED'))
jppyPluginConfig = jppyPluginEnv.Configure()
if not jppyPluginConfig.CheckLibWithHeader("libpython%s" % env['python_version'],
'Python.h','C','PyErr_Clear();'):
print "You need libpython%s.so to compile this program" % env['python_version']
Exit(1)
jppyPluginConfig.Finish()
-jppyPluginEnv.Append(LINKFLAGS=distutils.sysconfig.get_config_var('LINKFORSHARED'))
+python_library_filename = commands.getoutput("./find-python-library-name.sh libpython%s.so" % env['python_version'])
+jppyPluginEnv.Append(CPPDEFINES=['PYTHON_SHARED_LIB=\\"%s\\"' % python_library_filename])
jpilot_plugins = []