[glom] Fix loading of the versioned python module.
- From: Murray Cumming <murrayc src gnome org>
- To: svn-commits-list gnome org
- Subject: [glom] Fix loading of the versioned python module.
- Date: Sat, 4 Jul 2009 22:01:37 +0000 (UTC)
commit 893db907e3c47c9ab4be1d6cfe5e7c6c24971f17
Author: Murray Cumming <murrayc murrayc com>
Date: Sat Jul 4 23:56:51 2009 +0200
Fix loading of the versioned python module.
* configure.ac:
* glom/Makefile.am:
* glom/python_embed/Makefile.am:
* glom/python_embed/glom_python.cc:
* glom/python_embed/python_module/Makefile.am:
* glom/python_embed/python_module/py_glom_module.cc:
* glom/python_embed/python_module/py_glom_module.h: Use glom_1_12
instead of glom-1.12 because - and . are not valid in python module
names. I wish I knew of any standard way to do parallel install of
different versions of python modules.
ChangeLog | 17 ++++++++++++++++-
configure.ac | 5 +++++
glom/Makefile.am | 3 ++-
glom/python_embed/Makefile.am | 3 ++-
glom/python_embed/glom_python.cc | 6 +++---
glom/python_embed/python_module/Makefile.am | 9 ++++++---
glom/python_embed/python_module/py_glom_module.cc | 4 ++--
glom/python_embed/python_module/py_glom_module.h | 2 +-
8 files changed, 37 insertions(+), 12 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 6d745a4..ad713bc 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,4 +1,19 @@
-2009-07-04 Murray Cumming <murrayc murrayc-x61>
+2009-07-04 Murray Cumming <murrayc murrayc com>
+
+ Fix loading of the versioned python module.
+
+ * configure.ac:
+ * glom/Makefile.am:
+ * glom/python_embed/Makefile.am:
+ * glom/python_embed/glom_python.cc:
+ * glom/python_embed/python_module/Makefile.am:
+ * glom/python_embed/python_module/py_glom_module.cc:
+ * glom/python_embed/python_module/py_glom_module.h: Use glom_1_12
+ instead of glom-1.12 because - and . are not valid in python module
+ names. I wish I knew of any standard way to do parallel install of
+ different versions of python modules.
+
+2009-07-04 Murray Cumming <murrayc murrayc com>
libglom: Remove use of GLOM_ENABLE_MAEMO because it is about UI.
diff --git a/configure.ac b/configure.ac
index 85bf879..40ae618 100644
--- a/configure.ac
+++ b/configure.ac
@@ -22,6 +22,11 @@ AM_SANITY_CHECK
GLOM_ABI_VERSION=1.12
AC_SUBST([GLOM_ABI_VERSION])
+#Python modules can't be called glom-1.x, so we use underlines.
+#There might be a better way to do this, but I can't find any example of it. murrayc.
+GLOM_ABI_VERSION_UNDERLINED=1_12
+AC_SUBST([GLOM_ABI_VERSION_UNDERLINED])
+
# libgettext-po changed its API, changing the error handler struct from po_error_handler to po_xerror_handler:
AC_CHECK_MEMBER([struct po_xerror_handler.xerror], [have_gettext_po_xerror="yes"], [have_gettext_po_xerror="no"], [#include <gettext-po.h>])
if test "$have_gettext_po_xerror" = "yes"; then
diff --git a/glom/Makefile.am b/glom/Makefile.am
index 5c0c07b..d344396 100644
--- a/glom/Makefile.am
+++ b/glom/Makefile.am
@@ -27,7 +27,8 @@ AM_CPPFLAGS = -I top_srcdir@/ -I top_srcdir@/glom $(GLOM_CFLAGS) $(GLOM_WARNING_
-DGLOM_EXAMPLES_DIR=\""$(glom_examples_dir)"\" \
-DGLOM_EXAMPLES_DIR_ALTERNATIVE=\""$(glom_examples_dir_alternative)"\" \
-DGLOM_ICON_DIR=\""$(glom_icon_dir)"\" \
- -DGLOM_ABI_VERSION=\""$(GLOM_ABI_VERSION)\""
+ -DGLOM_ABI_VERSION=\""$(GLOM_ABI_VERSION)\"" \
+ -DGLOM_ABI_VERSION_UNDERLINED=\""$(GLOM_ABI_VERSION_UNDERLINED)\""
glom_SOURCES = main.cc \
application.cc application.h \
diff --git a/glom/python_embed/Makefile.am b/glom/python_embed/Makefile.am
index 458ebbd..d831304 100644
--- a/glom/python_embed/Makefile.am
+++ b/glom/python_embed/Makefile.am
@@ -1,5 +1,6 @@
AM_CPPFLAGS = -I top_srcdir@/ -I top_srcdir@/glom $(GLOM_CFLAGS) $(GLOM_WARNING_FLAGS) $(PYTHON_INCLUDES) \
- -DGLOM_ABI_VERSION=\""$(GLOM_ABI_VERSION)\""
+ -DGLOM_ABI_VERSION=\""$(GLOM_ABI_VERSION)\"" \
+ -DGLOM_ABI_VERSION_UNDERLINED=\""$(GLOM_ABI_VERSION_UNDERLINED)\""
SUBDIRS = python_module
diff --git a/glom/python_embed/glom_python.cc b/glom/python_embed/glom_python.cc
index 84e230c..0276729 100644
--- a/glom/python_embed/glom_python.cc
+++ b/glom/python_embed/glom_python.cc
@@ -138,7 +138,7 @@ void ShowTrace()
bool glom_python_module_is_available()
{
- PyObject* module_glom = PyImport_ImportModule((char*)"glom-" GLOM_ABI_VERSION); //TODO: unref this?
+ PyObject* module_glom = PyImport_ImportModule((char*)"glom_" GLOM_ABI_VERSION_UNDERLINED); //TODO: unref this?
return module_glom != 0;
}
@@ -183,7 +183,7 @@ Gnome::Gda::Value glom_evaluate_python_function_implementation(Field::glom_field
//prefix the def line:
const Glib::ustring func_name = "glom_calc_field_value";
- func_def = "def " + func_name + "(record):\n import glom-" GLOM_ABI_VERSION "\n import gda\n" + func_def;
+ func_def = "def " + func_name + "(record):\n import glom_" GLOM_ABI_VERSION_UNDERLINED "\n import gda\n" + func_def;
//We did this in main(): Py_Initialize();
PyObject* pMain = PyImport_AddModule((char*)"__main__");
@@ -218,7 +218,7 @@ Gnome::Gda::Value glom_evaluate_python_function_implementation(Field::glom_field
}
- PyObject* module_glom = PyImport_ImportModule((char*)"glom-" GLOM_ABI_VERSION);
+ PyObject* module_glom = PyImport_ImportModule((char*)"glom_" GLOM_ABI_VERSION_UNDERLINED);
if(!module_glom)
{
g_warning("Could not import python glom module.");
diff --git a/glom/python_embed/python_module/Makefile.am b/glom/python_embed/python_module/Makefile.am
index 77bf752..3380d13 100644
--- a/glom/python_embed/python_module/Makefile.am
+++ b/glom/python_embed/python_module/Makefile.am
@@ -1,5 +1,6 @@
AM_CPPFLAGS = -I top_srcdir@/ -I top_srcdir@/glom $(GLOM_CFLAGS) $(GLOM_WARNING_FLAGS) $(PYTHON_INCLUDES) \
- -DGLOM_ABI_VERSION=\""$(GLOM_ABI_VERSION)\""
+ -DGLOM_ABI_VERSION=\""$(GLOM_ABI_VERSION)\"" \
+ -DGLOM_ABI_VERSION_UNDERLINED=\""$(GLOM_ABI_VERSION_UNDERLINED)\""
SUBDIRS =
@@ -7,7 +8,9 @@ SUBDIRS =
common_ldflags = -module -avoid-version -no-undefined
# Build and install the python module:
-pyexec_LTLIBRARIES = glom-1.12.la
+# Note that we use underlines because import fails with incorrect syntax
+# when trying to use . or - in the module name. murrayc.
+pyexec_LTLIBRARIES = glom_1_12.la
glom_1_12_la_LDFLAGS = $(common_ldflags) -export-symbols-regex initglom
glom_1_12_la_LIBADD = $(top_builddir)/glom/libglom/libglom-1.12.la \
@@ -23,5 +26,5 @@ if WIN32
# Python .pyd modules are simply DLLs, but they have to be called .pyd for
# python to find them, and libtool only creates .dll.
install-exec-hook:
- mv $(pyexecdir)/glom.dll $(pyexecdir)/glom-1.12.pyd
+ mv $(pyexecdir)/glom.dll $(pyexecdir)/glom_1_12.pyd
endif
diff --git a/glom/python_embed/python_module/py_glom_module.cc b/glom/python_embed/python_module/py_glom_module.cc
index cbf0266..df944e9 100644
--- a/glom/python_embed/python_module/py_glom_module.cc
+++ b/glom/python_embed/python_module/py_glom_module.cc
@@ -33,7 +33,7 @@ static PyMethodDef pyglom_methods[] = {
};
PyMODINIT_FUNC
-initglom(void)
+initglom_1_12(void)
{
PyObject* m;
@@ -49,7 +49,7 @@ initglom(void)
return;
- m = Py_InitModule3((char*)"glom-" GLOM_ABI_VERSION, pyglom_methods,
+ m = Py_InitModule3((char*)"glom_" GLOM_ABI_VERSION_UNDERLINED, pyglom_methods,
(char*)"Python module for Glom caluclated fields.");
diff --git a/glom/python_embed/python_module/py_glom_module.h b/glom/python_embed/python_module/py_glom_module.h
index c9ae445..65eafcd 100644
--- a/glom/python_embed/python_module/py_glom_module.h
+++ b/glom/python_embed/python_module/py_glom_module.h
@@ -37,7 +37,7 @@
* - field values: for instance, name = record.related["contacts"]["name_first"];
* - Summary functions: for instance, total = record.related["invoice_lines"].sum("price");
*/
-PyMODINIT_FUNC initglom(void);
+PyMODINIT_FUNC initglom_1_12(void);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]