[Python-Dev] PEP 394 - Clarification of what "python" command should invoke

Steven D'Aprano steve at pearwood.info
Fri Sep 19 11:31:17 CEST 2014

On Fri, Sep 19, 2014 at 04:44:26AM -0400, Donald Stufft wrote:
> > On Sep 19, 2014, at 3:31 AM, Bohuslav Kabrda <bkabrda at redhat.com> wrote:
> > 
> > Hi, as Fedora is getting closer to having python3 as a default, I'm 
> > being more and more asked by Fedora users/contributors what'll 
> > "/usr/bin/python" invoke when we achieve this (Fedora 22 hopefully). 
> > So I was rereading PEP 394 and I think I need a small clarification 
> > regarding two points in the PEP: - "for the time being, all 
> > distributions should ensure that python refers to the same target as 
> > python2." - "Similarly, the more general python command should be 
> > installed whenever any version of Python is installed and should 
> > invoke the same version of Python as either python2 or python3."
> > 
> > The important word in the second point is, I think, *whenever*. 
> > Trying to apply these two points to Fedora 22 situation, I can think 
> > of several approaches:

> > - /usr/bin/python will always point to python3 (seems to go against 
> > the first mentioned PEP recommendation)

Definitely not that.

Arch Linux pointed /usr/bin/python at Python 3 some years ago, and I 
understand that this has caused no end of trouble for the folks on 
#python. I haven't seen any sign of this being an issue on the tutor@ or 
python-list at python.org mailing lists, but the demographics are quite 
different so that's not surprising.

> > - /usr/bin/python will always point to python2 (seems to go against 
> > the second mentioned PEP recommendation, there is no /usr/bin/python 
> > if python2 is not installed)

My understanding is that this is the intention of the PEP, at least 
until such time as Python 2 is end-of-lifed.

My interpretion would be that the second recommendation in the PEP is 
just confused :-) Perhaps the PEP author could clarify what the 
intention is.

> > - /usr/bin/python will point to python3 if python2 is not installed, 
> > else it will point to python2 (inconsistent; also the user doesn't 
> > know he's running and what libraries he'll be able to import - the 
> > system can have different sets of python2-* and python3-* extension 
> > modules installed)

Likely to cause all sorts of problems, and I understood that this was 
not the intention. Perhaps it was added *only* as a "grand-father 
clause" so that people don't yell at Arch Linux "See, the PEP says 
you're doing it wrong!".

> > - there will be no /usr/bin/python (goes against PEP and seems just wrong)

Seems like the least-worst to me.

If you think of "python == Python 2.x" (at least for the next few 
years), then if Python 2.x isn't installed, there should be no 
/usr/bin/python either.

> I don’t know for a fact, but I assume that as long as Python 2.x is 
> installed by default than ``python`` should point to ``python2``. If 
> Python 3.x is the default version and Python 2.x is the “optional” 
> version than I think personally it makes sense to switch eventually. 
> Maybe not immediately to give people time to update though?

Agreed. Once Python 2 is finally end-of-lifed in 2023 or thereabouts, 
then we can reconsider pointing /usr/bin/python at Python 3 (or 4, 
whatever is current by then). If Arch Linux jumped the gun by a decade 
or so, that's their problem :-)


More information about the Python-Dev mailing list