Bug#678354: libpeas: Build a Python 3 loader

Dmitrijs Ledkovs dmitrijs.ledkovs at canonical.com
Fri Jun 22 08:50:13 UTC 2012


Dear all,

Here is an improvement on top of Barry's patch:

* clean up and remove ubuntu-specific bits
* build one language loader per 'flavor'

This allows easily enabling/disabling flavors.

What about gjs? Was there a reason why that one was not built?
I added debian/rules support for it, but didn't enable nor added
additional dependencies.

-- 
Regards,
Dmitrijs.
-------------- next part --------------
=== modified file 'debian/changelog'
--- debian/changelog	2012-06-21 23:01:31 +0000
+++ debian/changelog	2012-06-22 08:44:42 +0000
@@ -1,3 +1,15 @@
+libpeas (1.4.0-2.1) unstable; urgency=low
+
+  [ Barry Warsaw ]
+  * Build the Python 3 plugin, and enable it to exist next to the Python 2
+    plugin (though only one can be used by an application at a time).  Add
+    Python 3 support to peas-demo.
+
+  [ Dmitrijs Ledkovs ]
+  * Build one language loader per flavor. There is no vala loader, as it's C.
+
+ -- Dmitrijs Ledkovs <dmitrij.ledkov at ubuntu.com>  Fri, 22 Jun 2012 00:07:26 +0100
+
 libpeas (1.4.0-2) unstable; urgency=low
 
   * Don't enable the seed plugin on ia64 and mips since seed is not available

=== modified file 'debian/control'
--- debian/control	2012-06-21 23:01:31 +0000
+++ debian/control	2012-06-21 23:06:07 +0000
@@ -9,6 +9,7 @@
 Uploaders: Martin Pitt <mpitt at debian.org>, Michael Biebl <biebl at debian.org>, Sjoerd Simons <sjoerd at debian.org>
 Build-Depends: cdbs (>= 0.4.90),
                debhelper (>= 8),
+               autoconf,
                gnome-pkg-tools,
                intltool (>= 0.40),
                gtk-doc-tools (>= 1.11),
@@ -20,6 +21,7 @@
                libseed-gtk3-dev (>= 2.91.91) [!ia64 !mips],
                python-dev (>= 2.5.2),
                python-gi-dev (>= 3.0.0),
+               python3-dev,
                valac-0.14,
                gnome-icon-theme
 Standards-Version: 3.9.3

=== modified file 'debian/control.in'
--- debian/control.in	2012-06-21 23:01:31 +0000
+++ debian/control.in	2012-06-21 23:05:45 +0000
@@ -4,6 +4,7 @@
 Uploaders: @GNOME_TEAM@
 Build-Depends: cdbs (>= 0.4.90),
                debhelper (>= 8),
+               autoconf,
                gnome-pkg-tools,
                intltool (>= 0.40),
                gtk-doc-tools (>= 1.11),
@@ -15,6 +16,7 @@
                libseed-gtk3-dev (>= 2.91.91) [!ia64 !mips],
                python-dev (>= 2.5.2),
                python-gi-dev (>= 3.0.0),
+               python3-dev,
                valac-0.14,
                gnome-icon-theme
 Standards-Version: 3.9.3

=== added directory 'debian/patches'
=== added file 'debian/patches/python3-demo.patch'
--- debian/patches/python3-demo.patch	1970-01-01 00:00:00 +0000
+++ debian/patches/python3-demo.patch	2012-06-21 23:01:50 +0000
@@ -0,0 +1,154 @@
+Description: Add Python 3 demo.
+ This patch mostly just copies the existing Python plugin demo, but tweaks the
+ visible strings to show how a Python 2 or Python 3 (but not both) plugin can
+ be used in a single application.
+Author: Barry Warsaw <barry at python.org>
+Forwarded: no
+
+--- a/peas-demo/peas-demo.c
++++ b/peas-demo/peas-demo.c
+@@ -126,6 +126,7 @@
+ 
+   peas_engine_enable_loader (engine, "gjs");
+   peas_engine_enable_loader (engine, "python");
++  peas_engine_enable_loader (engine, "python3");
+   peas_engine_enable_loader (engine, "seed");
+ 
+   if (run_from_build_dir)
+--- /dev/null
++++ b/peas-demo/plugins/python3hello/Makefile.am
+@@ -0,0 +1,8 @@
++plugindir = $(libdir)/peas-demo/plugins/python3hello
++
++plugin_PYTHON = \
++	python3hello.py
++
++plugin_DATA = python3hello.plugin
++
++EXTRA_DIST = $(plugin_DATA)
+--- /dev/null
++++ b/peas-demo/plugins/python3hello/python3hello.plugin
+@@ -0,0 +1,13 @@
++[Plugin]
++Module=python3hello
++Loader=python3
++IAge=2
++Name=Python 3 Says Hello
++Description=Inserts a box containing "Python 3 Says Hello" in every windows.
++Authors=Steve Frécinaux <code at istique.net>
++Copyright=Copyright © 2009 Steve Frécinaux
++Website=http://code.istique.net/
++Help=http://git.gnome.org/browse/error
++Help-Windows=http://git.gnome.org/browse/libpeas
++Help-MacOS-X=http://git.gnome.org/browse/libpeas
++Help-GNOME=http://git.gnome.org/browse/libpeas
+--- /dev/null
++++ b/peas-demo/plugins/python3hello/python3hello.py
+@@ -0,0 +1,61 @@
++# -*- coding: utf-8 -*-
++# ex:set ts=4 et sw=4 ai:
++
++##
++# python3hello.py
++# This file is part of libpeas
++#
++# Copyright (C) 2009-2010 Steve Frécinaux
++#
++# 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.
++##
++
++import sys
++
++from gi.repository import GObject
++from gi.repository import Peas
++from gi.repository import PeasGtk
++from gi.repository import Gtk
++
++LABEL_STRING="Python {}.{} Says Hello!".format(*sys.version_info[:2])
++
++class Python3HelloPlugin(GObject.Object, Peas.Activatable):
++    __gtype_name__ = 'Python3HelloPlugin'
++
++    object = GObject.property(type=GObject.Object)
++
++    def do_activate(self):
++        window = self.object
++        print("Python3HelloPlugin.do_activate", repr(window))
++        window._pythonhello_label = Gtk.Label()
++        window._pythonhello_label.set_text(LABEL_STRING)
++        window._pythonhello_label.show()
++        window.get_child().pack_start(window._pythonhello_label, True, True, 0)
++
++    def do_deactivate(self):
++        window = self.object
++        print("Python3HelloPlugin.do_deactivate", repr(window))
++        window.get_child().remove(window._pythonhello_label)
++        window._pythonhello_label.destroy()
++
++    def do_update_state(self):
++        print("Python3HelloPlugin.do_update_state", repr(self.object))
++
++class Python3HelloConfigurable(GObject.Object, PeasGtk.Configurable):
++    __gtype_name__ = 'Python3HelloConfigurable'
++
++    def do_create_configure_widget(self):
++        return Gtk.Label.new("Python {}.{} Hello configure widget".format(
++            *sys.version_info[:2]))
+--- a/peas-demo/plugins/Makefile.am
++++ b/peas-demo/plugins/Makefile.am
+@@ -5,7 +5,7 @@
+ endif
+ 
+ if ENABLE_PYTHON
+-SUBDIRS += pythonhello
++SUBDIRS += pythonhello python3hello
+ endif
+ 
+ if ENABLE_SEED
+--- a/configure.ac
++++ b/configure.ac
+@@ -490,6 +490,7 @@
+ peas-demo/plugins/gjshello/Makefile
+ peas-demo/plugins/helloworld/Makefile
+ peas-demo/plugins/pythonhello/Makefile
++peas-demo/plugins/python3hello/Makefile
+ peas-demo/plugins/secondtime/Makefile
+ peas-demo/plugins/seedhello/Makefile
+ peas-demo/plugins/valahello/Makefile
+--- a/peas-demo/plugins/pythonhello/pythonhello.py
++++ b/peas-demo/plugins/pythonhello/pythonhello.py
+@@ -22,12 +22,14 @@
+ # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ ##
+ 
++import sys
++
+ from gi.repository import GObject
+ from gi.repository import Peas
+ from gi.repository import PeasGtk
+ from gi.repository import Gtk
+ 
+-LABEL_STRING="Python Says Hello!"
++LABEL_STRING="Python {}.{} Says Hello!".format(*sys.version_info[:2])
+ 
+ class PythonHelloPlugin(GObject.Object, Peas.Activatable):
+     __gtype_name__ = 'PythonHelloPlugin'
+@@ -55,4 +57,5 @@
+     __gtype_name__ = 'PythonHelloConfigurable'
+ 
+     def do_create_configure_widget(self):
+-        return Gtk.Label.new("Python Hello configure widget")
++        return Gtk.Label.new("Python {}.{} Hello configure widget".format(
++            *sys.version_info[:2]))

=== added file 'debian/patches/series'
--- debian/patches/series	1970-01-01 00:00:00 +0000
+++ debian/patches/series	2012-06-21 23:01:50 +0000
@@ -0,0 +1,1 @@
+python3-demo.patch

=== modified file 'debian/rules'
--- debian/rules	2012-06-21 23:01:31 +0000
+++ debian/rules	2012-06-22 08:41:45 +0000
@@ -1,19 +1,30 @@
 #!/usr/bin/make -f
 
+include /usr/share/cdbs/1/rules/buildvars.mk
+
+DEB_PEAS_LOADERS ?= python python3 $(if $(filter-out ia64 mips, $(DEB_HOST_ARCH)),seed)
+DEB_MAKE_FLAVORS = all $(DEB_PEAS_LOADERS)
+DEB_DH_INSTALL_SOURCEDIR = debian/tmp/all
+DEB_BUILDDIR = build
+
 include /usr/share/cdbs/1/rules/debhelper.mk
 include /usr/share/cdbs/1/class/gnome.mk
 include /usr/share/cdbs/1/rules/utils.mk
 include /usr/share/gnome-pkg-tools/1/rules/uploaders.mk
 include /usr/share/gnome-pkg-tools/1/rules/gnome-get-source.mk
 
-DEB_CONFIGURE_EXTRA_FLAGS += --enable-gtk-doc \
-                             --enable-vala \
-                             --enable-python \
-                             --disable-gjs
-
-ifeq (,$(filter $(DEB_HOST_ARCH),ia64 mips))
-DEB_CONFIGURE_EXTRA_FLAGS += --enable-seed
-endif
+makebuilddir::
+	autoreconf
+
+DEB_CONFIGURE_FLAGS_all  += --enable-gtk-doc --enable-vala --disable-python
+
+DEB_PEAS_FLAGS := --disable-gtk --disable-glade-catalog --disable-python
+DEB_CONFIGURE_FLAGS_python  += $(DEB_PEAS_FLAGS) --enable-python
+DEB_CONFIGURE_FLAGS_python3 += $(DEB_PEAS_FLAGS) --enable-python
+DEB_CONFIGURE_FLAGS_seed    += $(DEB_PEAS_FLAGS) --enable-seed
+DEB_CONFIGURE_FLAGS_gjs     += $(DEB_PEAS_FLAGS) --enable-gjs
+
+debian/stamp-autotools/python3:: DEB_CONFIGURE_SCRIPT_ENV=PYTHON=python3
 
 # We clean the test directory before running check because we need to stop
 # -Bsymbolic-functions from being used when building the tests.  Else
@@ -22,6 +33,17 @@
 
 DEB_DH_MAKESHLIBS_ARGS_libpeas-1.0-0 += -X/usr/lib/libpeas-1.0/
 
+ifneq (,$(filter python3, $(DEB_PEAS_LOADERS)))
+common-install-arch::
+	cd debian/tmp/python3/usr/lib/libpeas-1.0/loaders/ && \
+		mv libpythonloader.so libpython3loader.so
+endif
+
+install/libpeas-1.0-0::
+	install -d debian/tmp/all/usr/lib/libpeas-1.0/loaders
+	cp -a debian/tmp/*/usr/lib/libpeas-1.0/loaders/*.so \
+	      debian/tmp/all/usr/lib/libpeas-1.0/loaders
+
 binary-post-install/libpeas-doc::
 	# remove compiled python and libtool .la files
 	find debian/$(cdbs_curpkg) -name '*.pyo' -delete



More information about the pkg-gnome-maintainers mailing list