Skip to content

Commit

Permalink
message_about_scripts_not_on_PATH: use pathlib also for parent_dir an…
Browse files Browse the repository at this point in the history
…d script_name directly
  • Loading branch information
lorddavidiii committed Jan 11, 2023
1 parent a5a5e28 commit 52a6318
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/pip/_internal/operations/install/wheel.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,10 +136,10 @@ def message_about_scripts_not_on_PATH(scripts: Sequence[str]) -> Optional[str]:
return None

# Group scripts by the path they were installed in
grouped_by_dir: Dict[str, Set[str]] = collections.defaultdict(set)
grouped_by_dir: Dict[Path, Set[str]] = collections.defaultdict(set)
for destfile in scripts:
parent_dir = os.path.dirname(destfile)
script_name = os.path.basename(destfile)
parent_dir = Path(destfile).parent.resolve()
script_name = Path(destfile).name
grouped_by_dir[parent_dir].add(script_name)

# We don't want to warn for directories that are on PATH.
Expand All @@ -149,10 +149,10 @@ def message_about_scripts_not_on_PATH(scripts: Sequence[str]) -> Optional[str]:
# 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(Path(sys.executable).parent.resolve())
warn_for: Dict[str, Set[str]] = {
warn_for: Dict[Path, Set[str]] = {
parent_dir: scripts
for parent_dir, scripts in grouped_by_dir.items()
if Path(parent_dir).resolve() not in not_warn_dirs
if parent_dir not in not_warn_dirs
}
if not warn_for:
return None
Expand Down

0 comments on commit 52a6318

Please sign in to comment.