pythonfinder.models.path module

class pythonfinder.models.path.PathEntry(path=None, children=NOTHING, only_python=False, name=NOTHING, py_version=None, pythons=NOTHING, is_dir=None, is_executable=None, is_python=None, is_root=True)[source]

Bases: pythonfinder.models.mixins.BasePath

property children
classmethod create(path, is_root=False, only_python=False, pythons=None, name=None)[source]

Helper method for creating new pythonfinder.models.PathEntry instances.

Parameters
  • path (str) – Path to the specified location.

  • is_root (bool) – Whether this is a root from the environment PATH variable, defaults to False

  • only_python (bool) – Whether to search only for python executables, defaults to False

  • pythons (dict) – A dictionary of existing python objects (usually from a finder), defaults to None

  • name (str) – Name of the python version, e.g. anaconda3-5.3.0

Returns

A new instance of the class.

Return type

pythonfinder.models.PathEntry

is_root
class pythonfinder.models.path.SystemPath(global_search=True, paths=NOTHING, executables=NOTHING, python_executables=NOTHING, path_order=NOTHING, python_version_dict=NOTHING, only_python=False, pyenv_finder=None, asdf_finder=None, windows_finder=None, system=False, version_dict=NOTHING, ignore_unsupported=False, SystemPath__finders=NOTHING)[source]

Bases: object

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

Returns

A new pythonfinder.models.SystemPath instance.

Return type

pythonfinder.models.SystemPath

create_python_version_dict()[source]
executables
find_all(executable)[source]

Search the path for an executable. Return all copies.

Parameters

executable (str) – Name of the executable

Returns

List[PathEntry]

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

Search for a specific python version on the path. Return all copies

Parameters
  • major (int) – Major python version to search for.

  • minor (int) – Minor python version to search for, defaults to None

  • patch (int) – Patch python version to search for, defaults to None

  • pre (bool) – Search for prereleases (default None) - prioritize releases if None

  • dev (bool) – Search for devreleases (default None) - prioritize releases if None

  • arch (str) – Architecture to include, e.g. ‘64bit’, defaults to None

  • name (str) – The name of a python version, e.g. anaconda3-5.3.0

Returns

A list of PathEntry instances matching the version requested.

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]

Search for a specific python version on the path.

Parameters
  • major (int) – Major python version to search for.

  • minor (int) – Minor python version to search for, defaults to None

  • patch (int) – Patch python version to search for, defaults to None

  • pre (bool) – Search for prereleases (default None) - prioritize releases if None

  • dev (bool) – Search for devreleases (default None) - prioritize releases if None

  • arch (str) – Architecture to include, e.g. ‘64bit’, defaults to None

  • name (str) – The name of a python version, e.g. anaconda3-5.3.0

  • sort_by_path (bool) – Whether to sort by path – default sort is by version(default: False)

Returns

A PathEntry instance matching the version requested.

Return type

PathEntry

property finders
get_path(path)[source]
get_pythons(finder)[source]
path_entries
python_executables
reload_finder(finder_name)[source]
version_dict
which(executable)[source]

Search for an executable on the path.

Parameters

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

Returns

PathEntry object.

class pythonfinder.models.path.VersionPath(global_search=True, paths=NOTHING, executables=NOTHING, python_executables=NOTHING, path_order=NOTHING, python_version_dict=NOTHING, only_python=False, pyenv_finder=None, asdf_finder=None, windows_finder=None, system=False, version_dict=NOTHING, ignore_unsupported=False, SystemPath__finders=NOTHING, base=None, name=None)[source]

Bases: pythonfinder.models.path.SystemPath

classmethod create(path, only_python=True, pythons=None, name=None)[source]

Accepts a path to a base python version directory.

Generates the version listings for it