A few more debug messages here and there; make it work with non-system libpython

parent 0d76b625
2006-02-19 Gustavo J. A. M. Carneiro <gjc@gnome.org>
* configure.in: Fix PY_LIB_LOC to point to $PY_EXEC_PREFIX/lib,
which is where a normal (i.e. not distribution patched) python
installation puts the shared library.
* src/nautilus-python.c (nautilus_python_init_python): Use
PY_LIB_LOC here to open the correct python library (for cases of
prefix != /usr).
* src/Makefile.am (PYTHON_LIBS): Use PY_LIB_LOC here.
* configure.in: Remove -L from $PY_LIB_LOC.
* src/nautilus-python.c (np_init_pygobject): Add a missing
PyErr_Print(); for the case when _PyGObbject_API is not found.
(np_init_pygtk): idem.
2006-02-18 Gustavo J. A. M. Carneiro <gjc@gnome.org>
* src/nautilus-python.c (np_init_pygnomevfs): Copy-paste of
......
......@@ -80,7 +80,7 @@ else:
if test -f $PY_PREFIX/include/python$PY_VERSION/Python.h; then
AC_MSG_RESULT(yes)
PY_LIBS="python$PY_VERSION"
PY_LIB_LOC="-L$PY_EXEC_PREFIX/lib/python$PY_VERSION/config"
PY_LIB_LOC="$PY_EXEC_PREFIX/lib"
PY_CFLAGS="-I$PY_PREFIX/include/python$PY_VERSION"
PY_MAKEFILE="$PY_EXEC_PREFIX/lib/python$PY_VERSION/config/Makefile"
PY_LOCALMODLIBS=`sed -n -e 's/^LOCALMODLIBS=\(.*\)/\1/p' $PY_MAKEFILE`
......
......@@ -7,11 +7,12 @@ INCLUDES = \
$(DISABLE_DEPRECATED_CFLAGS) \
$(NAUTILUS_PYTHON_CFLAGS) \
-DPYTHON_VERSION=\"$(PYTHON_VERSION)\" \
-DPY_LIB_LOC="\"$(PY_LIB_LOC)\"" \
$(PY_CFLAGS)
PYTHON_LIBS = \
-l$(PY_LIBS) \
$(PY_OTHER_LIBS) \
PYTHON_LIBS = \
-L$(PY_LIB_LOC) -l$(PY_LIBS) \
$(PY_OTHER_LIBS) \
$(PY_EXTRA_LIBS)
nautilus_extensiondir=$(NAUTILUS_LIBDIR)/nautilus/extensions-1.0
......
......@@ -53,6 +53,7 @@ static inline gboolean np_init_pygobject(void)
else {
PyErr_SetString(PyExc_RuntimeError,
"could not find _PyGObject_API object");
PyErr_Print();
return FALSE;
}
} else {
......@@ -75,6 +76,7 @@ static inline gboolean np_init_pygtk(void)
else {
PyErr_SetString(PyExc_RuntimeError,
"could not find _PyGtk_API object");
PyErr_Print();
return FALSE;
}
} else {
......@@ -175,8 +177,10 @@ nautilus_python_load_dir (GTypeModule *module, const char *dirname)
PyObject *sys_path, *py_path;
/* n-p python part is initialized on demand (or not
* at all if no extensions are found) */
if (!nautilus_python_init_python())
if (!nautilus_python_init_python()) {
g_warning("nautilus_python_init_python failed");
goto exit;
}
/* sys.path.insert(0, dirname) */
sys_path = PySys_GetObject("path");
py_path = PyString_FromString(dirname);
......@@ -196,35 +200,56 @@ nautilus_python_init_python (void)
PyObject *pygtk, *mdict, *require;
PyObject *sys_path, *tmp, *nautilus, *gtk, *pygtk_version, *pygtk_required_version;
GModule *libpython;
char *home_dir;
char *argv[] = { "nautilus", NULL };
if (Py_IsInitialized())
return TRUE;
libpython = g_module_open("libpython" PYTHON_VERSION "." G_MODULE_SUFFIX, 0);
debug("g_module_open " PY_LIB_LOC "/libpython" PYTHON_VERSION "." G_MODULE_SUFFIX);
libpython = g_module_open(PY_LIB_LOC "/libpython" PYTHON_VERSION "." G_MODULE_SUFFIX, 0);
if (!libpython)
g_warning("g_module_open libpython failed: %s", g_module_error());
debug("Py_Initialize");
Py_Initialize();
if (PyErr_Occurred()) {
PyErr_Print();
return FALSE;
}
debug("PySys_SetArgv");
PySys_SetArgv(1, argv);
if (PyErr_Occurred()) {
PyErr_Print();
return FALSE;
}
/* pygtk.require("2.0") */
debug("pygtk.require(\"2.0\")");
pygtk = PyImport_ImportModule("pygtk");
if (!pygtk) {
PyErr_Print();
return FALSE;
}
mdict = PyModule_GetDict(pygtk);
require = PyDict_GetItemString(mdict, "require");
PyObject_CallObject(require, Py_BuildValue("(S)", PyString_FromString("2.0")));
if (PyErr_Occurred()) {
PyErr_Print();
return FALSE;
}
/* import gobject */
debug("init_pygobject");
if (!np_init_pygobject())
if (!np_init_pygobject()) {
g_warning("pygobject initialization failed");
return FALSE;
}
/* import gtk */
debug("init_pygtk");
if (!np_init_pygtk())
if (!np_init_pygtk()) {
g_warning("pygtk initialization failed");
return FALSE;
}
/* import gnomevfs */
debug("init_gnomevfs");
if (!np_init_pygnomevfs())
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment