pythonfinder.models.python module¶
- class pythonfinder.models.python.PythonFinder(**data)[source]¶
Bases:
PathEntry
- class Config[source]¶
Bases:
object
- allow_mutation = True¶
- arbitrary_types_allowed = True¶
- include_private_attributes = True¶
- validate_assignment = True¶
- classmethod create(root, sort_function, version_glob_path=None, ignore_unsupported=True)[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
- Return type
- Returns
A new instance of the class.
- 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
- Return type
- Returns
A list of
PathEntry
instances matching the version requested.
- find_python_version(major=None, minor=None, patch=None, pre=None, dev=None, arch=None, name=None)[source]¶
Search or self for the specified Python version and return the first match.
- Parameters
major (int) – Major version number.
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
- Return type
PathEntry | None
- Returns
A
PathEntry
instance matching the version requested.
- ignore_unsupported: bool¶
Whether to ignore any paths which raise exceptions and are not actually python
- paths: List¶
List of paths discovered during search
- pythons_ref: Dict¶
- root: Path¶
- roots: Dict¶
The root locations used for discovery
- sort_function: Optional[Callable]¶
The function to use to sort version order when returning an ordered version set
- version_glob_path: str¶
Glob path for python versions off of the root directory
- property versions: DefaultDict[tuple, PathEntry]¶
- class pythonfinder.models.python.PythonVersion(**data)[source]¶
Bases:
FinderBaseModel
- class Config[source]¶
Bases:
object
- allow_mutation = True¶
- arbitrary_types_allowed = True¶
- include_private_attributes = True¶
- validate_assignment = True¶
- architecture: Optional[str]¶
- comes_from: Optional['PathEntry']¶
- company: Optional[str]¶
- executable: Optional[Union[str, WindowsPath, Path]]¶
- classmethod from_path(path, name=None, ignore_unsupported=True, company=None)[source]¶
Parses a python version from a system path.
- Raises:
ValueError – Not a valid python path
- Parameters
- Return type
- Returns
An instance of a PythonVersion.
- classmethod from_windows_launcher(launcher_entry, name=None, company=None)[source]¶
Create a new PythonVersion instance from a Windows Launcher Entry
- Parameters
- Return type
- Returns
An instance of a PythonVersion.
- is_debug: bool¶
- is_devrelease: bool¶
- is_postrelease: bool¶
- is_prerelease: bool¶
- major: int¶
- matches(major=None, minor=None, patch=None, pre=False, dev=False, arch=None, debug=False, python_name=None)[source]¶
- Return type
- minor: Optional[int]¶
- name: Optional[str]¶
- classmethod parse(version)[source]¶
Parse a valid version string into a dictionary
- Raises:
ValueError – Unable to parse version string ValueError – Not a valid python version TypeError – NoneType or unparsable type passed in
- patch: Optional[int]¶
- update_metadata(metadata)[source]¶
Update the metadata on the current
pythonfinder.models.python.PythonVersion
Given a parsed version dictionary from
pythonfinder.utils.parse_python_version()
, update the instance variables of the current version instance to reflect the newly supplied values.- Return type
- version: Optional[Version]¶
- property version_sort: tuple[int, int, int | None, int, int]¶
A tuple for sorting against other instances of the same class.
Returns a tuple of the python version but includes points for core python, non-dev, and non-prerelease versions. So released versions will have 2 points for this value. E.g.
(1, 3, 6, 6, 2)
is a release,(1, 3, 6, 6, 1)
is a prerelease,(1, 3, 6, 6, 0)
is a dev release, and(1, 3, 6, 6, 3)
is a postrelease.(0, 3, 7, 3, 2)
represents a non-core python release, e.g. by a repackager of python like Continuum.
- class pythonfinder.models.python.VersionMap(**data)[source]¶
Bases:
FinderBaseModel
- class Config[source]¶
Bases:
object
- allow_mutation = True¶
- arbitrary_types_allowed = True¶
- include_private_attributes = True¶
- validate_assignment = True¶
- versions: DefaultDict[Tuple[int, Optional[int], Optional[int], bool, bool, bool], List[PathEntry]]¶