[Python-Dev] Clarification of PEP 394 for scripts that run under Python 2 and 3 (original) (raw)

Damien George damien.p.george at gmail.com
Fri Nov 13 17:32:07 EST 2015


Hi python-dev,

We have a Python script that runs correctly under Python 2.6, 2.7 and 3.3+. It is executed on a *nix system using the "python" executable (ie not python2 or python3 specifically). This works just fine for systems that have Python 2 installed, or 2 and 3, or just 3 and symlink "python" to "python3" (eg Arch Linux).

But it fails for systems that have only Python 3 and do not create a "python" symlink, ie only "python3" exists as an executable.

We thought that PEP 394 would come to the rescue here but it seems to be unclear on this point. In particular it says:

Well, that's pretty clear to me: one can expect the "python" executable to be available to run scripts that are compatible with versions 2.x and 3.x.

The confusion comes because there are systems that install Python 3 without creating a "python" symlink (hence breaking the above). And Guido said that "'python' should always be the same as 'python2'" (see https://mail.python.org/pipermail/python-dev/2014-September/136389.html). Further, Nick Coghlan seemed to agree that "when there's only python3 installed, there should be no /usr/bin/python" (see https://mail.python.org/pipermail/python-dev/2014-September/136527.html).

My questions are:

  1. What is the true intent of PEP 394 when only Python 3 is installed? Is "python" available or not to run scripts compatible with 2.x and 3.x?

  2. Is it possible to write a shebang line that supports all variations of Python installations on *nix machines?

  3. If the answer to 2 is no, then what is the recommended way to support all Python installations with one standalone script?

Thanks!

Regards, Damien. -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://mail.python.org/pipermail/python-dev/attachments/20151113/86278b4e/attachment.html>



More information about the Python-Dev mailing list