pythonfinder.models.path module

class pythonfinder.models.path.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
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
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.

pythonfinder.models.path.exists_and_is_accessible(path)[source]