pythonfinder package¶
- class pythonfinder.Finder(**data)[source]¶
Bases:
FinderBaseModel- find_all_python_versions(major=None, minor=None, patch=None, pre=None, dev=None, arch=None, name=None)[source]¶
- find_python_version(major=None, minor=None, patch=None, pre=None, dev=None, arch=None, name=None, sort_by_path=False)[source]¶
Find the python version which corresponds most closely to the version requested.
- Parameters
major (str | int | None) – The major version to look for, or the full version, or the name of the target version.
minor (int | None) – The minor version. If provided, disables string-based lookups from the major version field.
patch (int | None) – The patch version.
pre (bool | None) – If provided, specifies whether to search pre-releases.
dev (bool | None) – If provided, whether to search dev-releases.
arch (str | None) – If provided, which architecture to search.
name (str | None) – Name of the target python, e.g.
anaconda3-5.3.0sort_by_path (bool) – Whether to sort by path – default sort is by version(default: False)
- Return type
PathEntry | None
- Returns
A new PathEntry pointer at a matching python version, if one can be located.
- global_search: bool¶
- ignore_unsupported: bool¶
- path_prepend: Optional[str]¶
- sort_by_path: bool¶
- system: bool¶
- system_path: Optional[SystemPath]¶
- exception pythonfinder.InvalidPythonVersion[source]¶
Bases:
ExceptionRaised when parsing an invalid python version
- class pythonfinder.SystemPath(*, global_search: bool = True, paths: Dict[str, Union[PythonFinder, PathEntry]] = None, executables_tracking: List[PathEntry] = None, python_executables_tracking: Dict[str, PathEntry] = None, path_order: List[str] = None, python_version_dict: Dict[Tuple, Any] = None, version_dict_tracking: Dict[Tuple, List[PathEntry]] = None, only_python: bool = False, pyenv_finder: Optional[PythonFinder] = None, asdf_finder: Optional[PythonFinder] = None, system: bool = False, ignore_unsupported: bool = False, finders_dict: Dict[str, PythonFinder] = None)[source]¶
Bases:
FinderBaseModel- class Config[source]¶
Bases:
object- allow_mutation = True¶
- arbitrary_types_allowed = True¶
- include_private_attributes = True¶
- keep_untouched = (<class 'cached_property.cached_property'>,)¶
- validate_assignment = True¶
- asdf_finder: Optional[PythonFinder]¶
- classmethod create(path=None, system=False, only_python=False, global_search=True, ignore_unsupported=True)[source]¶
Create a new
pythonfinder.models.SystemPathinstance.- Parameters
path (str | None) – Search path to prepend when searching, defaults to None
path – str, optional
system (bool) – Whether to use the running python by default instead of searching, defaults to False
only_python (bool) – Whether to search only for python executables, defaults to False
ignore_unsupported (bool) – Whether to ignore unsupported python versions, if False, an error is raised, defaults to True
- Return type
- Returns
A new
pythonfinder.models.SystemPathinstance.
- executables_tracking: List[PathEntry]¶
- find_all(executable)[source]¶
Search the path for an executable. Return all copies.
- Parameters
executable (str) – Name of the executable
- Return type
- Returns
List[PathEntry]
- find_all_python_versions(major=None, minor=None, patch=None, pre=None, dev=None, arch=None, name=None)[source]¶
- find_python_version(major=None, minor=None, patch=None, pre=None, dev=None, arch=None, name=None, sort_by_path=False)[source]¶
- Return type
- finders_dict: Dict[str, PythonFinder]¶
- global_search: bool¶
- ignore_unsupported: bool¶
- only_python: bool¶
- path_entries¶
- path_order: List[str]¶
- paths: Dict[str, Union[PythonFinder, PathEntry]]¶
- pyenv_finder: Optional[PythonFinder]¶
- python_executables¶
- python_executables_tracking: Dict[str, PathEntry]¶
- python_version_dict: Dict[Tuple, Any]¶
- system: bool¶
- version_dict¶
- version_dict_tracking: Dict[Tuple, List[PathEntry]]¶
Subpackages¶
- pythonfinder.models package
- Submodules
- pythonfinder.models.mixins module
PathEntryPathEntry.ConfigPathEntry.as_pythonPathEntry.childrenPathEntry.children_refPathEntry.create()PathEntry.find_all_python_versions()PathEntry.find_python_version()PathEntry.get_py_version()PathEntry.is_dirPathEntry.is_dir_refPathEntry.is_executablePathEntry.is_executable_refPathEntry.is_pythonPathEntry.is_python_refPathEntry.is_rootPathEntry.namePathEntry.next()PathEntry.only_pythonPathEntry.pathPathEntry.py_versionPathEntry.py_version_refPathEntry.pythonsPathEntry.pythons_refPathEntry.set_children()PathEntry.which()
- pythonfinder.models.path module
SystemPathSystemPath.ConfigSystemPath.asdf_finderSystemPath.check_for_asdf()SystemPath.check_for_pyenv()SystemPath.create()SystemPath.executablesSystemPath.executables_trackingSystemPath.find_all()SystemPath.find_all_python_versions()SystemPath.find_python_version()SystemPath.findersSystemPath.finders_dictSystemPath.get_path()SystemPath.get_pythons()SystemPath.global_searchSystemPath.ignore_unsupportedSystemPath.only_pythonSystemPath.path_entriesSystemPath.path_orderSystemPath.pathsSystemPath.pyenv_finderSystemPath.python_executablesSystemPath.python_executables_trackingSystemPath.python_version_dictSystemPath.set_defaults()SystemPath.systemSystemPath.version_dictSystemPath.version_dict_trackingSystemPath.which()
exists_and_is_accessible()
- pythonfinder.models.python module
PythonFinderPythonFinder.ConfigPythonFinder.create()PythonFinder.find_all_python_versions()PythonFinder.find_python_version()PythonFinder.get_bin_dir()PythonFinder.get_paths()PythonFinder.get_pythons()PythonFinder.get_version_order()PythonFinder.ignore_unsupportedPythonFinder.is_asdfPythonFinder.is_pyenvPythonFinder.pathsPythonFinder.pythonsPythonFinder.pythons_refPythonFinder.rootPythonFinder.rootsPythonFinder.sort_functionPythonFinder.version_from_bin_dir()PythonFinder.version_glob_pathPythonFinder.version_pathsPythonFinder.versionsPythonFinder.which()
PythonVersionPythonVersion.ConfigPythonVersion.architecturePythonVersion.as_dict()PythonVersion.as_major()PythonVersion.as_minor()PythonVersion.comes_fromPythonVersion.companyPythonVersion.create()PythonVersion.executablePythonVersion.from_path()PythonVersion.from_windows_launcher()PythonVersion.get_architecture()PythonVersion.is_debugPythonVersion.is_devreleasePythonVersion.is_postreleasePythonVersion.is_prereleasePythonVersion.majorPythonVersion.matches()PythonVersion.minorPythonVersion.namePythonVersion.parse()PythonVersion.parse_executable()PythonVersion.patchPythonVersion.update_metadata()PythonVersion.versionPythonVersion.version_sortPythonVersion.version_tuple
VersionMap
- pythonfinder.models.windows module
- pythonfinder.models.mixins module
- Submodules
Submodules¶
- pythonfinder.cli module
- pythonfinder.environment module
- pythonfinder.exceptions module
- pythonfinder.pythonfinder module
- pythonfinder.utils module
dedup()ensure_path()expand_paths()filter_pythons()get_python_version()guess_company()is_in_path()looks_like_python()normalize_path()parse_asdf_version_order()parse_pyenv_version_order()parse_python_version()path_is_executable()path_is_known_executable()path_is_python()path_is_pythoncore()split_version_and_name()unnest()