[issue40667] [Windows] Add global python and python3 commands

Eryk Sun report at bugs.python.org
Mon May 18 11:00:19 EDT 2020


Eryk Sun <eryksun at gmail.com> added the comment:

> these may overtake people's existing installs and replace them 
> with something more clever (this annoys people)

In particular, installing the launchers to %SystemRoot% means that in some contexts, such as the search path that CreateProcessW and SearchPathW use, the launcher commands will take precedence over %PATH%.

> shebang lines will start being noticed
> "python3.exe" could launch Python 2, but I'm not too concerned by this

The launcher can get the name of the current process to restrict its behavior. For "python3.exe", run as "py.exe -3", which is subject to PY_PYTHON3. For "python2.exe", run as "py.exe -2", which is subject to PY_PYTHON2. For "python.exe", run as "py.exe", which is subject to shebangs, VIRTUAL_ENV, and PY_PYTHON.

Since the loader doesn't resolve symbolic links, these extra names can actually just be symlinks if the filesystem supports them and the installer is allowed to create them. If installing the launchers to %SystemRoot%, the filesystem must be NTFS and we must have admin access, so symlinks should be supported.

> these add an extra process in the chain, which can break callers 
> who need the process ID/handle

The launcher could facilitate finding the image path when programs need to spawn the interpreter directly as a child process. Maybe when running as "python2.exe" and "python3.exe", the launcher's -0p option could print just the image path that it would execute instead of the list of installed versions.

----------
nosy: +eryksun

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue40667>
_______________________________________


More information about the Python-bugs-list mailing list