1
1
Fork 0
mirror of https://github.com/pypa/pip synced 2023-12-13 21:30:23 +01:00

Use str to pass versions to avoid debundling issue

This commit is contained in:
Tzu-ping Chung 2021-01-18 05:54:04 +08:00
parent 3af9093a73
commit ab181811ae
2 changed files with 12 additions and 2 deletions

2
news/9348.bugfix.rst Normal file
View file

@ -0,0 +1,2 @@
Avoid parsing version to make the version check more robust against lousily
debundled downstream distributions.

View file

@ -432,8 +432,16 @@ class InstallRequirement:
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):