File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 2121from datetime import datetime , timedelta
2222
2323import requests
24+ from packaging .specifiers import SpecifierSet
2425from packaging .version import Version
2526
2627GRACE_PERIOD_DAYS = 5
@@ -34,6 +35,8 @@ def _get_pypi_releases(package_name: str) -> list[Any]:
3435 except Exception :
3536 return []
3637
38+ current_python = f"{ sys .version_info .major } .{ sys .version_info .minor } .{ sys .version_info .micro } "
39+
3740 result = []
3841 for ver , files in data ["releases" ].items ():
3942 if not files or re .search (r"(a|b|rc|dev)\d*$" , ver , re .I ):
@@ -42,6 +45,15 @@ def _get_pypi_releases(package_name: str) -> list[Any]:
4245 Version (ver )
4346 except Exception :
4447 continue
48+ requires_python = next (
49+ (f ["requires_python" ] for f in files if f .get ("requires_python" )), None
50+ )
51+ if requires_python :
52+ try :
53+ if not SpecifierSet (requires_python ).contains (current_python ):
54+ continue
55+ except Exception :
56+ pass
4557 upload_time = files [- 1 ].get ("upload_time_iso_8601" , "" )
4658 match = re .search (r"([\d-]+)T" , upload_time )
4759 if not match :
You can’t perform that action at this time.
0 commit comments