kdevelop-python for python 3: beta release

Good news: Python 3.4 is about to be released, and with it kdevelop-python’s first version to support Python 3. Until that happens in a few days, here’s a beta:

kdev-python version 1.5.80-py3
http://download.kde.org/unstable/kdevelop/kdev-python/1.5.80/src/kdev-python-1.5.80-py3.tar.xz.mirrorlist
SHA256:99ca1ce97e2a7e553051be7505c17a921ab1aaf318999826ea285f771bcc538a

The kdev-python 1.6-py3 series is compatible with KDevelop 4.6 (kdevplatform 1.6) and is suitable for working with Python 3.x source code.
If you’re only interested in using (as opposed to packaging or developing) kdev-python, you should consider installing kdev-python from your distribution’s package manager instead of downloading the source code.

There are a few things which need to be announced about this, so read on!

Embedded Python fork

First and foremost, this abomination is finally gone in the -py3 series. Python 3.4 merged a patch which is required by kdev-python, and now we can use the system’s python installation. This will especially make kdev-python comply with all distribution’s requirements for packaging software, which means it will hopefully soon be available in all major distribution’s package repositories.
This also means that kdev-python now depends on Python =3.4.

Python 2 compatibility

The py3 series is not compatible with Python 2, and currently you can not install kdev-python and kdev-python3 side-by-side. I will try to address this restriction in the future and I will also publish a script to install the two versions into separate environments, but for now that’s what is like. Especially, for packagers, this means that kdev-python must conflict with kdev-python3. The problem cannot be solved by renaming all the files, it also requires new UI and glue code to be written to select the correct language version, which I only have done partially as of today.

Branch names in kdev-python.git

I also used this opportunity to reorganize the branches in kdev-python.git a bit:

  • python3 is now python3-legacy (do not use)
  • python3-nofork is now python3; this branch is the most recent (unstable) version of the python3 version of the plugin, and compiles against kdevplatform master
  • there’s a 1.6-py3 branch which is like 1.6 but for python 3.

If you had any of the renamed branches checked out, you might need to do git reset –hard origin/branchname. In the near future, master will also be renamed to python2 and python3 will be renamed to master (but not yet).

Feature comparison of kdev-python3 and kdev-python2

Generally, the Python 3 version has all the features from Python 2 plus a few more and some bug fixes. Not all new Python 3 features are understood yet (the syntax is supported, but the semantics isn’t, e.g. nonlocal does nothing), though. What is there however is support for function annotations:

If the expressions in a function annotation represent a type (i.e. not an instance or something different) they are used to adjust the function’s return and argument types.

I really hope this feature gets used for type hints, so this is a first step to encourage you to use it for that. 😉
Not all is awesome just yet, though: Although I’m not aware of any major issues, there will be regressions (things which were working in Python 2 but are now broken). There are always regressions, even with the ~90% test coverage kdev-python has. That’s the purpose of this beta: go forth and test, and report all the bugs to the tracker so they can be slain!

Categories: Everything

Tags: , , , , ,

2 replies

  1. I just read that Python 3.4 was released and remember your blog and your comments regarding kdev-python and this latest Python release. I am really happy and looking forward to start testing it! (and eventually migrate all my scripts and projects onto py3

    • Yep — I will do a release of kdev-python3 later today. I wanted to do it yesterday, where the py3.4 release was announced, but it didn't happen in time for me to prepare my own release.

Leave a Reply

Your email address will not be published. Required fields are marked *