Changes/Python 3 as Default

From FedoraProject

Jump to: navigation, search

Contents

Python 3 as the Default Implementation

Summary

Up until now, Fedora has used Python 2 as the default Python implementation. This change proposes switching to Python 3. The details of the term "switching" are explained thoroughly in the Scope section.

Owner

Current status

Detailed Description

Python 3 is the next generation of Python programming language. It is currently mature and stable, since it has been under active development for five years - version 3.0 was released in December 2008, current latest stable version is 3.4.3 released in February 2015. The main reason to switch to Python 3 as the default implementation is that Python 2 is in maintenance mode, thus only bugfixes and security fixes are accepted upstream. Further reasons are mentioned in the Benefit to Fedora section. For this Change to be carried out successfully, it is necessary that the key packages in the Fedora software stack be ported to Python 3. These are parts of the minimal buildroot, the default package manager, programs present on the LiveCD etc. More information on the packages involved can be found in Dependencies. While porting of some packages is rather trivial, other packages need significant amount of work to get rid of the Python 2 dependence.

Benefit to Fedora

Python 2.7 (latest Python 2 release, which we also have in Fedora) is currently in maintenance mode only, which means upstream only accepts bugfixes and security fixes, but no new features are being implemented. Python 2.7 is the last minor release of Python 2, with upstream support until 2020. Python 3, on the other hand, is actively developed and new features are being added every release. Moreover, there is currently no end of support date for Python 3.

Fedora already has Python 3 stack that is parallel to Python 2 stack. There are several benefits of switching the "primary" Python stack:

  • Getting upstream support for default system version will not be limited by time.
  • Our system tools will be able to switch to Python 3, drop the burden of Python 2 support and use new features of Python 3.
  • As a distribution that stays close to upstream, Fedora should help Python community go forward by contributing patches and working closely with upstreams to get this accomplished. Thus this Change is meant to benefit not only Fedora, but also broader Python community.
  • Switching to Python 3 as a default will once again push Fedora to stay as close to upstream as possible, highlighting the "Features" and "First" (although, to be honest, Arch Linux was first in this...)

Scope

The main goal is switching to Python 3 as a default, in which state:

  • DNF is the default package manager instead of Yum, which only works with Python 2
  • Python 3 is the only Python implementation in the minimal buildroot (already done since F22)
  • Python 3 is the only Python implementation on the Workstation LiveDVD
  • Python 3 is the only Python implementation in minimal cloud image
  • Python 3 is the only Python implementation in Atomic host
  • It'd also be nice to have Python 3 as the only implementation on the Server LiveDVD, but it's not likely

(see Dependencies for the list of packages that need to be ported)

Warning (medium size).png
Warning
This section is still in progress and not the final version of the proposed guidelines changes. A summary of possibilities can be found here.

Changes in packaging:

  • Change definition of default python interpreter to python3.
  • Change unversioned python macros to python3 (Possibly do that change in upstream rpm)
  • Deletion of /usr/bin/python OR symlink to python3?
  • All applications that use only a single python version MUST use python3 (unless they have a good reason not to do so).
  • Python libraries that are named python-foo can be expected to be built with python2 *for now*. But they MUST have a python3- subackage and use the macro %python_provide python3-foo, which might provide some unversioned python module in the future. This macro will be defined when using BR python3-devel.
  • If you only build for python2 from a python-foo.src.rpm, you MUST ship it in a python2- subpackage and use the macro %python_provide python2-foo.


There are basically two types of packages that need to undergo the conversion:

  • "libraries" - Python extension modules and libraries that provide Python bindings - assuming that there is upstream support, these can receive python3- subpackage any time without any damage to Fedora; we can then just utilize this subpackage when switching to Python 3 (instead of using current python- subpackage).
  • "applications" - Packages that build with some sort of "embedded Python support", like gdb, or Rhythmbox with its plugins. In these cases, it makes no sense to do a python3- subpackage, since the whole package would need to be duplicated (e.g. python3-gdb). These packages should be built with Python 3 in Fedora 23 rawhide as soon as possible.

Work in Fedora 21 Timeframe

  • Proposal owners:
    • Discussing changes in Python packaging guidelines with Fedora community and FPC
    • Helping upstreams with porting to Python 3
    • Introducing python3- packages where appropriate, testing packages that only build with Python once (e.g. gdb, Rhythmbox)
  • Other developers:
    • Hopefully the same as proposal owners.
  • Release engineering:
    • Nothing.
  • Policies and guidelines:
    • None for F21

Work in Fedora 22 Timeframe

  • Proposal owners:
    • Discussing changes in Python packaging guidelines with Fedora community and FPC
    • Helping upstreams with porting to Python 3
    • Introducing python3- packages where appropriate, testing packages that only build with Python once (e.g. gdb, Rhythmbox)
  • Other developers:
    • Hopefully the same as proposal owners.
  • Release engineering:
    • Nothing.
  • Policies and guidelines:
    • None for F22

Work in Fedora 23 Timeframe

  • Proposal owners:
    • Continue the work from F21 and F22 timeframe
    • Modify comps accordingly
    • Apply the changes to Python packaging guidelines
  • Other developers:
    • Introduce python3- subpackages where appropriate, build against Python 3 if the package supports it
  • Release engineering:
    • Nothing
  • Policies and guidelines:
    • TODO: changes in packaging

Upgrade/compatibility impact

The Python 2 stack will stay in Fedora, it will just not be the default one. Depending on the modifications done to Python packaging guidelines, this probably means that Python 2 packages will stay the way they are and default tools will drag in python3- dependencies. Upstream recommends that /usr/bin/python point to Python 2 runtime for the time being, so if we go with that, there shouldn't be any serious compatibility impact:

  • Users will still be able to install Python 2 packages
  • Both Python 2 and 3 stacks will still live in parallel

Libraries that are built with Python only once (like gdb) may force users to rewrite their custom scripts and plugins (see e.g. https://bugzilla.redhat.com/show_bug.cgi?id=1014549#c3).

How To Test

  • No special hardware is needed.
  • Install Fedora 23 in mock/virtual machine and test if everything still works, most importantly system tools like DNF or Firewalld.
  • Test installing the system with Anaconda running on Python 3.

User Experience

Users shouldn't notice any changes, except that packages in minimal buildroot and on LiveCD will be python3-, not python-. Anaconda deps will be python3- as well. /usr/bin/python will still point to Python 2 and depending on result of discussions with FPC, "yum install python-foo" will still install Python 2 version of the package.

Dependencies

See https://fedoraproject.org/wiki/User:Churchyard/python3 (our tracking page with notes) or https://bugzilla.redhat.com/show_bug.cgi?id=1014209 (tracking bug).

Contingency Plan

  • Contingency mechanism: None needed. Packages that will be ready will be built with Python 3, the rest will be ported in next release.
  • Contingency deadline: Software string freeze
  • Blocks release? No

Documentation

http://docs.python.org/dev/howto/pyporting.html

http://docs.python.org/3/howto/cporting.html

https://wiki.gnome.org/PyGObject/IntrospectionPorting

Release Notes