mirror of
https://github.com/pypa/pip
synced 2023-12-13 21:30:23 +01:00
Norm path before compare (#11719)
This commit is contained in:
parent
78ab4cf071
commit
d89475934c
1
news/11719.bugfix.rst
Normal file
1
news/11719.bugfix.rst
Normal file
|
@ -0,0 +1 @@
|
|||
Normalize paths before checking if installed scripts are on PATH.
|
|
@ -143,16 +143,18 @@ def message_about_scripts_not_on_PATH(scripts: Sequence[str]) -> Optional[str]:
|
|||
|
||||
# We don't want to warn for directories that are on PATH.
|
||||
not_warn_dirs = [
|
||||
os.path.normcase(i).rstrip(os.sep)
|
||||
os.path.normcase(os.path.normpath(i)).rstrip(os.sep)
|
||||
for i in os.environ.get("PATH", "").split(os.pathsep)
|
||||
]
|
||||
# If an executable sits with sys.executable, we don't warn for it.
|
||||
# This covers the case of venv invocations without activating the venv.
|
||||
not_warn_dirs.append(os.path.normcase(os.path.dirname(sys.executable)))
|
||||
not_warn_dirs.append(
|
||||
os.path.normcase(os.path.normpath(os.path.dirname(sys.executable)))
|
||||
)
|
||||
warn_for: Dict[str, Set[str]] = {
|
||||
parent_dir: scripts
|
||||
for parent_dir, scripts in grouped_by_dir.items()
|
||||
if os.path.normcase(parent_dir) not in not_warn_dirs
|
||||
if os.path.normcase(os.path.normpath(parent_dir)) not in not_warn_dirs
|
||||
}
|
||||
if not warn_for:
|
||||
return None
|
||||
|
|
|
@ -588,6 +588,12 @@ class TestMessageAboutScriptsNotOnPATH:
|
|||
)
|
||||
assert retval is None
|
||||
|
||||
def test_PATH_check_path_normalization(self) -> None:
|
||||
retval = self._template(
|
||||
paths=["/a/./b/../b//c/", "/d/e/bin"], scripts=["/a/b/c/foo"]
|
||||
)
|
||||
assert retval is None
|
||||
|
||||
def test_single_script__single_dir_on_PATH(self) -> None:
|
||||
retval = self._template(paths=["/a/b", "/c/d/bin"], scripts=["/a/b/foo"])
|
||||
assert retval is None
|
||||
|
|
Loading…
Reference in a new issue