From Fedora Project Wiki
m (stdout typo to stderr)
m (Quick Opt-Out: In the best case, do both things)
Line 57: Line 57:
=== Quick Opt-Out ===
=== Quick Opt-Out ===


In case switching to <code>/usr/bin/python2</code> or <code>/usr/bin/python3</code> is non-trivial, you can do two things:
In case switching to <code>/usr/bin/python2</code> or <code>/usr/bin/python3</code> is non-trivial, you can do two things (preferably both):


* Set the environment variable <code>DISABLE_AMBIGUOUS_PYTHON_VERSION_WARNING=1</code> when calling <code>/usr/bin/python</code>
* Set the environment variable <code>DISABLE_AMBIGUOUS_PYTHON_VERSION_WARNING=1</code> when calling <code>/usr/bin/python</code>

Revision as of 14:53, 5 January 2018


Important.png
Almost-a-Change
This page not a Fedora Change only because it does not affect end users, so it doesn't need release notes and associated communication.

Summary

Deprecate, and later disable, running /usr/bin/python (as opposed to /usr/bin/python3 or /usr/bin/python2) during RPM build.

Changes will be driven by Python SIG, but a few packages may fail to build (with the failure message providing an easy workaround).

Owner

Detailed Description

Motivation

Currently in Fedora (package names, executable names, etc.), python means Python 2. We would like to change it to mean Python 3, but to do that, we need to free it of the current meaning. This means explicitly using either "python2" or "python3" throughout Fedora. This is a multi-release effort tracked in Python SIG's "Finalizing Fedora Switch to Python3" document. This page describes a very focused subset of it.

Renaming packages (and associated changes to, for example, Requires: directives) is relatively straightforward, but making all Fedora-provided code avoid /usr/bin/python (as opposed to /usr/bin/python2) is both harder to achieve and harder to keep track of.

We would like to start deprecating /usr/bin/python (as opposed to /usr/bin/python2) at RPM build time. RPM build is a controlled environment: changes to it will not be felt by end users, breakages are almost immediately visible, and output of Koji builds can be nicely tracked and analyzed.

Specification

Python 2, when called as python or /usr/bin/python at RPM build time (as identified by the RPM_BUILD_ROOT environment variable), will print a deprecation warning to stderr.

A new Taskotron check will be implemented to look for this warning and fail if it's found. We will look at the Taskotron results and work with packagers to switch to update the affected packages. (We'll look at the results to determine if we'll use automated pull requests, mass bug filing, or something else.)

The warning itself may cause some packages to fail to build, for example if a test relies on exact stderr contents. For these cases, it will be possible to turn the warning off using an environment variable, but we ask packagers that use of this workaround is tracked in Bugzilla. See #Quick Opt-Out below.

After all packages that BuildRequire python2 are re-built with this check passing, python will be switched to fail after printing the message.

The warning will not be effective if stderr output is hidden. So, after switching /usr/bin/python to fail, some packages may start failing to build. We will work with the packagers to fix these. (We'll look at results from the "warnings phase" to see how proactive we'll need to be here.)

The warning text will be:

DEPRECATION WARNING: python2 invoked with /usr/bin/python.
    Use /usr/bin/python3 or /usr/bin/python2
    /usr/bin/python will be removed or switched to Python 3 in the future.
    If you cannot make the switch now, please follow instructions at https://fedoraproject.org/wiki/XXX#Quick_Opt-Out

(Using the Wiki link allows us to easily revise the instructions.)

Quick Opt-Out

In case switching to /usr/bin/python2 or /usr/bin/python3 is non-trivial, you can do two things (preferably both):

  • Set the environment variable DISABLE_AMBIGUOUS_PYTHON_VERSION_WARNING=1 when calling /usr/bin/python
  • File a Bugzilla, and make it block our tracking bug (XXX - link)

All such bugs will need to be fixed before we make /usr/bin/python fail hard.

Benefit to Fedora

This change brings us one step closer to a seamless transition to Python 3.

Also, we hope to gain experience with changing packages to avoid /usr/bin/python, to prepare us for making user-visible changes later.


Scope

  • Proposal owners: Patch python2, write the Taskotron check, deal with warnings and failures.
  • Other developers: Switch to using /usr/bin/python3 or /usr/bin/python2 explicitly at RPM build time (with help from Proposal owners if needed).
  • Release engineering: N/A (Note: Depending on the timing, separate targeted rebuilds may be needed, but we can do these as Proven Packagers)
  • Policies and guidelines: N/A (XXX: really?)
  • Trademark approval: N/A (not needed for this Change)

Upgrade/compatibility impact

N/A (the effect is at RPM build time only)


How To Test

  • Build a package that invokes /usr/bin/python, python or %{__python} in %prep, %build, %install or %check.
  • Observe a warning in the build logs
  • If already enabled system-wide: observe that the build fails
  • Look at XXX to see a failed Taskotron check

User Experience

N/A – does not affect end users

Dependencies

May affect packages that use Python 2 to build (including in tests). Any breakage should be minimal, with an easy workaround if things go wrong.

Contingency Plan

  • Contingency mechanism: If something goes unexpectedly wrong, and the workaround above doesn't work, the patch to python2 will be reverted. Any packages already changed due to the warning will remain changed.
  • Contingency deadline: Beta Freeze (or any time this causes a FTBFS that can't be solved promptly)
  • Blocks release? No
  • Blocks product? None

Documentation

This page is the documentation.

Release Notes

N/A (Not an end-user visible change)