pythonfinder package

class pythonfinder.Finder(**data)[source]

Bases: FinderBaseModel

create_system_path()[source]
Return type

SystemPath

find_all_python_versions(major=None, minor=None, patch=None, pre=None, dev=None, arch=None, name=None)[source]
Return type

list[PathEntry]

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.

ignore_unsupported: bool
classmethod parse_major(major, minor=None, patch=None, pre=None, dev=None, arch=None)[source]
Return type

dict[str, Any]

path_prepend: Optional[str]
sort_by_path: bool
system: bool
system_path: Optional[SystemPath]
which(exe)[source]
Return type

PathEntry | None

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]
static check_for_asdf()[source]
static check_for_pyenv()[source]
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

SystemPath

Returns

A new pythonfinder.models.SystemPath instance.

property executables: list[PathEntry]
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

list[PathEntry | PythonFinder]

Returns

List[PathEntry]

find_all_python_versions(major=None, minor=None, patch=None, pre=None, dev=None, arch=None, name=None)[source]
Return type

list[PathEntry]

find_python_version(major=None, minor=None, patch=None, pre=None, dev=None, arch=None, name=None, sort_by_path=False)[source]
Return type

PathEntry

property finders: list[str]
finders_dict: Dict[str, PythonFinder]
get_path(path)[source]
Return type

PythonFinder | PathEntry

get_pythons(finder)[source]
Return type

Iterator

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]
classmethod set_defaults(values)[source]
system: bool
version_dict
version_dict_tracking: Dict[Tuple, List[PathEntry]]
which(executable)[source]

Search for an executable on the path.

Parameters

executable (str) – Name of the executable to be located.

Return type

PathEntry | None

Returns

PathEntry object.

Subpackages

Submodules