From c5416c59975574c01b8c596fb6d09b54b9596be6 Mon Sep 17 00:00:00 2001 From: Steve Dower Date: Tue, 6 May 2025 14:09:45 +0100 Subject: [PATCH] gh-133512: Adds warnings to py.exe launcher about subcommands belonging to Python install manager --- ...25-05-06-14-09-19.gh-issue-133512.bh-D-g.rst | 2 ++ PC/launcher2.c | 17 ++++++++++++++++- 2 files changed, 18 insertions(+), 1 deletion(-) create mode 100644 Misc/NEWS.d/next/Windows/2025-05-06-14-09-19.gh-issue-133512.bh-D-g.rst diff --git a/Misc/NEWS.d/next/Windows/2025-05-06-14-09-19.gh-issue-133512.bh-D-g.rst b/Misc/NEWS.d/next/Windows/2025-05-06-14-09-19.gh-issue-133512.bh-D-g.rst new file mode 100644 index 00000000000000..7579910f988f75 --- /dev/null +++ b/Misc/NEWS.d/next/Windows/2025-05-06-14-09-19.gh-issue-133512.bh-D-g.rst @@ -0,0 +1,2 @@ +Add warnings to :ref:`launcher` about use of subcommands belonging to the +Python install manager. diff --git a/PC/launcher2.c b/PC/launcher2.c index 72121724726ccb..357ee53e55c22d 100644 --- a/PC/launcher2.c +++ b/PC/launcher2.c @@ -1058,7 +1058,7 @@ checkShebang(SearchInfo *search) debug(L"# Failed to open %s for shebang parsing (0x%08X)\n", scriptFile, GetLastError()); free(scriptFile); - return 0; + return RC_NO_SCRIPT; } DWORD bytesRead = 0; @@ -2665,6 +2665,21 @@ performSearch(SearchInfo *search, EnvironmentInfo **envs) case RC_NO_SHEBANG: case RC_RECURSIVE_SHEBANG: break; + case RC_NO_SCRIPT: + if (!_comparePath(search->scriptFile, search->scriptFileLength, L"install", -1) || + !_comparePath(search->scriptFile, search->scriptFileLength, L"uninstall", -1) || + !_comparePath(search->scriptFile, search->scriptFileLength, L"list", -1) || + !_comparePath(search->scriptFile, search->scriptFileLength, L"help", -1)) { + fprintf( + stderr, + "WARNING: The '%.*ls' command is unavailable because this is the legacy py.exe command.\n" + "If you have already installed the Python install manager, open Installed Apps and " + "remove 'Python Launcher' to enable the new py.exe command.\n", + search->scriptFileLength, + search->scriptFile + ); + } + break; default: return exitCode; }