4from typing
import NewType, Optional, Tuple, cast
14def check_requires_python(
15 requires_python: Optional[str], version_info: Tuple[int, ...]
18 Check if the given Python version matches a "Requires-Python" specifier.
20 :param version_info: A 3-tuple of ints representing a Python
21 major-minor-micro version to check (e.g. `sys.version_info[:3]`).
23 :return: `True` if the given Python version satisfies the requirement.
24 Otherwise, return `False`.
26 :raises InvalidSpecifier: If `requires_python` has an invalid format.
28 if requires_python
is None:
33 python_version =
version.parse(
".".join(map(str, version_info)))
34 return python_version
in requires_python_specifier
37@functools.lru_cache(maxsize=512)