Editing PyMaemo/Python 2.6 porting guide

Warning: You are not logged in. Your IP address will be recorded in this page's edit history.
The edit can be undone. Please check the comparison below to verify that this is what you want to do, and then save the changes below to finish undoing the edit.
Latest revision Your text
Line 1: Line 1:
-
{{out of date}}
+
== Python 2.6 Porting Guide ==
<b style="color: red">Important: this document is still a draft. There are currently no planned dates for migration to 2.6, but it will be informed in advance on the maemo-developers and pymaemo-developers mailing lists, so that developers have some time to fix their packages.</b>
<b style="color: red">Important: this document is still a draft. There are currently no planned dates for migration to 2.6, but it will be informed in advance on the maemo-developers and pymaemo-developers mailing lists, so that developers have some time to fix their packages.</b>
Line 5: Line 5:
This documents contains some general guidelines about how to port your Python application currently being used with Python 2.5 for working without problems with Python 2.6.
This documents contains some general guidelines about how to port your Python application currently being used with Python 2.5 for working without problems with Python 2.6.
-
== Introduction ==
+
=== Introduction ===
-
Currently, Maemo 4.x (Diablo) has Python 2.5. Maemo 5 (Fremantle) has this same version, but we are evaluating upgrading Fremantle to Python 2.6, so that developers can use the latest features, while keeping compatibility with Python 2.5. See the [http://docs.python.org/whatsnew/2.6.html What’s New in Python 2.6] page for details.
+
Currently, Maemo 4.x (Diablo) has Python 2.5. Maemo 5 Beta (Fremantle) also has 2.5, but we are evaluating upgrading Fremantle to 2.6, so that developers can use the latest features, while keeping compatibility with Python 2.5. See the [http://docs.python.org/whatsnew/2.6.html What’s New in Python 2.6] page for details.
-
This also means that we have no plans to migrate to Python 3.x during Fremantle life cycle. Using Python 2.6 is the best option because developers can use most 3.x features without breaking compatibility with Python 2.5. With Python 2.6, users can use a flag to check for possible incompatibilities with Python 3.x.
+
This also means that we have no plans to migrate to Python 3.x in Fremantle. Using Python 2.6 is the best option because developers can use most 3.x features without breaking compatibility with Python 2.5.
-
One question might arise: why not have both 2.6 and 3.x, or even 2.5, 2.6 and 3.x? We have thought about this, the problem is, with the current mechanism used in Debian and Ubuntu (which we also use), packages that install Python extensions need to be compiled for all supported versions, and all resulting binaries are installed ''in a single package''. This means that some packages will simply double or triple their size even if only one version is installed and used.
+
One question might arise: why not have both 2.6 and 3.x, or even 2.5, 2.6 and 3.x? We have thought about this, the problem is, in the current mechanism used in Debian and Ubuntu (that we also use), the packages that install Python extensions need to be compiled for all supported versions, and all these versions are installed <b>in a single package</b>. This means that some packages will simply double or triple their size even if only one version is installed.
-
Besides, if we have two or three versions available in the repository, there is a possibility that some packages would depend on e.g. 2.5 while others depend 3.x. So the user would need to have ''both'' versions installed in some cases.
+
Besides, if we have two or three versions available in the repository, there is a possibility that some packages depend on e.g. 2.5 while others depend 3.x. So the user would need to have <b>both</b> versions installed in some cases.
-
For small devices such as the Internet Tablets, saving space is also a high priority, so we decided to support only a single version at a time during the life cycle of a Maemo distribution.
+
For small devices as the Internet Tablets, saving space is also a high priority, so we decided to support a single version during the life cycle of the distribution.
-
=== Python 2.6 porting guidelines ===
+
<b>FINISH ME</b>
-
Porting a package to support Python 2.6 usually involves actually making it version agnostic. In Maemo versions prior to Fremantle, 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 also had these names on their Depends fields in debian/control.
+
* Any paths that, for some reason, must 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 you use distutils for building your package, you must pass the --install-layout=deb flag for "setup.py install" command inside debian/rules in order to install the files to the proper locations. If you're using CDBS for this task, use the variable DEB_PYTHON_INSTALL_ARGS_ALL for passing the flag, e.g.:
-
As long as Fremantle contains Python 2.5, though, packages that worked on Diablo should also work on Fremantle without changes. This happens because PyMaemo packages named python-<something> can also be installed by using python2.5-<something>.
+
::DEB_PYTHON_INSTALL_ARGS_ALL = --no-compile -O0 --install-layout=deb
-
On the other hand, if we indeed upgrade to Python 2.6, this compatibility will not work anymore, and packages will need modifications so they can work on Fremantle.
+
* If your application uses any python2.5 package as one of its dependencies in any Depends field, you should drop the version number and add the version as a requirement - as a example, python2.5 can be changed to python (>= 2.5) without problems. If this is not possible/desired, just change the dependencies to python2.6.
-
 
+
-
One possibility we are evaluating is to provide updates to PyMaemo packages in previous Maemo releases (e.g. chinook and diablo) so they can also be installed by using the version agnostic python-<something> name (along the old python2.5-<something> names). This would allow most packages to be uploaded to all three releases (chinook, diablo and fremantle) without requiring specific changes only for Fremantle.
+
-
 
+
-
=== Porting tips ===
+
-
 
+
-
* 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 you use distutils for building your package, you must pass the --install-layout=deb flag for "setup.py install" command inside debian/rules in order to install the files to the proper locations. If you're using CDBS for this task, use the variable DEB_PYTHON_INSTALL_ARGS_ALL for passing the flag, e.g.:<pre>DEB_PYTHON_INSTALL_ARGS_ALL = --no-compile -O0 --install-layout=deb</pre>
+
-
* If your application uses any python2.5 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 nor desired, just change the dependencies to python2.6.
+
* Also, this would be a good time for your package to use dependencies that follow the new Debian Python Policy, if that's the case - the Policy states that Python packages must not have a fixed version number on its name (e.g. prefer python-xml instead of python2.6-xml).
* Also, this would be a good time for your package to use dependencies that follow the new Debian Python Policy, if that's the case - the Policy states that Python packages must not have a fixed version number on its name (e.g. prefer python-xml instead of python2.6-xml).
-
* One very particular case where changes are required is when some Python script uses identifies that became reserved keywords in Python 2.6. 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.
 
-
 
-
[[Category:Python]]
 

Learn more about Contributing to the wiki.


Please note that all contributions to maemo.org wiki may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see maemo.org wiki:Copyrights for details). Do not submit copyrighted work without permission!


Cancel | Editing help (opens in new window)

Templates used on this page: