Skip to content

Commit

Permalink
Canonicalize req name while doing pre-install package search
Browse files Browse the repository at this point in the history
  • Loading branch information
deveshks committed Apr 15, 2020
1 parent e40d267 commit 94cdef2
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
1 change: 1 addition & 0 deletions news/5021.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Package name should be normalized before we use it to search if it's already installed or not
8 changes: 6 additions & 2 deletions src/pip/_internal/req/req_install.py
Original file line number Diff line number Diff line change
Expand Up @@ -420,12 +420,16 @@ def check_if_exists(self, use_user_site):
"""
if self.req is None:
return

# Canonicalize requirement name to use normalized
# names while searching for already installed packages
no_marker = Requirement(str(self.req))
no_marker.marker = None
no_marker.name = canonicalize_name(no_marker.name)
# get_distribution() will resolve the entire list of requirements
# anyway, and we've already determined that we need the requirement
# in question, so strip the marker so that we don't try to
# evaluate it.
no_marker = Requirement(str(self.req))
no_marker.marker = None
try:
self.satisfied_by = pkg_resources.get_distribution(str(no_marker))
except pkg_resources.DistributionNotFound:
Expand Down

0 comments on commit 94cdef2

Please sign in to comment.