Add the whole blog

This commit is contained in:
Luca Beltrame 2020-12-28 18:06:15 +01:00
parent 0d2f58ce7a
commit c4f23c1529
Signed by: einar
GPG key ID: 4707F46E9EC72DEC
418 changed files with 15708 additions and 0 deletions

View file

@ -0,0 +1,41 @@
---
author: einar
categories:
- General
- KDE
- Linux
comments: true
date: "2012-12-02T18:00:57Z"
slug: making-kde-applications-python-3-friendly
tags:
- KDE
- pykde
- python
title: Making KDE applications Python 3 friendly
disable_share: true
wordpress_id: 1044
---
When I'm not on [forum duty](http://forum.kde.org) or handling [openSUSE](http://www.opensuse.org)-related contributions, I try to improve my code contributions to KDE, even though I'm by no means an experienced programmer (I program all day long in Python, but I'm still a biologist after all). For the upcoming 4.10 release I've been polishing up Python 3 support.
As you may know, Python 3 isn't the standard in many distributions (Arch Linux excluded), but despite the slow start, it is slowly gaining steam. PyKDE4 was built keeping in mind Python 3 support, so theoretically we supported it right from the start.
When I wanted to package PyKDE4 for Python 3 in openSUSE, I stumbled upon some quirks: the CMake build system was not finding Python 3 properly. After some investigation, I noticed that the Python macros responsible for finding the Python library had some assumptions that worked fine for Python 2, but not for Python 3 (a lot of distributions name libypthon3 with a suffix, like _mu_). Since 4.10 was bumping the minimum required CMake version to 2.8.8, I moved in and [rewrote the macros making use of the new functionality offered by upstream CMake](https://projects.kde.org/projects/kde/kdelibs/repository/revisions/2526082c9691b313e04925725b36db2924d96e30) (with a big help from Rolf Eike Beer).
As I worked more on PyKDE4, I hit a second snag: i18n() calls were chocking on Unicode. As QString is Unicode-aware, that was really difficult to debug. The root cause was actually [a SNAFU of my own caused by swapping lines](https://projects.kde.org/projects/kde/kdebindings/pykde4/repository/revisions/ba44c32b266c598c764447a8411e9000e7ec7dd9), and will be fixed in 4.9.4 and 4.10.
Lastly, I got word that [Kate's Pate](http://kate-editor.org/2012/06/26/extending-kate-with-pytho/) was [not building on Python 3](https://bugs.kde.org/show_bug.cgi?id=310220). This caused a huge back and forth of mails and IRC conversations between me and Pate's developer, Shaheed Haque. I initially fixed building with [a very crude patch](https://git.reviewboard.kde.org/r/107362/), which Shaheed improved afterwards. Then the product built under Python 3.3, but kept on crashing. After some debugging, two different issues were found (module not found when imported, and string conversions). With those fixed, Pate would load in Kate but crash when any plugin documentation was loaded. A few more rounds of discussion and commits, and I'm happy to report that everything works as intended!
[![]({{ site.url }}/images/2012/12/pate_py3-300x205.png)]({{ site.url }}/images/2012/12/pate_py3.png)
In short, 4.10 should be a good release for Python 3 users. I have some ideas for 4.11 as well: time will tell if I get around to doing them.