[Python-Dev] Python install layout and the PATH on win32 (Rationale part 2: Moving the python.exe)

Brian Curtin brian at python.org
Fri Mar 23 04:20:12 CET 2012


2012/3/22 VanL <van.lindberg at gmail.com>:
> Open Issues:
>
> """If we do put python.exe on PATH (whether it's in bin or not), we have
> to debate how to handle people having multiple versions of python on
> their machine. In a post-PEP 397 world, no Python is "the machine
> default" - .py files are associated with py.exe, not python.exe, so we
> have to consider the following 3 commands being run from a shell
> prompt:
>
>    1. myprog.py
>    2. py myprog.py
>    3. python myprog.py
>
> 1 and 2 will always do the same thing. However, 3 could easily do
> something completely different, if the Python in the #! line differs
> from the one found on PATH. To me, this implies that it's better for
> (3) to need explicit user action (setting PATH) if it's to do anything
> other than give an error. But maybe that's just me. I've been hit too
> often by confusion caused by *not* remembering this fact."""

I'm not sure how widely used #1 is. I can't remember coming across any
bug reports or posts around the web where the example command line
just uses the Python chosen by the file association. I would suspect
it's especially rare in the current time when many people are running
a lot of versions of Python. Right now I have 2.6, 2.7, 3.1, 3.2, and
3.3, all installed in some different order, and I couldn't tell you
which of those I installed the latest bugfix release for. That last
one wins the race when it comes to file associations, and I've never
paid attention to the installer option.

#3 *will* require explicit user action - the Path setting is off by
default. For as much as it's an advanced feature, it's really helpful
to beginners. If you just want to type in "python" and have it work,
the Path option is great.

That's not to say the launcher isn't *also* a good thing. If you're a
first timer and install Python 3.3 and want to run a tutorial - add
Python to the path, type "python", and you're on your way. If you're
an advanced user and you want to write and run code on Python 3.3, do
the same. If you're even more advanced and are doing multi-version
work, the launcher is a helpful alternative.

> One possible response here is that the moving of the python.exe binary and
> the setting of the PATH would be tied to an unchecked-by-default installer
> option, making an explicit user choice needed to invoke the new
> functionality.

I ended up typing out the above while missing this paragraph...but, bingo.

> Breakage of existing tools: Mark Hammond, Paul Moore, and Tim Golden have
> all expressed that they have existing tools that would break and would need
> to be adjusted to match the new location of the python.exe, because that
> location is assumed to be at the root of the python install.

Isn't the proposed "BinaryDir" registry key helpful here? It's not
like we're telling people to fend for themselves -- we'll tell you
where it's at.

> A related issue is that this portion of the proposal has met with some
> resistance, but not much support here on Python-dev. The reason for that is
> selection bias: Those who are on Python-dev are much more likely to have
> tools that do advanced things with Python, such as introspect on the
> location of the binary, and are also much more likely to be comfortable with
> things like editing the PATH on windows. In contrast, the people that have
> trouble with this issue are those that are newest to Python and programming
> generally - those for whom editing the PATH is a challenge and whom are
> likely to be confused by the distinction between python.exe and a python
> program - and why, even after they add python to the path, the python
> program is not directly executable.

I still don't really get how this portion of the proposal, the
python.exe move to bin, is holding people up. If you're using the
launcher, the change is invisible. If you're using a setup where bin
is on the Path, the change is invisible. File associations? Invisible.
If you're typing out the full path, you have to type "bin" in the
middle -- this kind of sucks but I think we'll live.

I get that tools could be affected. I had two IDE makers at PyCon
immediately throw up red flags to this change. I think one of them was
about to charge the stage during my talk. When it was mentioned that
we could point them to the proper location, they breathed a sigh of
relief and said "cool, do it". If a registry key pointing you to
python.exe (rather, the directory) right now in Python < 3.3 works,
why doesn't another one pointing you to python.exe in Python >= 3.3
work?


More information about the Python-Dev mailing list