Skip to content

Commit 2a061c2

Browse files
committed
Restrict the Windows name check to only "pip[major[.minor]].exe" names
1 parent 299d5be commit 2a061c2

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

src/pip/_internal/utils/misc.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -878,12 +878,19 @@ def protect_pip_from_modification_on_windows(modifying_pip):
878878
On Windows, any operation modifying pip should be run as:
879879
python -m pip ...
880880
"""
881+
pip_names = [
882+
"pip.exe",
883+
"pip{}.exe".format(sys.version_info[0]),
884+
"pip{}.{}.exe".format(*sys.version_info[:2])
885+
]
886+
881887
# See https://github.com/pypa/pip/issues/1299 for more discussion
882888
should_show_use_python_msg = (
883889
modifying_pip and
884890
WINDOWS and
885-
os.path.basename(sys.argv[0]).startswith("pip")
891+
os.path.basename(sys.argv[0]) in pip_names
886892
)
893+
887894
if should_show_use_python_msg:
888895
new_command = [
889896
sys.executable, "-m", "pip"

0 commit comments

Comments
 (0)