Wednesday, November 23, 2011

An update on Ubuntu's Python plans

Earlier this month, I attended UDS-P (the Ubuntu Developers Summit for 12.04 Precise Pangolin).  12.04 is an LTS release, or Long Term Support, meaning it will be officially supported on both the desktop and server for five years.

During the summit we reiterated our plans for Python on Ubuntu, both for 12.04 LTS, and our vision of Python two years from now for the next LTS, 14.04.  I'm here to provide an update from my last report, which was written after UDS-O for 11.10.

As per those previous plans, we've removed Python 2.6 from Ubuntu 12.04.  Now you have only Python 2.7 and 3.2.  Dropping Python 2.6 may cause some inconvenience for data centers which like to upgrade only between LTS's but don't want to have to upgrade both their operation system and their Python version.  Canonical services such as Launchpad and Landscape fall into this camp.  The biggest problem is that Python 2.7 is not available for the last LTS, i.e. 10.04.  To mitigate this, we decided to create a PPA containing Python 2.7 and a bunch of packages that services such as Launchpad will need to do their porting.  This now exists, although it hasn't yet been tested with any development branches of Launchpad or Landscape as far as I'm aware.  If you have your own data center porting task ahead of you, you can also use this PPA, and if there are additional packages you need for 10.04, you can create your own PPA which depends on ours, and build those extra packages there.

But that's all boring stuff.  Let's have some fun!

The other decision we made concerns Python 3.  I strongly feel that the Python community is very close to the tipping point in Python 3 adoption.  Yes, there's still tons of code that needs porting, but we're seeing more and more activity every day.  Even large frameworks such as Twisted are working on Python 3 branches.  I wrote PEP 404 that (somewhat tongue in check) expresses official Python pronouncement on the migration path from Python 2.7 to Python 3.  There will not be a Python 2.8, so the time to begin porting your code is now.

And it's really not that difficult.  There are several great guides available to help you with porting your pure Python packages to Python 3, available on both python.org and python3porting.com.  There are packages such as six available to ease the trickier bits of porting, and I have another blog post coming that describes my experiences in porting dbus-python. This latter task is made more complex by being a fairly involved C extension module.  Again, both python.org and python3porting.com have useful guides for porting extension modules, although they have missed a few things.  I wrote a mailing list article on some of the things that I had to do, but the blog post will include more detail.

Other distros such as Fedora are also starting to work on porting essential packages to Python 3, and here's where free software and open source rules.  Our distros can work together to help nudge the Python community over that tipping point.  Fedora is working from a bottom-up approach, where they are porting packages as needed by request, and we in Ubuntu are working top-down, by identifying several desktop applications that we'll port, along with their dependency stack.  We'll both be pushing our changes to the upstream projects so every Python developer can benefit, no matter what platform they are on.

My long term vision is that Ubuntu 14.04 won't even have Python 2 on the CD images (if we even have CD images in two years), and we'll also move Python 2.7 off to universe.  It will never completely go away, but the operating system and all the applications you get in a default install will run on Python 3.  I'm much more sanguine about this goal now that I was even six months ago, but that's not to say it still won't be a lot of work.

The time is now to move to Python 3, if for no other reason than to fix all those pesky UnicodeErrors.  I think there's a lot more of value in Python 3 too of course, and Python 3.3 will be even more awesome.  I expect Python 3.3 or 3.4 to be in Ubuntu 14.04.

The place to be for all Python 3 porting efforts is the python-porting mailing list.

UPDATE: Fixed Python 3.3/3.4 plans to correctly read for Ubuntu 14.04 (thanks Nick!)