From Fedora Project Wiki

Revision as of 11:40, 27 June 2017 by Pviktori (talk | contribs) (How To Test: - grammar fix)

Finalizing Fedora's Switch to Python 3


Currently, in Fedora package names, executables etc., python without a version number generally means Python 2. Given that the upstream support for Python 2 will end soon, we want to prepare Fedora for a transition to Python 3 as a default. Before switching python to refer to Python 3, a lot of preparatory work needs to be done and this page explains our plan to achieve this.

Wait, wasn't Python 3 as Default already done in Fedora 23? Yes it was, but part of that change proposal was that /usr/bin/python and unversioned package names starting with python will still mean Python 2, in compliance with upstream PEP 394. This change is about what happens once PEP 394 is updated (and we will drive that update if needed):

  • /usr/bin/python will mean Python 3
  • dnf install python will mean Python 3
  • dnf install python-foo will mean Python 3 version of foo
  • pip, virtualenv, flask, pycodestyle, flake8, sphinx-build and others like so will all run the Python 3 version, the Python 2 version will need to be run using the -2 (or 2) suffix


Current status

  • Last updated: 2017-06-27

The current situation in Fedora ("correct" means "follows current packaging guidelines"):

  • Correct package supporting Python 2 and 3 builds these binary RPMs:
    • python2-foo (provides python-foo as a virtual provide via %python_provides)
    • python3-foo (uses %python_provides, which is currently no-op)
  • "Misnamed" package supporting py2/3 builds these binary RPMs:
    • python-foo (the py2 version; may provide python2-foo virtually, but usually doesn't)
    • python3-foo
  • Correct py2-only packages are named:
    • python2-foo (provides python-foo as a virtual provide via %python_provides)
  • Correct py3-only packages are named:
    • python3-foo (uses %python_provides, which is currently no-op)
  • "Misnamed" py2-only package might be named:
    • python-foo, or
    • pyfoo, or
    • foo-python, etc.
  • There are (close to) no "misnamed" py3-only packages

Detailed Description

The default version of Python in Fedora is currently Python 2. The python command invokes a Python 2 interpreter, and whenever one installs a python-foo package, they get a Python 2 version of this package. However, Python 2 is slowly approaching its end of existence and might no longer be supported upstream after 2020. Therefore we would like to start the transition to Python 3 as a default Python version. This requires a lot of preparatory work before we do the actual switch. We need to make sure that nothing uses python to imply Python 2 neither in binary RPM names nor in dependencies' names, but rather explicitly specifies a Python version by using either python2- or python3. The state we want to achieve in Fedora to be ready for the switch, is where python-foo package names are only virtually provided with %python_provide macro and mean a default Python version available.

Transition Steps

Phase 1: Eliminate the python- prefix from the Python 2 package names

  • Targeted release: Fedora 30
  • Description: Ensure that all python-foo names are virtual provides declarations, with the actual RPMs themselves being named python2-foo. python-foo names are also not to be used to declare the dependencies of a Python 2 package. This is a preparatory phase to clean up Fedora's Python packages and ensure consistency not only for new Python packages, but also for existing ones.
  • Steps:
    • Identify the packages with naming issues. Those include packages with misnamed binary RPMs and dependencies.
    • Inform the package maintainers about the issues. Gather feedback and encourage fixing the packages.
    • Start mass bug filing slowly: open e.g. 20 Bugzillas and learn from the reaction.

Phase 2: Switch python to refer to python3

  • Targeted release: Fedora 32
  • Description: Make Python 3 a default version of Python in Fedora. This would mean that installing a python-foo package will imply a Python 3 version on the package, and invoking python will run a Python 3 version of the interpreter. The steps needed to achive this will be done in combination with proposing changes to the upstream guidance in PEP 394.
  • Steps:
    • Switch %python_provides macro to provide python-foo from python3-foo instead of python2-foo
    • Switch /usr/bin/python to point to /usr/bin/python3

Phase 3: Orphan python2 package

  • Targeted release: Fedora 33
  • Description: Python maintainers stop maintaining python2 package in Fedora. It will probably be picked up by someone from Python SIG.

Benefit to Fedora

This change simplifies transition to Python 3, when the upstream support for Python 2 ends.


  • Proposal owners:

Feature owners have to communicate the idea to the packagers and provide all the detailed information. They may step in to fix the packages if absolutely needed.

  • Other developers:

Package maintainers affected by the naming policies will be asked to fix their packages via mailing lists and Bugzilla.

  • Policies and guidelines:
    • Using python2/python3 instead of python in binary RPM package name guidelines, fpc
    • Using python2/python3 instead of python in (Build)Requires guidelines, fpc

How To Test

We have implemented taskotron checks for Phase 1 changes. The checks are being run each time a Python package is build in Koji, and you may view the results in taskotron resultsdb or when you submit the update in Bodhi.


Only those Python 2 packages which use python- prefix in dependency declarations are expected to break. However, when the change is completed, no packages like this are expected to exist.


Discussion on Fedora devel mailing list

PEP 394