[libpeas] Support py2 and py3 at the same time



commit 590b5e1c3f11b4c5d6b15826aec05caeafaf9258
Author: Paolo Borelli <pborelli gnome org>
Date:   Thu Jan 3 14:08:24 2013 +0100

    Support py2 and py3 at the same time
    
    This patch reworks the build system so that we use the same sources to
    build both a python2 loader and a python3 loader. The python 2 one
    keeps the same name for backward compatibility, while the python 3 one
    is explicitely called "python3".
    Supporting py2 and py3 in the same build is tricky since the existing
    autotools support is limited, so we make some assumptions:
     - there are separate --enable-python2 and --enable-python3 flags,
       --enable-python has been removed
     - the py3 loader is in a separate dir but compliles the files from the
       py2 loader
     - for py2 we only check the binary and the python2-config tool, while
       for py3 we use the proper AM_PATH_PYTHON macro
     - for py2 we manually detect pyexecdir, hopefully with the same logic
       used by the AM_PATH_PYTHON macro
     - we do not check for Python.h header anymore since it is not strictly
       needed and autoconf caching makes it difficult
     - for we build the demos only for python3 (unit tests instead are
       replicated for both)
    
    https://bugzilla.gnome.org/show_bug.cgi?id=691081

 .gitignore                                         |    7 +
 configure.ac                                       |  134 +++++++++++++-------
 loaders/Makefile.am                                |    6 +-
 loaders/python/Makefile.am                         |    8 +-
 loaders/python3/Makefile.am                        |   34 +++++
 peas-demo/plugins/Makefile.am                      |    2 +-
 peas-demo/plugins/pythonhello/pythonhello.plugin   |    2 +-
 tests/libpeas/Makefile.am                          |   13 ++-
 tests/libpeas/extension-python3.c                  |  124 ++++++++++++++++++
 tests/libpeas/plugins/Makefile.am                  |    7 +-
 tests/libpeas/plugins/extension-python/Makefile.am |   31 ++++-
 ...python.gschema.xml => extension-py.gschema.xml} |    2 +-
 .../plugins/extension-python/extension-py.plugin   |    8 ++
 .../{extension-python.py => extension-py.py}       |    0
 .../extension-python/extension-python.plugin       |    8 --
 .../plugins/extension-python3-nonexistent.plugin   |    8 ++
 tests/libpeas/testing/testing-extension.c          |    1 +
 17 files changed, 324 insertions(+), 71 deletions(-)
---
diff --git a/.gitignore b/.gitignore
index 3af562c..837a0fd 100644
--- a/.gitignore
+++ b/.gitignore
@@ -76,6 +76,7 @@ Makefile.in
 /tests/libpeas/extension-c
 /tests/libpeas/extension-gjs
 /tests/libpeas/extension-python
+/tests/libpeas/extension-python3
 /tests/libpeas/extension-seed
 /tests/libpeas/extension-set
 /tests/libpeas/plugin-info
@@ -85,6 +86,12 @@ Makefile.in
 /tests/libpeas/plugins/extension-js/extension-seed.gschema.xml
 /tests/libpeas/plugins/extension-js/extension-seed.js
 /tests/libpeas/plugins/extension-js/extension-seed.plugin
+/tests/libpeas/plugins/extension-python/extension-python.gschema.xml
+/tests/libpeas/plugins/extension-python/extension-python.plugin
+/tests/libpeas/plugins/extension-python/extension-python.py
+/tests/libpeas/plugins/extension-python/extension-python3.gschema.xml
+/tests/libpeas/plugins/extension-python/extension-python3.plugin
+/tests/libpeas/plugins/extension-python/extension-python3.py
 /tests/libpeas-gtk/plugin-manager
 /tests/libpeas-gtk/plugin-manager-store
 /tests/libpeas-gtk/plugin-manager-view
diff --git a/configure.ac b/configure.ac
index a8338b7..428b3ea 100644
--- a/configure.ac
+++ b/configure.ac
@@ -311,68 +311,106 @@ dnl ================================================================
 dnl Python
 dnl ================================================================
 
-PYTHON_REQUIRED=2.5.2
+PYTHON2_REQUIRED=2.5.2
+PYTHON3_REQUIRED=3.2.0
 
 dnl Used by the Python loader to check the PyGObject version at runtime
 PYGOBJECT_MAJOR_VERSION=3
 PYGOBJECT_MINOR_VERSION=0
 PYGOBJECT_MICRO_VERSION=0
 PYGOBJECT_REQUIRED=$PYGOBJECT_MAJOR_VERSION.$PYGOBJECT_MINOR_VERSION.$PYGOBJECT_MICRO_VERSION
+AC_DEFINE_UNQUOTED(PYGOBJECT_MAJOR_VERSION,[$PYGOBJECT_MAJOR_VERSION], [PyGObject major version.])
+AC_DEFINE_UNQUOTED(PYGOBJECT_MINOR_VERSION,[$PYGOBJECT_MINOR_VERSION], [PyGObject minor version.])
+AC_DEFINE_UNQUOTED(PYGOBJECT_MICRO_VERSION,[$PYGOBJECT_MICRO_VERSION], [PyGObject micro version.])
 
-AC_ARG_ENABLE(python,
-	      AS_HELP_STRING([--enable-python],[Enable Python support]),
-	      [enable_python=$enableval],
-	      [enable_python=auto])
+AC_MSG_CHECKING([for Python 2 availability.])
 
-if test "$enable_python" = "no"; then
-	found_python="no (disabled, use --enable-python to enable)"
+AC_ARG_ENABLE(python2,
+    AS_HELP_STRING([--enable-python2],[Enable Python 2 support]),
+    [enable_python2=$enableval],
+    [enable_python2=auto])
+
+if test "x$enable_python2" = "xno"; then
+    found_python2="no (disabled, use --enable-python2 to enable)"
 else
-	AM_PATH_PYTHON($PYTHON_REQUIRED,
-		       [found_python=yes],
-		       [found_python="no (python interpretor >= ${PYTHON_REQUIRED} not found"])
-
-	if test "$found_python" = "yes"; then
-		AC_PATH_TOOL(PYTHON_CONFIG, "python${PYTHON_VERSION}-config")
-		if test -z "$PYTHON_CONFIG"; then
-			AC_PATH_TOOL(PYTHON_CONFIG, "python-config-${PYTHON_VERSION}")
-			if test -z "$PYTHON_CONFIG"; then
-				found_python="no (python${PYTHON_VERSION}-config not found)"
-			fi
-		fi
-	fi
-
-	if test "$found_python" = "yes"; then
-		save_CPPFLAGS="${CPPFLAGS}"
-		CPPFLAGS="$CPPFLAGS `$PYTHON_CONFIG --includes`"
-		AC_CHECK_HEADER(Python.h,,[found_python="no (Python headers not found)"])
-		CPPFLAGS="${save_CPPFLAGS}"
-	fi
-
-	AC_MSG_CHECKING([for PyGObject availability.])
-	if test "$found_python" = "yes"; then
-		PKG_CHECK_EXISTS([pygobject-3.0 >= $PYGOBJECT_REQUIRED],,
-				 [found_python="no (pygobject >= $PYGOBJECT_REQUIRED not found)"])
-	fi
-	AC_MSG_RESULT([$found_python])
+    dnl NOTE: we do not use AM_PATH_PYTHON, since it does not allow
+    dnl to call it twice for py2 and py3, so we just check the prog
+    AC_PATH_PROGS(PYTHON2, [python2 python2.7 python2.6 python2.5])
+    if test -z "${PYTHON2}"; then
+        found_python2="no (python2 not found)"
+    else
+        AM_PYTHON_CHECK_VERSION($PYTHON2, $PYTHON2_REQUIRED, [
+            AC_PATH_TOOL(PYTHON2_CONFIG, "python2-config")
+            if test -n "${PYTHON2_CONFIG}"; then
+                PKG_CHECK_MODULES(PYGOBJECT, pygobject-3.0 >= $PYGOBJECT_REQUIRED, [
+                    found_python2=yes
+                    PYTHON2_CFLAGS=`${PYTHON2_CONFIG} --includes`
+                    PYTHON2_LIBS=`${PYTHON2_CONFIG} --libs`
+                    pyexecdir=`$PYTHON2 -c "import sys; from distutils import sysconfig; print sysconfig.get_python_lib(True, prefix='')"`
+                    PYTHON2_PYEXECDIR="\${exec_prefix}/${pyexecdir}"
+                    AC_SUBST(PYTHON2_CFLAGS)
+                    AC_SUBST(PYTHON2_LIBS)
+                    AC_SUBST(PYTHON2_PYEXECDIR)
+                    AC_DEFINE(ENABLE_PYTHON2, 1, [Define to compile with Python 2 support])
+                ], [
+                    found_python2="no (PyGObject not found)"
+                ])
+            else
+                found_python2="no (python2-config not found)"
+            fi
+        ], [
+            found_python2="no (python2 version too old)"
+        ])
+    fi
 fi
 
-if test "$enable_python" = "yes" -a "$found_python" != "yes"; then
-	AC_MSG_ERROR([$found_python])
+if test "x$enable_python2" = "xyes" -a "x$found_python2" != "xyes"; then
+    AC_MSG_ERROR([You need to have Python 2 and PyGobject installed to build libpeas])
 fi
+AC_MSG_RESULT([$found_python2])
+
+AM_CONDITIONAL([ENABLE_PYTHON2],[test "x$found_python2" = "xyes"])
+
+
+AC_MSG_CHECKING([for Python 3 availability.])
+
+AC_ARG_ENABLE(python3,
+    AS_HELP_STRING([--enable-python3],[Enable Python 3 support]),
+    [enable_python3=$enableval],
+    [enable_python3=auto])
 
-if test "$found_python" = "yes"; then
-	PYTHON_CFLAGS="`$PKG_CONFIG --cflags pygobject-3.0` `$PYTHON_CONFIG --includes`"
-	PYTHON_LIBS="`$PKG_CONFIG --libs pygobject-3.0` `$PYTHON_CONFIG --libs`"
-	AC_SUBST(PYTHON_CFLAGS)
-	AC_SUBST(PYTHON_LIBS)
+if test "x$enable_python3" = "xno"; then
+    found_python3="no (disabled, use --enable-python3 to enable)"
+else
+    AM_PATH_PYTHON($PYTHON3_REQUIRED, [
+        AC_PATH_TOOL(PYTHON3_CONFIG, "python3-config")
+        if test -n "${PYTHON3_CONFIG}"; then
+            PKG_CHECK_MODULES(PYGOBJECT, pygobject-3.0 >= $PYGOBJECT_REQUIRED, [
+                found_python3=yes
+                PYTHON3_CFLAGS=`${PYTHON3_CONFIG} --includes`
+                PYTHON3_LIBS=`${PYTHON3_CONFIG} --libs`
+                PYTHON3_PYEXECDIR="${pyexecdir}"
+                AC_SUBST(PYTHON3_CFLAGS)
+                AC_SUBST(PYTHON3_LIBS)
+                AC_SUBST(PYTHON3_PYEXECDIR)
+                AC_DEFINE(ENABLE_PYTHON3, 1, [Define to compile with Python 3 support])
+            ], [
+                found_python3="no (PyGObject not found)"
+            ])
+        else
+            found_python3="no (python3-config not found)"
+        fi
+    ], [
+        found_python3="no (python3 not found)"
+    ])
+fi
 
-	AC_DEFINE_UNQUOTED(PYGOBJECT_MAJOR_VERSION,[$PYGOBJECT_MAJOR_VERSION], [PyGObject major version.])
-	AC_DEFINE_UNQUOTED(PYGOBJECT_MINOR_VERSION,[$PYGOBJECT_MINOR_VERSION], [PyGObject minor version.])
-	AC_DEFINE_UNQUOTED(PYGOBJECT_MICRO_VERSION,[$PYGOBJECT_MICRO_VERSION], [PyGObject micro version.])
-	AC_DEFINE(ENABLE_PYTHON,1,[Define to compile with Python support])
+if test "x$enable_python3" = "xyes" -a "x$found_python3" != "xyes"; then
+    AC_MSG_ERROR([You need to have Python 3 and PyGObject installed to build libpeas])
 fi
+AC_MSG_RESULT([$found_python3])
 
-AM_CONDITIONAL([ENABLE_PYTHON],[test "$found_python" = "yes"])
+AM_CONDITIONAL([ENABLE_PYTHON3],[test "x$found_python3" = "xyes"])
 
 dnl ================================================================
 dnl Documentation
@@ -436,6 +474,7 @@ libpeas-gtk/Makefile
 loaders/Makefile
 loaders/gjs/Makefile
 loaders/python/Makefile
+loaders/python3/Makefile
 loaders/seed/Makefile
 data/Makefile
 data/glade/Makefile
@@ -488,7 +527,8 @@ Configuration:
 
 Languages support:
 
-        Python support                : ${found_python}
+        Python 2 support              : ${found_python2}
+        Python 3 support              : ${found_python3}
         Javascript support (Seed)     : ${found_seed}
         Javascript support (GJS)      : ${found_gjs}
 "
diff --git a/loaders/Makefile.am b/loaders/Makefile.am
index 8de15e7..dd5ac86 100644
--- a/loaders/Makefile.am
+++ b/loaders/Makefile.am
@@ -4,10 +4,14 @@ if ENABLE_GJS
 SUBDIRS += gjs
 endif
 
-if ENABLE_PYTHON
+if ENABLE_PYTHON2
 SUBDIRS += python
 endif
 
+if ENABLE_PYTHON3
+SUBDIRS += python3
+endif
+
 if ENABLE_SEED
 SUBDIRS += seed
 endif
diff --git a/loaders/python/Makefile.am b/loaders/python/Makefile.am
index f029d8c..fee60da 100644
--- a/loaders/python/Makefile.am
+++ b/loaders/python/Makefile.am
@@ -8,8 +8,9 @@ INCLUDES = \
 	$(GCOV_CFLAGS)			\
 	$(WARN_CFLAGS)			\
 	$(DISABLE_DEPRECATED)		\
-	$(PYTHON_CFLAGS)		\
-	-DPEAS_PYEXECDIR=\""$(pyexecdir)"\" \
+	$(PYGOBJECT_CFLAGS)		\
+	$(PYTHON2_CFLAGS)		\
+	-DPEAS_PYEXECDIR=\""$(PYTHON2_PYEXECDIR)"\" \
 	-DPEAS_LOCALEDIR=\""$(prefix)/$(DATADIRNAME)/locale"\"
 
 loader_LTLIBRARIES = libpythonloader.la
@@ -26,7 +27,8 @@ libpythonloader_la_LDFLAGS = \
 
 libpythonloader_la_LIBADD = \
 	$(PEAS_LIBS)			\
-	$(PYTHON_LIBS)
+	$(PYGOBJECT_LIBS)		\
+	$(PYTHON2_LIBS)
 
 gcov_sources = $(libpythonloader_la_SOURCES)
 include $(top_srcdir)/Makefile.gcov
diff --git a/loaders/python3/Makefile.am b/loaders/python3/Makefile.am
new file mode 100644
index 0000000..fbe52ad
--- /dev/null
+++ b/loaders/python3/Makefile.am
@@ -0,0 +1,34 @@
+# Python 3 plugin loader
+
+loaderdir = $(libdir)/libpeas-1.0/loaders
+
+INCLUDES = \
+	-I$(top_srcdir)			\
+	$(PEAS_CFLAGS)			\
+	$(GCOV_CFLAGS)			\
+	$(WARN_CFLAGS)			\
+	$(DISABLE_DEPRECATED)		\
+	$(PYGOBJECT_CFLAGS)		\
+	$(PYTHON3_CFLAGS)		\
+	-DPEAS_PYEXECDIR=\""$(PYTHON3_PYEXECDIR)"\" \
+	-DPEAS_LOCALEDIR=\""$(prefix)/$(DATADIRNAME)/locale"\"
+
+loader_LTLIBRARIES = libpython3loader.la
+
+libpython3loader_la_SOURCES = \
+	$(top_srcdir)/loaders/python/peas-extension-python.c		\
+	$(top_srcdir)/loaders/python/peas-extension-python.h		\
+	$(top_srcdir)/loaders/python/peas-plugin-loader-python.c	\
+	$(top_srcdir)/loaders/python/peas-plugin-loader-python.h
+
+libpython3loader_la_LDFLAGS = \
+	$(LOADER_LIBTOOL_FLAGS)	\
+	$(GCOV_LDFLAGS)
+
+libpython3loader_la_LIBADD = \
+	$(PEAS_LIBS)			\
+	$(PYGOBJECT_LIBS)		\
+	$(PYTHON3_LIBS)
+
+gcov_sources = $(libpython3loader_la_SOURCES)
+include $(top_srcdir)/Makefile.gcov
diff --git a/peas-demo/plugins/Makefile.am b/peas-demo/plugins/Makefile.am
index 92ac90b..d9ea866 100644
--- a/peas-demo/plugins/Makefile.am
+++ b/peas-demo/plugins/Makefile.am
@@ -4,7 +4,7 @@ if ENABLE_GJS
 SUBDIRS += gjshello
 endif
 
-if ENABLE_PYTHON
+if ENABLE_PYTHON3
 SUBDIRS += pythonhello
 endif
 
diff --git a/peas-demo/plugins/pythonhello/pythonhello.plugin b/peas-demo/plugins/pythonhello/pythonhello.plugin
index 59139bb..6b96e73 100644
--- a/peas-demo/plugins/pythonhello/pythonhello.plugin
+++ b/peas-demo/plugins/pythonhello/pythonhello.plugin
@@ -1,6 +1,6 @@
 [Plugin]
 Module=pythonhello
-Loader=python
+Loader=python3
 Name=Python Says Hello
 Description=Inserts a box containing "Python Says Hello" in every windows.
 Authors=Steve FrÃcinaux <code istique net>
diff --git a/tests/libpeas/Makefile.am b/tests/libpeas/Makefile.am
index de308bf..5d317d6 100644
--- a/tests/libpeas/Makefile.am
+++ b/tests/libpeas/Makefile.am
@@ -35,11 +35,18 @@ extension_gjs_CFLAGS   = $(GJS_CFLAGS)
 extension_gjs_LDADD    = $(progs_ldadd) $(GJS_LIBS)
 endif
 
-if ENABLE_PYTHON
+if ENABLE_PYTHON2
 TEST_PROGS               += extension-python
 extension_python_SOURCES  = extension-python.c
-extension_python_CFLAGS   = $(PYTHON_CFLAGS)
-extension_python_LDADD    = $(progs_ldadd) $(PYTHON_LIBS)
+extension_python_CFLAGS   = $(PYGOBJECT_CFLAGS) $(PYTHON2_CFLAGS)
+extension_python_LDADD    = $(progs_ldadd) $(PYGOBJECT_LIBS) $(PYTHON2_LIBS)
+endif
+
+if ENABLE_PYTHON3
+TEST_PROGS                += extension-python3
+extension_python3_SOURCES  = extension-python3.c
+extension_python3_CFLAGS   = $(PYGOBJECT_CFLAGS) $(PYTHON3_CFLAGS)
+extension_python3_LDADD    = $(progs_ldadd) $(PYGOBJECT_LIBS) $(PYTHON3_LIBS)
 endif
 
 if ENABLE_SEED
diff --git a/tests/libpeas/extension-python3.c b/tests/libpeas/extension-python3.c
new file mode 100644
index 0000000..dee8876
--- /dev/null
+++ b/tests/libpeas/extension-python3.c
@@ -0,0 +1,124 @@
+/*
+ * extension-python3.c
+ * This file is part of libpeas
+ *
+ * Copyright (C) 2011 - Steve FrÃcinaux, Garrett Regier
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU Library General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU Library General Public License for more details.
+ *
+ *  You should have received a copy of the GNU Library General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <pygobject.h>
+
+#include <libpeas/peas-activatable.h>
+#include "loaders/python/peas-extension-python.h"
+
+#include "testing/testing-extension.h"
+#include "introspection/introspection-base.h"
+
+static void
+test_extension_python3_instance_refcount (PeasEngine     *engine,
+                                          PeasPluginInfo *info)
+{
+  PeasExtension *extension;
+  PyObject *instance;
+
+  extension = peas_engine_create_extension (engine, info,
+                                            INTROSPECTION_TYPE_BASE,
+                                            NULL);
+
+  g_assert (PEAS_IS_EXTENSION (extension));
+
+  instance = ((PeasExtensionPython *) extension)->instance;
+
+  g_assert_cmpint (instance->ob_refcnt, ==, 1);
+
+  /* The internal extension GObject should only be reffed by its python wrapper. */
+  g_assert_cmpint (((PyGObject *)instance)->obj->ref_count, ==, 1);
+
+  g_object_unref (extension);
+}
+
+static void
+test_extension_python3_activatable_subject_refcount (PeasEngine     *engine,
+                                                     PeasPluginInfo *info)
+{
+  PeasExtension *extension;
+  GObject *object;
+  PyObject *wrapper;
+
+  /* Create the 'object' property value, to be similar to a GtkWindow
+   * instance: a sunk GInitiallyUnowned object. */
+  object = g_object_new (G_TYPE_INITIALLY_UNOWNED, NULL);
+  g_object_ref_sink (object);
+  g_assert_cmpint (object->ref_count, ==, 1);
+
+  /* we pre-create the wrapper to make it easier to check reference count */
+  extension = peas_engine_create_extension (engine, info,
+                                            PEAS_TYPE_ACTIVATABLE,
+                                            "object", object,
+                                            NULL);
+
+  g_assert (PEAS_IS_EXTENSION (extension));
+
+  /* The python wrapper created around our dummy object should have increased
+   * its refcount by 1.
+   */
+  g_assert_cmpint (object->ref_count, ==, 2);
+
+  /* Ensure the python wrapper is only reffed once, by the extension */
+  wrapper = g_object_get_data (object, "PyGObject::wrapper");
+  g_assert_cmpint (wrapper->ob_refcnt, ==, 1);
+
+  g_assert_cmpint (G_OBJECT (extension)->ref_count, ==, 1);
+  g_object_unref (extension);
+
+  /* We unreffed the extension, so it should have been destroyed and our dummy
+   * object refcount should be back to 1. */
+  g_assert_cmpint (object->ref_count, ==, 1);
+
+  g_object_unref (object);
+}
+
+static void
+test_extension_python3_nonexistent (PeasEngine *engine)
+{
+  PeasPluginInfo *info;
+
+  testing_util_push_log_hook ("Error loading plugin 'extension-python3-nonexistent'");
+
+  info = peas_engine_get_plugin_info (engine, "extension-python3-nonexistent");
+
+  g_assert (!peas_engine_load_plugin (engine, info));
+}
+
+int
+main (int   argc,
+      char *argv[])
+{
+  g_test_init (&argc, &argv, NULL);
+  g_type_init ();
+
+  testing_extension_all ("python3");
+
+  EXTENSION_TEST (python3, "instance-refcount", instance_refcount);
+  EXTENSION_TEST (python3, "activatable-subject-refcount", activatable_subject_refcount);
+  EXTENSION_TEST (python3, "nonexistent", nonexistent);
+
+  return testing_extension_run_tests ();
+}
diff --git a/tests/libpeas/plugins/Makefile.am b/tests/libpeas/plugins/Makefile.am
index 1b093f9..00d28e4 100644
--- a/tests/libpeas/plugins/Makefile.am
+++ b/tests/libpeas/plugins/Makefile.am
@@ -10,8 +10,12 @@ SUBDIRS += extension-js
 endif
 endif
 
-if ENABLE_PYTHON
+if ENABLE_PYTHON3
 SUBDIRS += extension-python
+else
+if ENABLE_PYTHON2
+SUBDIRS += extension-python
+endif
 endif
 
 noinst_PLUGIN = \
@@ -19,6 +23,7 @@ noinst_PLUGIN = \
 	extension-c-nonexistent.plugin		\
 	extension-gjs-nonexistent.plugin	\
 	extension-python-nonexistent.plugin	\
+	extension-python3-nonexistent.plugin	\
 	extension-seed-nonexistent.plugin	\
 	info-missing-module.plugin		\
 	info-missing-name.plugin		\
diff --git a/tests/libpeas/plugins/extension-python/Makefile.am b/tests/libpeas/plugins/extension-python/Makefile.am
index ca8cd84..31a34f5 100644
--- a/tests/libpeas/plugins/extension-python/Makefile.am
+++ b/tests/libpeas/plugins/extension-python/Makefile.am
@@ -1,10 +1,31 @@
 include $(top_srcdir)/tests/Makefile.plugin
 
-noinst_PYTHON = extension-python.py
-
-noinst_PLUGIN = \
+noinst_DATA = \
 	extension-python.gschema.xml	\
 	extension-python.plugin		\
-	extension-python.py
+	extension-python.py		\
+	extension-python3.gschema.xml	\
+	extension-python3.plugin	\
+	extension-python3.py
+
+extension-py.%:
+	test -e $@
+
+extension-python.gschema.xml extension-python3.gschema.xml: extension-py.gschema.xml
+	$(AM_V_GEN) cp $< $@ && \
+	$(SED) -i -e 's%PY_LOADER%$(@:extension-%.gschema.xml=%)%g' $@
+
+extension-python.py extension-python3.py: extension-py.py
+	$(AM_V_GEN) $(LN_S) $< $@
+
+extension-python.plugin extension-python3.plugin: extension-py.plugin
+	$(AM_V_GEN) cp $< $@ && \
+	$(SED) -i -e 's%PY_LOADER%$(@:extension-%.plugin=%)%g' $@
+
+EXTRA_DIST = \
+	extension-py.gschema.xml	\
+	extension-py.plugin		\
+	extension-py.py
 
-EXTRA_DIST = $(noinst_PLUGIN)
+CLEANFILES = $(noinst_DATA)
+DISTCLEANFILES = $(noinst_DATA)
diff --git a/tests/libpeas/plugins/extension-python/extension-python.gschema.xml b/tests/libpeas/plugins/extension-python/extension-py.gschema.xml
similarity index 70%
rename from tests/libpeas/plugins/extension-python/extension-python.gschema.xml
rename to tests/libpeas/plugins/extension-python/extension-py.gschema.xml
index 8ba4ee4..c0f7bc8 100644
--- a/tests/libpeas/plugins/extension-python/extension-python.gschema.xml
+++ b/tests/libpeas/plugins/extension-python/extension-py.gschema.xml
@@ -1,5 +1,5 @@
 <schemalist>
-  <schema id="extension-python" path="/org/gnome/libpeas/tests/extension-python/">
+  <schema id="extension-PY_LOADER" path="/org/gnome/libpeas/tests/extension-PY_LOADER/">
     <key name="a-setting" type="s">
       <default>'Blah'</default>
       <summary>Just a setting.</summary>
diff --git a/tests/libpeas/plugins/extension-python/extension-py.plugin b/tests/libpeas/plugins/extension-python/extension-py.plugin
new file mode 100644
index 0000000..a3ba01f
--- /dev/null
+++ b/tests/libpeas/plugins/extension-python/extension-py.plugin
@@ -0,0 +1,8 @@
+[Plugin]
+Module=extension-PY_LOADER
+Loader=PY_LOADER
+Name=Extension PY_LOADER
+Description=This plugin is for the PY_LOADER PeasExtension tests.
+Authors=Garrett Regier
+Copyright=Copyright  2010 Garrett Regier
+Website=http://live.gnome.org/Libpeas
diff --git a/tests/libpeas/plugins/extension-python/extension-python.py b/tests/libpeas/plugins/extension-python/extension-py.py
similarity index 100%
rename from tests/libpeas/plugins/extension-python/extension-python.py
rename to tests/libpeas/plugins/extension-python/extension-py.py
diff --git a/tests/libpeas/plugins/extension-python3-nonexistent.plugin b/tests/libpeas/plugins/extension-python3-nonexistent.plugin
new file mode 100644
index 0000000..5678ffb
--- /dev/null
+++ b/tests/libpeas/plugins/extension-python3-nonexistent.plugin
@@ -0,0 +1,8 @@
+[Plugin]
+Module=extension-python3-nonexistent
+Loader=python3
+Name=Extension Python 3 Nonexistent
+Description=This plugin is nonexistent.
+Authors=Garrett Regier
+Copyright=Copyright  2011 Garrett Regier
+Website=http://live.gnome.org/Libpeas
diff --git a/tests/libpeas/testing/testing-extension.c b/tests/libpeas/testing/testing-extension.c
index 3004cbf..7b2b394 100644
--- a/tests/libpeas/testing/testing-extension.c
+++ b/tests/libpeas/testing/testing-extension.c
@@ -173,6 +173,7 @@ test_extension_create_invalid (PeasEngine     *engine,
   /* This cannot be tested in PyGI and Seed's log handler messes this up */
   if (g_strcmp0 (extension_plugin, "extension-c") != 0 &&
       g_strcmp0 (extension_plugin, "extension-python") != 0 &&
+      g_strcmp0 (extension_plugin, "extension-python3") != 0 &&
       g_strcmp0 (extension_plugin, "extension-seed") != 0)
     {
       testing_util_push_log_hook ("*cannot add *IntrospectionHasMissingPrerequisite* "



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]