1212from typing import NamedTuple
1313
1414import packaging .tags
15+ from packaging .specifiers import SpecifierSet
1516from packaging .tags import Tag
1617from packaging .utils import parse_wheel_filename
1718from packaging .version import Version
@@ -47,7 +48,7 @@ def _py_exe(major: int, minor: int) -> str:
4748
4849
4950def _pythons_to_check (
50- tags : frozenset [Tag ], package : Package | None = None
51+ tags : frozenset [Tag ], python_versions : SpecifierSet | None = None
5152) -> tuple [str , ...]:
5253 tag_compatible_pythons : set [str ] = set ()
5354 for tag in tags :
@@ -71,18 +72,18 @@ def _pythons_to_check(
7172 if not tag_compatible_pythons :
7273 raise AssertionError (f"no interpreters found for { tags } " )
7374
74- if not package :
75+ if not python_versions :
7576 return tuple (sorted (tag_compatible_pythons ))
7677
7778 package_compatible_pythons : set [str ] = set ()
7879 for python_exe in tag_compatible_pythons :
7980 py_version_str = python_exe .replace ("python" , "" )
80- if py_version_str in package . python_versions :
81+ if py_version_str in python_versions :
8182 package_compatible_pythons .add (python_exe )
8283
8384 if not package_compatible_pythons :
8485 raise AssertionError (
85- f"no interpreters found for { tags } after applying package constraints { package . python_versions } . "
86+ f"no interpreters found for { tags } after applying package constraints { python_versions } . "
8687 f"Wheel supports: { sorted (tag_compatible_pythons )} "
8788 )
8889
@@ -189,7 +190,7 @@ def main() -> int:
189190 name , version , _ , wheel_tags = parse_wheel_filename (filename )
190191 package = packages [(name , version )]
191192 info = validate_infos [(name , version )]
192- for python in _pythons_to_check (wheel_tags , package ):
193+ for python in _pythons_to_check (wheel_tags , package . python_versions ):
193194 _validate (
194195 python = python ,
195196 filename = os .path .join (args .dist , filename ),
0 commit comments