Skip to content

Commit 85ccf51

Browse files
committed
Better accomodate for case-insensitive file systems
1 parent 4e53eaf commit 85ccf51

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

src/pip/_internal/utils/entrypoints.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
f"pip{sys.version_info.major}.{sys.version_info.minor}",
1414
]
1515
if WINDOWS:
16-
_allowed_extensions = {"", ".exe", ".EXE"}
16+
_allowed_extensions = {"", ".exe"}
1717
_EXECUTABLE_NAMES = [
1818
"".join(parts)
1919
for parts in itertools.product(_EXECUTABLE_NAMES, _allowed_extensions)
@@ -50,10 +50,15 @@ def get_best_invocation_for_this_pip() -> str:
5050

5151
# Try to use pip[X[.Y]] names, if those executables for this environment are
5252
# the first on PATH with that name.
53-
exe_are_in_PATH = binary_prefix in os.environ.get("PATH", "").split(os.pathsep)
53+
path_parts = os.path.normcase(os.environ.get("PATH", "")).split(os.pathsep)
54+
exe_are_in_PATH = os.path.normcase(binary_prefix) in path_parts
5455
if exe_are_in_PATH:
5556
for exe_name in _EXECUTABLE_NAMES:
56-
if shutil.which(exe_name) == os.path.join(binary_prefix, exe_name):
57+
found_executable = shutil.which(exe_name)
58+
if found_executable and os.path.samefile(
59+
found_executable,
60+
os.path.join(binary_prefix, exe_name),
61+
):
5762
return exe_name
5863

5964
# Use the `-m` invocation, if there's no "nice" invocation.

0 commit comments

Comments
 (0)