[Python-Dev] Update PEP 394: Distributions can choose what does python command mean (original) (raw)

Guido van Rossum guido at python.org
Fri Apr 12 11:13:42 EDT 2019


I think this is reasonable. Thanks for making the rationale clear!

On Fri, Apr 12, 2019 at 8:02 AM Petr Viktorin <encukou at gmail.com> wrote:

On 4/12/19 4:53 PM, Miro Hrončok wrote: > Hello. > > Based on discussions in [1], Petr Viktorin and me have drafted a new > update [2] to the PEP 394 (The "python" Command on Unix-Like Systems). > > The update gives distributors the opportunity to decide where does the > "python" command lead to, whether it is present etc. > > Please, see the PR [2] for the suggested changes. > > [1]: https://mail.python.org/pipermail/python-dev/2019-February/156272.html > [2]: https://github.com/python/peps/pull/989

The text is available at https://github.com/hroncok/peps/blob/pep394-2019/pep-0394.txt As a summary, I'll paste the rationale sections here: History of this PEP =================== In 2011, the majority of distributions aliased the python command to Python 2, but some started switching it to Python 3 ([5]). As some of the former distributions did not provide a python2 command by default, there was previously no way for Python 2 code (or any code that invokes the Python 2 interpreter directly rather than via sys.executable) to reliably run on all Unix-like systems without modification, as the python command would invoke the wrong interpreter version on some systems, and the python2 command would fail completely on others. This PEP originally provided a very simple mechanism to restore cross-platform support, with minimal additional work required on the part of distribution maintainers. Simplified, the recommendation was: 1. The python command was preferred for code compatible with both Python 2 and 3 (since it was available on all systems, even those that already aliased it to Python 3). 2. The python command should always invoke Python 2 (to prevent hard-to-diagnose errors when Python 2 code is run on Python 3). 3. The python2 and python3 commands should be available to specify the version explicitly. However, these recommendations implicitly assumed that Python 2 would always be available. As Python 2 is nearing its end of life in 2020 (PEP 373, PEP 404), distributions are making Python 2 optional or removing entirely. This means either removing the python command or switching it to invoke Python 3, invalidating respectively the first or second recommendation. Also, some distributors decided that their users are better served by ignoring the PEP's recommendations, making the PEP's supposedly cross-platform recommendations on python and python2 in shebangs increasingly unreliable.

Current Rationale ================= As of 2019, nearly all new systems include Python 3 and the python3 command. This makes the python3 command the best general choice for code that can run on either Python 3.x or 2.x, even though it is not available everywhere. The recommendation is skewed toward current and future systems, leaving behind “old systems” (like RHEL 6 or default Python installed on macOS). On these systems, Python software is rarely updated and any recommendations this PEP makes would likely be ignored. Also, since distributors often ignored recommendations the PEP gave regarding the python command (for what they saw as legitimate special needs), this PEP now gives them broad control over the command. Correspondingly, users are advised to not use the python command in cross-platform code. Instead, this PEP specifies the expected behavior of the python3 and python2 commands, which is not controversial.


Python-Dev mailing list Python-Dev at python.org https://mail.python.org/mailman/listinfo/python-dev Unsubscribe: https://mail.python.org/mailman/options/python-dev/guido%40python.org

-- --Guido van Rossum (python.org/~guido) *Pronouns: he/him/his **(why is my pronoun here?)* <http://feministing.com/2015/02/03/how-using-they-as-a-singular-pronoun-can-change-the-world/> -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://mail.python.org/pipermail/python-dev/attachments/20190412/eba9f542/attachment.html>



More information about the Python-Dev mailing list