Skip to content

Commit 64dd93f

Browse files
committed
Change logic to use split
1 parent 8b6c950 commit 64dd93f

File tree

1 file changed

+6
-12
lines changed

1 file changed

+6
-12
lines changed

src/pip/_internal/index/package_finder.py

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -250,18 +250,12 @@ def evaluate_link(self, link: Link) -> tuple[LinkType, str]:
250250
if not supports_python:
251251
requires_python = link.requires_python
252252
if requires_python:
253-
try:
254-
rp_ver_spec_list = []
255-
for rp_spec in specifiers.SpecifierSet(requires_python):
256-
rp_version = rp_spec.version
257-
if rp_spec.operator == "==" and rp_version.endswith(".*"):
258-
rp_version = rp_version[:-2]
259-
rp_ver_spec_list.append((Version(rp_version), rp_spec))
260-
requires_python = ",".join(
261-
[str(s) for _, s in sorted(rp_ver_spec_list)]
262-
)
263-
except InvalidVersion:
264-
pass
253+
def get_version_sort_key(v: str) -> tuple[int, ...]:
254+
return tuple(int(s) for s in v.split(".") if s.isdigit())
255+
requires_python = ",".join(sorted(
256+
(str(s) for s in specifiers.SpecifierSet(requires_python)),
257+
key=get_version_sort_key,
258+
))
265259
reason = f"{version} Requires-Python {requires_python}"
266260
return (LinkType.requires_python_mismatch, reason)
267261

0 commit comments

Comments
 (0)