Skip to content

[WIP] PEP 394: Allow not installing unversioned "python" command #893

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from

Conversation

encukou
Copy link
Member

@encukou encukou commented Feb 13, 2019

The intended future for the python command is:

python doesn't exist and one always has to specify python2 or python3.

( – Guido, #630 (comment) )

There are three conflicting ideas around the python command, longer-term:

  1. The python command should continue to refer to Python 2 (if Python 2 is available).
  2. python is a correct shebang for py2/py3 source-compatible scripts.
  3. Python 2 should not be available (by default / after 2020).

One of these has to give.
It seems that (2) is the easiest to shed, so this proposal does just that.

  • Make python3 the preferred shebang for py2/py3 compatible scripts, as that's the only shebang that'll work on py2-less systems. (An exception is made for scripts targetting the system Python on e.g. macOS/RHEL.)

  • Make the unversioned python command optional (along with idle, pydoc, and python-config).
    Distributions now do not need to install it by default, even if Python 2 is installed. (But they should make it installable explicitly, as long as they ship Python 2.)
    This should introduce more people to systems without the "legacy" python command, encourage the use of explicit python2/python3, and ease switching to systems that don't have Python 2 at all.

  • Clarify that distributions should not make unversioned python configurable. (That might work for carefully managed systems, but the ecosystem should converge on python3, not "your python needs to be set properly".)

  • Remove mentions of choosing to link python to python3 in the future, as we don't expect to start recommending that.

  • Use the term "unversioned" python when contrasting it with python3/python2.
    I found that this makes the message much clearer.

The intended future for the ``python`` command is:

> ``python`` doesn't exist and one always has to specify ``python2``
> or ``python3``.

( – Guido, python#630 (comment) )

There are three conflicting ideas around the ``python`` command,
longer-term:

1. The ``python`` command should continue to refer to Python 2 (if
   Python 2 is available).
2. ``python`` is a correct shebang for py2/py3 source-compatible scripts.
3. Python 2 should *not* be available (by default / after 2010).

One of these has to give.
It seems that (2) is the easiest to shed, so this proposal does just that.

* Make ``python3`` the preferred shebang for py2/py3 compatible
  scripts, as that's the only shebang that'll work on py2-less systems.
  (An exception is made for scripts targetting the *system* Python
  on e.g. macOS/RHEL.)
* Make the unversioned ``python`` command optional (along with
  ``idle``, ``pydoc``, and ``python-config``).
  Distributions now do not need to install it by default, even if
  Python 2 is installed. (But they should make it installable
  explicitly, as long as they ship Python 2.)
  This should introduce more people to systems without the
  "legacy" ``python`` command, encourage the use of explicit
  ``python2``/``python3``, and ease switching to systems that don't
  have Python 2 at all.
* Clarify that distributions *should not* make unversioned
  ``python`` configurable. (That might work for carefully managed
  systems, but the ecosystem should converge on ``python3``, not
  "your ``python`` needs to be set properly".)
* Remove mentions of choosing to link ``python`` to ``python3`` in the
  future, as we don't expect to start recommending that.

* Use the term **"unversioned"** ``python`` when contrasting it with
  ``python3``/``python2``.
  I found that this makes the message much clearer.
@encukou
Copy link
Member Author

encukou commented Feb 13, 2019

Note:

I'm responsible for how this is handled in RHEL 8 beta, where /usr/bin/python is configurable (though configuring it is discouraged).
I don't recommend that in the PEP – I don't think it needs to cover distros that need to lock in the behavior of /usr/bin/python for a decade.

@Rosuav
Copy link
Contributor

Rosuav commented Feb 13, 2019

It sounds to me like you're suggesting that py2/py3 compatible scripts be basically indistinguishable from Python 3 scripts, which in turn implies that a Python 3.x needs to be installed, even though the script could easily run on Py2. Is that your intention?

@encukou
Copy link
Member Author

encukou commented Feb 13, 2019

@Rosuav: Yes. In my opinion, that's the least bad option.
Note that Python 3 is available on the vast majority of systems. Notable exceptions I know of:

  • macOS-provided Python, which AFAIK doesn't even have python2, so it's basically a lost cause
  • RHEL 7 (we're working on that, but I'm not allowed to say much more)
  • Old OSes where people don't install new things lightly

@Rosuav
Copy link
Contributor

Rosuav commented Feb 13, 2019

Cool. I'm absolutely okay with it too, but then, I'm one of those early adopters who runs everything on alpha releases, so my opinion carries little weight :)

@vstinner
Copy link
Member

@FlyingWombat
Copy link

FlyingWombat commented Feb 15, 2019

So, I'm pretty new to Python, but:
Can I ask what the rationale is for removing python?
IMO using python3 makes Python 3.x seem like a fork of Python 2.x. But I thought the intent was the other way around: that Python 2.x would be the "fork", if it is to continue to exist. Isn't that whole idea of Python 2 End of Life?

I know a lot of distros kept python as python2, to preserve compatibility with legacy python programs. But IMO that's a backwards way of doing things.
Pretty much every other program I know of has foo execute the latest version, and then maybe older versions can be installed as fooX.Y. That makes more sense to me.

@ncoghlan
Copy link
Contributor

@encukou Should this be closed in favour of #989?

@FlyingWombat The PEP is slowly being moved in that direction, but back when the PEP was first written (2011, just after Python 3.2 had been released), distros doing that was a genuinely bad idea, so we wanted to actively discourage them from doing it. The situation has changed a lot in the past eight years though, so the guidance needs to change accordingly.

@encukou
Copy link
Member Author

encukou commented Apr 25, 2019

@encukou Should this be closed in favour of #989?

Ah, I knew I was forgetting something! Thanks for the reminder.

@encukou encukou closed this Apr 25, 2019
@encukou encukou deleted the pep-394-update branch April 25, 2019 14:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants