Caution

This API is not finalized, and may change in a patch version.

unearth.evaluator#

Evaluate the links based on the given environment.

class unearth.evaluator.Evaluator(package_name: str, target_python: ~unearth.evaluator.TargetPython = <factory>, ignore_compatibility: bool = False, allow_yanked: bool = False, format_control: ~unearth.evaluator.FormatControl = <factory>, exclude_newer_than: ~datetime.datetime | None = None)#

Evaluate the links based on the given environment.

Parameters:
  • package_name – The links must match the package name

  • target_python – The links must match the target Python

  • ignore_compatibility – Whether to ignore the compatibility check

  • allow_yanked – Whether to allow yanked candidates

  • format_control – Format control flags

  • exclude_newer_than – Exclude the candidates newer than this date

Evaluate the link and return the package if it matches or None if it doesn’t.

validate_wheel_tag(tags: Iterable[Tag]) bool#

Check if the wheel tags are compatible with the target Python.

Parameters:

tags (Iterable[Tag]) – The wheel tags to check.

class unearth.evaluator.Package(name: str, version: str | None, link: Link)#

A package instance has a name, version, and link that can be downloaded or unpacked.

name#

The name of the package.

Type:

str

version#

The version of the package, or None if the requirement is a link.

Type:

str | None

The link to the package.

Type:

unearth.link.Link

as_json() dict[str, Any]#

Return a JSON-serializable representation of the package.

class unearth.evaluator.TargetPython(py_ver: tuple[int, ...] | None = None, abis: list[str] | None = None, impl: str | None = None, platforms: list[str] | None = None)#

Target Python to get the candidates.

py_ver#

Python version tuple, e.g. (3, 9).

Type:

tuple[int, …] | None

platforms#

List of platforms, e.g. ['linux_x86_64'].

Type:

list[str] | None

impl#

Implementation, e.g. 'cp'.

Type:

str | None

abis#

List of ABIs, e.g. ['cp39'].

Type:

list[str] | None

unearth.evaluator.evaluate_package(package: Package, requirement: Requirement, allow_prereleases: bool | None = None) bool#

Evaluate the package based on the requirement.

Parameters:
  • package (Package) – The package to evaluate

  • requirement – The requirement to evaluate against

  • allow_prerelease (bool|None) – Whether to allow prereleases, or None to infer from the specifier.

Returns:

True if the package matches the requirement, False otherwise

Return type:

bool