Skip to content

Commit d9d7790

Browse files
authored
Merge pull request #9467 from uranusjr/avoid-exchanging-parsed-version
Use str to pass versions to avoid debundling issue
2 parents e7d6e54 + ab18181 commit d9d7790

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

news/9348.bugfix.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Avoid parsing version to make the version check more robust against lousily
2+
debundled downstream distributions.

src/pip/_internal/req/req_install.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -419,8 +419,16 @@ def check_if_exists(self, use_user_site):
419419
if not existing_dist:
420420
return
421421

422-
existing_version = existing_dist.parsed_version
423-
if not self.req.specifier.contains(existing_version, prereleases=True):
422+
# pkg_resouces may contain a different copy of packaging.version from
423+
# pip in if the downstream distributor does a poor job debundling pip.
424+
# We avoid existing_dist.parsed_version and let SpecifierSet.contains
425+
# parses the version instead.
426+
existing_version = existing_dist.version
427+
version_compatible = (
428+
existing_version is not None and
429+
self.req.specifier.contains(existing_version, prereleases=True)
430+
)
431+
if not version_compatible:
424432
self.satisfied_by = None
425433
if use_user_site:
426434
if dist_in_usersite(existing_dist):

0 commit comments

Comments
 (0)