This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Windows installer does not add py.exe launcher to "App Paths" key
Type: enhancement Stage:
Components: Installation, Windows Versions: Python 3.11
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: eryksun, oscarbenjamin, paul.moore, steve.dower, tim.golden, zach.ware
Priority: normal Keywords:

Created on 2015-10-09 15:06 by oscarbenjamin, last changed 2022-04-11 14:58 by admin.

Messages (4)
msg252618 - (view) Author: Oscar Benjamin (oscarbenjamin) * Date: 2015-10-09 15:06
From the mailing list:
https://mail.python.org/pipermail/python-list/2015-October/697744.html

'''
The new installer for 3.5 doesn't create an "App Paths" key for
"python.exe" like the old installer used to do (see the old
Tools/msi/msi.py). Without that, unless python.exe is in the search
PATH, "Win+R -> python" and running "start python" in the command
prompt won't work. You can of course add the key manually as the
default value for
"[HKLM|HKCU]\Software\Microsoft\Windows\CurrentVersion\App
Paths\python.exe". IMO, this makes it the 'system' Python.
'''

Is this an intentional change or an oversight?
msg404350 - (view) Author: Steve Dower (steve.dower) * (Python committer) Date: 2021-10-19 20:32
Somewhat deliberate. We moved to properly support side-by-side installs, which can't be done with this key - App Paths would end up out of sync with PATH... almost instantly, really. (However, the Windows Store package manages this correctly in line with its PATH management, so they won't get out of sync.)

However, the py.exe launcher could be added there instead, as it is managed separately from the Python install so there's only ever one. It also handles the file association and drop handler, so it would make sense to set it here too.

The registry key would have to be added to the launcher MSI, somewhere under Tools/msi. Probably also needs a keypath registry key under its own location to be able to manage this properly - there should be other examples available.
msg404379 - (view) Author: Eryk Sun (eryksun) * (Python triager) Date: 2021-10-19 23:30
> IMO, this makes it the 'system' Python.

"App Paths" entries can be used like versioned symlinks in POSIX. For example, an "App Paths" entry for "python3.exe" can refer to a particular installation's "python.exe". That said, "App Paths" is only used by the shell API, not CreateProcessW(). The potential for inconsistency and confusion is a significant downside. 

> the py.exe launcher could be added there instead

Python's installer puts the launcher in either the Windows directory or a directory that's in PATH, so there's really no need for an "App Paths" entry. 

> Windows Store package manages this correctly in line with its 
> PATH management

The store app adds a user "App Paths" entry for the versioned executable name, such as "python3.10.exe". Unfortunately, when searching PATH and "App Paths", the shell API only tries to append ".exe" if the name doesn't already have an extension. Thus running "python3.10" from the Win+R dialog fails, but running "python3.10.exe" succeeds. To work around this, one can add a second "App Paths" entry for the name without ".exe", e.g. "python3.10".

The store app doesn't add "App Paths" entries for "python.exe" and "python3.exe". It's probably for the best, particularly for "python.exe". Entries in "App Paths" take precedence over PATH in the Win+R dialog, but CMD's `start` and PowerShell's `start-process` always search PATH first.
msg404382 - (view) Author: Steve Dower (steve.dower) * (Python committer) Date: 2021-10-19 23:57
> The store app doesn't add "App Paths" entries for "python.exe" and "python3.exe".

You're right, it's not following the aliases, but the actual executable. For 3.7, we had them as "python.exe", but from 3.8 they became "python3.8.exe" with a "python.exe" alias (python3.exe was always an alias). And since the App Path entries refer directly to the executable under "Program Files", you can (still!) only actually run them if you've also got the alias enabled.

You can test this by opening "Manage App Execution Aliases", disabling "python3.10.exe", and then pressing Win+R and launching "python3.10.exe". Re-enable the alias and it will run.

I believe it should follow aliases, since that's the only way the current logic works. I've already reported the bug that you can't launch without the global alias being enabled, and was told that it's "by design" and "better for users". But I'll see if I can find the owner of the feature and encourage them to fix it again.

> Python's installer puts the launcher in either the Windows directory or a directory that's in PATH, so there's really no need for an "App Paths" entry.

I believe there are some scenarios that search App Paths for "registered apps", but we already handle Open With just fine and I can't think what else matters, so you're probably right.
History
Date User Action Args
2022-04-11 14:58:22adminsetgithub: 69542
2021-10-19 23:57:59steve.dowersetmessages: + msg404382
2021-10-19 23:30:53eryksunsetnosy: + eryksun
messages: + msg404379
2021-10-19 20:32:56steve.dowersettype: enhancement
title: Windows 3.5 installer does not add python to "App Paths" key -> Windows installer does not add py.exe launcher to "App Paths" key
components: + Windows

nosy: + paul.moore, tim.golden, zach.ware, steve.dower
versions: + Python 3.11, - Python 3.5
messages: + msg404350
2015-10-09 15:06:17oscarbenjamincreate