Skip to content

Commit

Permalink
Merge pull request #9467 from uranusjr/avoid-exchanging-parsed-version
Browse files Browse the repository at this point in the history
Use str to pass versions to avoid debundling issue
  • Loading branch information
uranusjr authored Mar 3, 2021
2 parents e7d6e54 + ab18181 commit d9d7790
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
2 changes: 2 additions & 0 deletions news/9348.bugfix.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Avoid parsing version to make the version check more robust against lousily
debundled downstream distributions.
12 changes: 10 additions & 2 deletions src/pip/_internal/req/req_install.py
Original file line number Diff line number Diff line change
Expand Up @@ -419,8 +419,16 @@ def check_if_exists(self, use_user_site):
if not existing_dist:
return

existing_version = existing_dist.parsed_version
if not self.req.specifier.contains(existing_version, prereleases=True):
# pkg_resouces may contain a different copy of packaging.version from
# pip in if the downstream distributor does a poor job debundling pip.
# We avoid existing_dist.parsed_version and let SpecifierSet.contains
# parses the version instead.
existing_version = existing_dist.version
version_compatible = (
existing_version is not None and
self.req.specifier.contains(existing_version, prereleases=True)
)
if not version_compatible:
self.satisfied_by = None
if use_user_site:
if dist_in_usersite(existing_dist):
Expand Down

0 comments on commit d9d7790

Please sign in to comment.