[Python-Dev] [PEPs] Support the /usr/bin/python2 symlink upstream

Kerrick Staley mail at kerrickstaley.com
Sun Jul 10 02:45:04 CEST 2011


Sorry that I dropped the ball on this. I'd still like to see this get
implemented, but I got distracted with school and forgot about it.
Updates I have made to the PEP will be sent as a patch immediately
after this email.

Here's a summary of what was happenening when we left off:
* The draft SVN version from March 4 was pretty much complete.

* Some were concerned about addressing Windows, but it was generally
agreed to leave the Windows issue to another PEP. PEP 397 was started
on March 15 to address the Windows side of the issue. PEP 397
recommends that the Windows Python launcher read the shebang and use
it to determine which Python version to use; this allows one syntax
for both operating systems that is compatible with the current PEP 394
recommendation.

* There were concerns from Ned Deily about the naming of other
binaries such as idle, pydoc, and python-config; these need to be
created as idle2, pydoc2, and python2-config, with links created at
the locations of the original binaries.

* There were concerns from Glenn Linderman that the shebang line
doesn't encode enough information to flexibly handle Windows launching
(or even launching in general).

====
Here are my thoughts:
* For Ned's comments, I agree. Although the issue isn't as large with
these programs, there's no reason we can't handle them in the same
way. I updated the PEP.

* For Glenn's comments, I think the method you propose adds too much
complexity. Regardless, if the #@ syntax is implemented, it can be
described in PEP 397; it won't have an impact on the contents of this
PEP. I think, though, that having multiple syntaxes may cause many
scripts to be incompatible with multiple platforms when they don't
have to be, since Unix coders will rarely add a #@ line, and Windows
coders will likely forget the #! line.

Also, #@ really ignores the purpose of a shebang: shebangs simply
indicate an interpreter that works with the script; the shebang allows
users to run arbitrary scripts without worrying about which
interpreter they should specify. There's no reason that a script
should use one interpreter on Unix, but be incompatible with that
interpreter on Windows yet compatible with another. The name of the
Unix binary is enough to determine the implementation and version of
the interpreter to be used on Unix, and a Windows launcher should
always invoke the same implementation/version on Windows (and this
won't require hard-coding anything into the launcher if done right).
If you want the script to run with a specific interpreter and version,
possibly contingent on which operating system you're running the
script under, then you can just invoke the interpreter by name with
the script as an argument (e.g. python3 myprogram.py).

TL;DR: shebangs encode a default implementation/version, and if you
need something special, you can just manually run python3 myprogram.py
or use a .bat file.

====
Also, I updated the PEP with the clarification that commands like
python3 should be hard links (because they'll be invoked from code and
are more efficient; also, hard links are just as flexible as symlinks
here), while commands like python should be soft links (because this
makes it clear to sysadmins that they can be "switched", and it's
needed for flexibility if python3 changes). This really doesn't
matter, but can we keep it this way unless there are serious
objections?

Regards,
Kerrick Staley


More information about the Python-Dev mailing list