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.0
sort_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:
Exception
Raised 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.SystemPath
instance.- 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.SystemPath
instance.
- 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
PathEntry
PathEntry.Config
PathEntry.as_python
PathEntry.children
PathEntry.children_ref
PathEntry.create()
PathEntry.find_all_python_versions()
PathEntry.find_python_version()
PathEntry.get_py_version()
PathEntry.is_dir
PathEntry.is_dir_ref
PathEntry.is_executable
PathEntry.is_executable_ref
PathEntry.is_python
PathEntry.is_python_ref
PathEntry.is_root
PathEntry.name
PathEntry.next()
PathEntry.only_python
PathEntry.path
PathEntry.py_version
PathEntry.py_version_ref
PathEntry.pythons
PathEntry.pythons_ref
PathEntry.set_children()
PathEntry.which()
- pythonfinder.models.path module
SystemPath
SystemPath.Config
SystemPath.asdf_finder
SystemPath.check_for_asdf()
SystemPath.check_for_pyenv()
SystemPath.create()
SystemPath.executables
SystemPath.executables_tracking
SystemPath.find_all()
SystemPath.find_all_python_versions()
SystemPath.find_python_version()
SystemPath.finders
SystemPath.finders_dict
SystemPath.get_path()
SystemPath.get_pythons()
SystemPath.global_search
SystemPath.ignore_unsupported
SystemPath.only_python
SystemPath.path_entries
SystemPath.path_order
SystemPath.paths
SystemPath.pyenv_finder
SystemPath.python_executables
SystemPath.python_executables_tracking
SystemPath.python_version_dict
SystemPath.set_defaults()
SystemPath.system
SystemPath.version_dict
SystemPath.version_dict_tracking
SystemPath.which()
exists_and_is_accessible()
- pythonfinder.models.python module
PythonFinder
PythonFinder.Config
PythonFinder.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_unsupported
PythonFinder.is_asdf
PythonFinder.is_pyenv
PythonFinder.paths
PythonFinder.pythons
PythonFinder.pythons_ref
PythonFinder.root
PythonFinder.roots
PythonFinder.sort_function
PythonFinder.version_from_bin_dir()
PythonFinder.version_glob_path
PythonFinder.version_paths
PythonFinder.versions
PythonFinder.which()
PythonVersion
PythonVersion.Config
PythonVersion.architecture
PythonVersion.as_dict()
PythonVersion.as_major()
PythonVersion.as_minor()
PythonVersion.comes_from
PythonVersion.company
PythonVersion.create()
PythonVersion.executable
PythonVersion.from_path()
PythonVersion.from_windows_launcher()
PythonVersion.get_architecture()
PythonVersion.is_debug
PythonVersion.is_devrelease
PythonVersion.is_postrelease
PythonVersion.is_prerelease
PythonVersion.major
PythonVersion.matches()
PythonVersion.minor
PythonVersion.name
PythonVersion.parse()
PythonVersion.parse_executable()
PythonVersion.patch
PythonVersion.update_metadata()
PythonVersion.version
PythonVersion.version_sort
PythonVersion.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()