@lru_cache(maxsize=<NUM_LIT>)<EOL><INDENT>def find_python_version(<EOL>self, major=None, minor=None, patch=None, pre=None, dev=None, arch=None, name=None<EOL>):<EOL><DEDENT>
from .models import PythonVersion<EOL>minor = int(minor) if minor is not None else minor<EOL>patch = int(patch) if patch is not None else patch<EOL>version_dict = {<EOL>"<STR_LIT>": minor,<EOL>"<STR_LIT>": patch,<EOL>}  <EOL>if (<EOL>isinstance(major, six.string_types)<EOL>and pre is None<EOL>and minor is None<EOL>and dev is None<EOL>and patch is None<EOL>):<EOL><INDENT>if arch is None and "<STR_LIT:->" in major and major[<NUM_LIT:0>].isdigit():<EOL><INDENT>orig_string = "<STR_LIT>".format(major)<EOL>major, _, arch = major.rpartition("<STR_LIT:->")<EOL>if arch.startswith("<STR_LIT:x>"):<EOL><INDENT>arch = arch.lstrip("<STR_LIT:x>")<EOL><DEDENT>if arch.lower().endswith("<STR_LIT>"):<EOL><INDENT>arch = arch.lower().replace("<STR_LIT>", "<STR_LIT>")<EOL><DEDENT>if not (arch.isdigit() and (int(arch) & int(arch) - <NUM_LIT:1>) == <NUM_LIT:0>):<EOL><INDENT>major = orig_string<EOL>arch = None<EOL><DEDENT>else:<EOL><INDENT>arch = "<STR_LIT>".format(arch)<EOL><DEDENT>try:<EOL><INDENT>version_dict = PythonVersion.parse(major)<EOL><DEDENT>except (ValueError, InvalidPythonVersion):<EOL><INDENT>if name is None:<EOL><INDENT>name = "<STR_LIT>".format(major)<EOL>major = None<EOL><DEDENT>version_dict = {}<EOL><DEDENT><DEDENT>elif major[<NUM_LIT:0>].isalpha():<EOL><INDENT>name = "<STR_LIT:%s>" % major<EOL>major = None<EOL><DEDENT>else:<EOL><INDENT>if "<STR_LIT:.>" in major and all(part.isdigit() for part in major.split("<STR_LIT:.>")[:<NUM_LIT:2>]):<EOL><INDENT>match = version_re.match(major)<EOL>version_dict = match.groupdict()<EOL>version_dict["<STR_LIT>"] = bool(<EOL>version_dict.get("<STR_LIT>", False)<EOL>)<EOL>version_dict["<STR_LIT>"] = bool(version_dict.get("<STR_LIT>", False))<EOL><DEDENT>else:<EOL><INDENT>version_dict = {<EOL>"<STR_LIT>": major,<EOL>"<STR_LIT>": minor,<EOL>"<STR_LIT>": patch,<EOL>"<STR_LIT>": pre,<EOL>"<STR_LIT>": dev,<EOL>"<STR_LIT>": arch,<EOL>}<EOL><DEDENT><DEDENT>if version_dict.get("<STR_LIT>") is not None:<EOL><INDENT>minor = int(version_dict["<STR_LIT>"])<EOL><DEDENT>if version_dict.get("<STR_LIT>") is not None:<EOL><INDENT>patch = int(version_dict["<STR_LIT>"])<EOL><DEDENT>if version_dict.get("<STR_LIT>") is not None:<EOL><INDENT>major = int(version_dict["<STR_LIT>"])<EOL><DEDENT>_pre = version_dict.get("<STR_LIT>", pre)<EOL>pre = bool(_pre) if _pre is not None else pre<EOL>_dev = version_dict.get("<STR_LIT>", dev)<EOL>dev = bool(_dev) if _dev is not None else dev<EOL>arch = (<EOL>version_dict.get("<STR_LIT>", None) if arch is None else arch<EOL>)  <EOL><DEDENT>if os.name == "<STR_LIT>" and self.windows_finder is not None:<EOL><INDENT>match = self.windows_finder.find_python_version(<EOL>major=major,<EOL>minor=minor,<EOL>patch=patch,<EOL>pre=pre,<EOL>dev=dev,<EOL>arch=arch,<EOL>name=name,<EOL>)<EOL>if match:<EOL><INDENT>return match<EOL><DEDENT><DEDENT>return self.system_path.find_python_version(<EOL>major=major, minor=minor, patch=patch, pre=pre, dev=dev, arch=arch, name=name<EOL>)<EOL>
Find the python version which corresponds most closely to the version requested.

:param Union[str, int] major: The major version to look for, or the full version, or the name of the target version.
:param Optional[int] minor: The minor version. If provided, disables string-based lookups from the major version field.
:param Optional[int] patch: The patch version.
:param Optional[bool] pre: If provided, specifies whether to search pre-releases.
:param Optional[bool] dev: If provided, whether to search dev-releases.
:param Optional[str] arch: If provided, which architecture to search.
:param Optional[str] name: *Name* of the target python, e.g. ``anaconda3-5.3.0``
:return: A new *PathEntry* pointer at a matching python version, if one can be located.
:rtype: :class:`pythonfinder.models.path.PathEntry`