Skip to content

Commit d894759

Browse files
authored
Norm path before compare (#11719)
1 parent 78ab4cf commit d894759

File tree

3 files changed

+12
-3
lines changed

3 files changed

+12
-3
lines changed

news/11719.bugfix.rst

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Normalize paths before checking if installed scripts are on PATH.

src/pip/_internal/operations/install/wheel.py

+5-3
Original file line numberDiff line numberDiff line change
@@ -143,16 +143,18 @@ def message_about_scripts_not_on_PATH(scripts: Sequence[str]) -> Optional[str]:
143143

144144
# We don't want to warn for directories that are on PATH.
145145
not_warn_dirs = [
146-
os.path.normcase(i).rstrip(os.sep)
146+
os.path.normcase(os.path.normpath(i)).rstrip(os.sep)
147147
for i in os.environ.get("PATH", "").split(os.pathsep)
148148
]
149149
# If an executable sits with sys.executable, we don't warn for it.
150150
# This covers the case of venv invocations without activating the venv.
151-
not_warn_dirs.append(os.path.normcase(os.path.dirname(sys.executable)))
151+
not_warn_dirs.append(
152+
os.path.normcase(os.path.normpath(os.path.dirname(sys.executable)))
153+
)
152154
warn_for: Dict[str, Set[str]] = {
153155
parent_dir: scripts
154156
for parent_dir, scripts in grouped_by_dir.items()
155-
if os.path.normcase(parent_dir) not in not_warn_dirs
157+
if os.path.normcase(os.path.normpath(parent_dir)) not in not_warn_dirs
156158
}
157159
if not warn_for:
158160
return None

tests/unit/test_wheel.py

+6
Original file line numberDiff line numberDiff line change
@@ -588,6 +588,12 @@ def test_multi_script__single_dir_on_PATH(self) -> None:
588588
)
589589
assert retval is None
590590

591+
def test_PATH_check_path_normalization(self) -> None:
592+
retval = self._template(
593+
paths=["/a/./b/../b//c/", "/d/e/bin"], scripts=["/a/b/c/foo"]
594+
)
595+
assert retval is None
596+
591597
def test_single_script__single_dir_on_PATH(self) -> None:
592598
retval = self._template(paths=["/a/b", "/c/d/bin"], scripts=["/a/b/foo"])
593599
assert retval is None

0 commit comments

Comments
 (0)