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

Bug#672553: pykde4: Add Python 3 support



Package: pykde4
Version: 4:4.7.4-2
Severity: wishlist
Tags: patch
User: ubuntu-devel@lists.ubuntu.com
Usertags: origin-ubuntu ubuntu-patch quantal

pykde4 already supports Python 3 in the upstream code.  Making this
available would be a simple matter of packaging.

Well ... almost.  There are a couple of things that complicate it.
Firstly, there's a patch from newer upstream releases to fix building
with >= 3.2.  Secondly, a bug in kdelibs5-dev (which I've filed
separately as #672552) causes a build failure; I worked around that by
shipping a local cut-down copy of PythonMacros.cmake, which I reckoned
would be temporarily acceptable because the resulting file is so short.

I've tested this by running a Python 3 port of the Ubuntu installer's
KDE frontend with it, and everything appears to be working fine.  I
built my test packages on Ubuntu rather than Debian because I ran into
#671893 and couldn't readily fix that, but I hope it will still be OK
once that's fixed.

  * Add Python 3 support.

diff --git a/debian/control b/debian/control
index 51ac67f..d634f34 100644
--- a/debian/control
+++ b/debian/control
@@ -8,8 +8,9 @@ Build-Depends: kde-sc-dev-latest (>= 4:4.7.4),
  libphonon-dev (>= 4:4.6.0really4.4.4), libsoprano-dev (>= 2.7.0),
  libqt4-dev (>= 4:4.7.1), libqt4-opengl-dev (>= 4:4.7.1), libqtwebkit-dev,
  libboost-dev, shared-desktop-ontologies (>= 0.8),
- python, python-all-dev, python-sip-dev (>= 4.12.0),
- python-qt4 (>= 4.8.3-3~), python-qt4-dev (>= 4.8.3-3~)
+ python, python-all-dev, python3-all-dev,
+ python-sip-dev (>= 4.12.0), python3-sip-dev,
+ python-qt4 (>= 4.8.3-3~), python3-pyqt4, python-qt4-dev (>= 4.8.3-3~)
 Uploaders: Sune Vuorela <sune@debian.org>, Modestas Vainius <modax@debian.org>, Michael Meskes <meskes@debian.org>
 Standards-Version: 3.9.2
 X-Python-Version: >= 2.5
@@ -89,3 +90,50 @@ Description: debugging symbols for the PyKDE bindings
  are experiencing crashes of the PyKDE application and wish to report a problem
  to the developers.
 
+Package: python3-kde4
+Architecture: any
+Depends: ${shlibs:Depends}, ${python3:Depends}, ${misc:Depends},
+ python3-pyqt4, ${sip:Depends}, python3-sip
+Provides: ${python3:Provides}
+Description: Python 3 bindings for the KDE Development Platform
+ This package contains PyKDE, the Python 3 bindings for the KDE
+ libraries, that allow you to write KDE programs using Python 3 instead of
+ C++. It contains at least the following modules under the
+ PyKDE namespace:
+ .
+  * dnssd
+  * kdecore
+  * kdeui
+  * khtml
+  * kio
+  * knewstuff
+  * kparts
+  * kterminal
+  * ktexteditor
+  * kutils
+  * nepomuk
+  * plasma
+  * solid
+ .
+ And a few KDE related technologies like:
+ .
+  * akonadi
+  * phonon
+  * soprano
+ .
+ This package provides modules for all supported Python 3 versions.
+
+Package: python3-kde4-dbg
+Section: debug
+Architecture: any
+Priority: extra
+Depends: ${misc:Depends}, kdelibs5-dbg, python3-kde4 (= ${binary:Version})
+Recommends: python3-pyqt4-dbg
+Breaks: kdebindings-dbg
+Replaces: kdebindings-dbg
+Description: debugging symbols for the PyKDE bindings
+ This package contains debugging files used to investigate problems with
+ Python 3 bindings for the KDE Development Platform. Install this package if
+ you are experiencing crashes of the PyKDE application and wish to report a
+ problem to the developers.
+
diff --git a/debian/patches/cmake_no_bytecode.diff b/debian/patches/cmake_no_bytecode.diff
new file mode 100644
index 0000000..ab90706
--- /dev/null
+++ b/debian/patches/cmake_no_bytecode.diff
@@ -0,0 +1,31 @@
+Index: b/cmake/modules/PythonMacros.cmake
+===================================================================
+--- /dev/null
++++ b/cmake/modules/PythonMacros.cmake
+@@ -0,0 +1,26 @@
++# Python macros
++# ~~~~~~~~~~~~~
++# Copyright (c) 2007, Simon Edwards <simon@simonzone.com>
++# Cloned-and-hacked by Colin Watson <cjwatson@ubuntu.com>, removing bytecode
++# support.
++#
++# Redistribution and use is allowed according to the terms of the BSD license.
++# For details see the accompanying COPYING-CMAKE-SCRIPTS file.
++#
++# This file defines the following macros:
++#
++# PYTHON_INSTALL (SOURCE_FILE DESINATION_DIR)
++#     Install the SOURCE_FILE, which is a Python .py file, into the
++#     destination directory during install.
++
++GET_FILENAME_COMPONENT(PYTHON_MACROS_MODULE_PATH ${CMAKE_CURRENT_LIST_FILE}  PATH)
++
++MACRO(PYTHON_INSTALL SOURCE_FILE DESINATION_DIR)
++
++  FIND_FILE(_python_compile_py PythonCompile.py PATHS ${CMAKE_MODULE_PATH})
++
++  ADD_CUSTOM_TARGET(compile_python_files ALL)
++
++  # Install the source file.
++  INSTALL(FILES ${SOURCE_FILE} DESTINATION ${DESINATION_DIR})
++ENDMACRO(PYTHON_INSTALL)
diff --git a/debian/patches/python32_compile_fix.diff b/debian/patches/python32_compile_fix.diff
new file mode 100644
index 0000000..5440477
--- /dev/null
+++ b/debian/patches/python32_compile_fix.diff
@@ -0,0 +1,21 @@
+Description: Compile fix for Python 3.2 and higher
+Author: Simon Edwards <simon@simonzone.com>
+Origin: upstream, https://projects.kde.org/projects/kde/kdebindings/pykde4/repository/revisions/54bd6a7628e04efe5e1de53075227713f2526acf
+Last-Update: 2012-05-08
+
+Index: b/sip/kio/kfileitem.sip
+===================================================================
+--- a/sip/kio/kfileitem.sip
++++ b/sip/kio/kfileitem.sip
+@@ -236,7 +236,11 @@
+         
+         len = sipCpp->count();
+         
++#if PY_VERSION_HEX >= 0x03020000
++        if (PySlice_GetIndicesEx(a0, len, &start, &stop, &step, &slicelength) < 0)
++#else
+         if (PySlice_GetIndicesEx((PySliceObject *)a0, len, &start, &stop, &step, &slicelength) < 0)
++#endif
+             sipIsErr = 1;
+         else
+         {
diff --git a/debian/patches/series b/debian/patches/series
index 0474e82..04bb536 100644
--- a/debian/patches/series
+++ b/debian/patches/series
@@ -4,3 +4,5 @@ fix_kpythonpluginfactory_build.diff
 make_pykde4_respect_sip_flags.diff
 pythonpluginfactory_use_versioned_python_lib.diff
 optional_install_sip_files.diff
+python32_compile_fix.diff
+cmake_no_bytecode.diff
diff --git a/debian/python-kde4.install b/debian/python-kde4.install
index bb19869..824bdd6 100644
--- a/debian/python-kde4.install
+++ b/debian/python-kde4.install
@@ -1,6 +1,6 @@
 usr/lib/kde4/kpythonpluginfactory.so
-usr/lib/python*/*-packages/PyKDE4/*.so
-usr/lib/python*/*-packages/PyKDE4/__init__.py
-usr/lib/python*/*-packages/PyKDE4/pykdeconfig.py
-usr/lib/python*/*-packages/PyQt4/uic/pykdeuic4.py
-usr/lib/python*/*-packages/PyQt4/uic/widget-plugins/kde4.py
+usr/lib/python2.*/*-packages/PyKDE4/*.so
+usr/lib/python2.*/*-packages/PyKDE4/__init__.py
+usr/lib/python2.*/*-packages/PyKDE4/pykdeconfig.py
+usr/lib/python2.*/*-packages/PyQt4/uic/pykdeuic4.py
+usr/lib/python2.*/*-packages/PyQt4/uic/widget-plugins/kde4.py
diff --git a/debian/python3-kde4.docs b/debian/python3-kde4.docs
new file mode 100644
index 0000000..e845566
--- /dev/null
+++ b/debian/python3-kde4.docs
@@ -0,0 +1 @@
+README
diff --git a/debian/python3-kde4.install b/debian/python3-kde4.install
new file mode 100644
index 0000000..3367644
--- /dev/null
+++ b/debian/python3-kde4.install
@@ -0,0 +1,5 @@
+usr/lib/python3/*-packages/PyKDE4/*.so
+usr/lib/python3/*-packages/PyKDE4/__init__.py
+usr/lib/python3/*-packages/PyKDE4/pykdeconfig.py
+usr/lib/python3/*-packages/PyQt4/uic/pykdeuic4.py
+usr/lib/python3/*-packages/PyQt4/uic/widget-plugins/kde4.py
diff --git a/debian/rules b/debian/rules
index 90db410..e637de3 100755
--- a/debian/rules
+++ b/debian/rules
@@ -1,6 +1,6 @@
 #! /usr/bin/make -f
 
-dh = --with=python2
+dh = --with=python2,python3
 
 include /usr/share/pkg-kde-tools/qt-kde-team/2/debian-qt-kde.mk
 
@@ -8,6 +8,7 @@ pyversions = $(shell pyversions -vr)
 pydefaultversion = $(shell pyversions -vd)
 pyshared_nondefault = $(foreach v,$(filter-out $(pydefaultversion),$(pyversions)),\
     usr/lib/pyshared/python$v/PyKDE4 usr/lib/python$v/dist-packages/PyKDE4)
+py3versions = $(shell py3versions -vr)
 
 define nl
 
@@ -20,16 +21,24 @@ override_dh_auto_configure:
 	    -DPYTHON_EXECUTABLE=/usr/bin/python$v \
 	    -DDEFAULT_PYTHON_VERSION=$(if $(filter $(pydefaultversion),$v),true,false) \
 	    $(nl))
+	$(foreach v,$(py3versions),$(overridden_command) --builddirectory=builddir-$v -- \
+	    -DPYTHON_EXECUTABLE=/usr/bin/python$v \
+	    -DPYTHON_LIBRARY=/usr/lib/libpython${v}mu.so \
+	    -DPYTHON_SITE_PACKAGES_INSTALL_DIR=/usr/lib/python3/dist-packages \
+	    -DDEFAULT_PYTHON_VERSION=false \
+	    $(nl))
 
 override_dh_auto_build override_dh_auto_install override_dh_auto_test override_dh_auto_clean:
 	$(foreach v,$(pyversions),$(overridden_command) --builddirectory=builddir-$v $(nl))
+	$(foreach v,$(py3versions),$(overridden_command) --builddirectory=builddir-$v $(nl))
 
 override_dh_python2:
 	$(overridden_command)
 	dh_sip -ppython-kde4
 
 override_dh_strip:
-	$(overridden_command) --dbg-package=python-kde4-dbg
+	$(overridden_command) -ppython-kde4 --dbg-package=python-kde4-dbg
+	$(overridden_command) -ppython3-kde4 --dbg-package=python3-kde4-dbg
 
 override_dh_shlibdeps:
 	if [ -d debian/python-kde4 ]; then \

Thanks,

-- 
Colin Watson                                       [cjwatson@ubuntu.com]



Reply to: