Python/Harmattan/Python 2.6 porting tips

[edit] Introduction

Porting a package to support Python 2.6 usually involves making it version agnostic, removing any explicit Python versioning. In Maemo versions prior to Maemo 5, the packages had hardcoded support for Python 2.5, which can be demonstrated by all Python binding packages having "python2.5-" as prefix and consequently Python applications having these names also on their runtime dependencies. As Maemo 5 also used Python 2.5, these packages still worked without much problems, but as MeeGo 1.2 Harmattan uses Python 2.6 they will have to be ported.

[edit] Python 2.6 porting tips

  • First of all, consider using pyside-assistant for taking care of the packaging of your application, instead of packaging it by hand. This way you can avoid dealing with various issues regarding Debian packaging and focus mostly in the application itself.
  • Any paths that, for some reason, have hardcoded "python2.5" or "site-packages" will have to be changed to "python2.6" and "dist-packages", as these are the ones used on Python 2.6.
  • If your application uses any python2.5 prefixed package as one of its dependencies in any Depends field, you should drop the version number and add the version as a requirement - for example, python2.5 can be changed to python (>= 2.5) without problems. If this is not possible or not desired, just change the dependencies to their python2.6 counterparts.
  • Also, this would be a good time for your package to be named following the new Debian Python Policy - the Policy states that Python packages must not have a fixed version number on its name (e.g. prefer python-foo instead of python2.6-foo).
  • One very particular case where changes are required is when some Python script uses identifiers that became reserved keywords in Python 2.6. As an example, old versions of python-xml had this issue, where the as identifier (which became a reserved keyword in Python 2.6) was being used as variable name in some places. If these occurrences are not replaced, running the script will result in syntax errors.