Qucs-S S-parameter Viewer & RF Synthesis Tools
Loading...
Searching...
No Matches
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
pip._internal.index.package_finder.CandidateEvaluator Class Reference

Public Member Functions

"CandidateEvaluator" create (cls, str project_name, Optional[TargetPython] target_python=None, bool prefer_binary=False, bool allow_all_prereleases=False, Optional[specifiers.BaseSpecifier] specifier=None, Optional[Hashes] hashes=None)
 
None __init__ (self, str project_name, List[Tag] supported_tags, specifiers.BaseSpecifier specifier, bool prefer_binary=False, bool allow_all_prereleases=False, Optional[Hashes] hashes=None)
 
List[InstallationCandidateget_applicable_candidates (self, List[InstallationCandidate] candidates)
 
Optional[InstallationCandidatesort_best_candidate (self, List[InstallationCandidate] candidates)
 
BestCandidateResult compute_best_candidate (self, List[InstallationCandidate] candidates)
 

Protected Member Functions

CandidateSortingKey _sort_key (self, InstallationCandidate candidate)
 

Protected Attributes

 _allow_all_prereleases
 
 _hashes
 
 _prefer_binary
 
 _project_name
 
 _specifier
 
 _supported_tags
 
 _wheel_tag_preferences
 

Detailed Description

Responsible for filtering and sorting candidates for installation based
on what tags are valid.

Constructor & Destructor Documentation

◆ __init__()

None pip._internal.index.package_finder.CandidateEvaluator.__init__ (   self,
str  project_name,
List[Tag supported_tags,
specifiers.BaseSpecifier  specifier,
bool   prefer_binary = False,
bool   allow_all_prereleases = False,
Optional[Hashes]   hashes = None 
)
:param supported_tags: The PEP 425 tags supported by the target
    Python in order of preference (most preferred first).

Member Function Documentation

◆ _sort_key()

CandidateSortingKey pip._internal.index.package_finder.CandidateEvaluator._sort_key (   self,
InstallationCandidate  candidate 
)
protected
Function to pass as the `key` argument to a call to sorted() to sort
InstallationCandidates by preference.

Returns a tuple such that tuples sorting as greater using Python's
default comparison operator are more preferred.

The preference is as follows:

First and foremost, candidates with allowed (matching) hashes are
always preferred over candidates without matching hashes. This is
because e.g. if the only candidate with an allowed hash is yanked,
we still want to use that candidate.

Second, excepting hash considerations, candidates that have been
yanked (in the sense of PEP 592) are always less preferred than
candidates that haven't been yanked. Then:

If not finding wheels, they are sorted by version only.
If finding wheels, then the sort order is by version, then:
  1. existing installs
  2. wheels ordered via Wheel.support_index_min(self._supported_tags)
  3. source archives
If prefer_binary was set, then all wheels are sorted above sources.

Note: it was considered to embed this logic into the Link
      comparison operators, but then different sdist links
      with the same version, would have to be considered equal

◆ compute_best_candidate()

BestCandidateResult pip._internal.index.package_finder.CandidateEvaluator.compute_best_candidate (   self,
List[InstallationCandidate candidates 
)
Compute and return a `BestCandidateResult` instance.

◆ create()

"CandidateEvaluator" pip._internal.index.package_finder.CandidateEvaluator.create (   cls,
str  project_name,
Optional[TargetPython]   target_python = None,
bool   prefer_binary = False,
bool   allow_all_prereleases = False,
Optional[specifiers.BaseSpecifier]   specifier = None,
Optional[Hashes]   hashes = None 
)
Create a CandidateEvaluator object.

:param target_python: The target Python interpreter to use when
    checking compatibility. If None (the default), a TargetPython
    object will be constructed from the running Python.
:param specifier: An optional object implementing `filter`
    (e.g. `packaging.specifiers.SpecifierSet`) to filter applicable
    versions.
:param hashes: An optional collection of allowed hashes.

◆ get_applicable_candidates()

List[InstallationCandidate] pip._internal.index.package_finder.CandidateEvaluator.get_applicable_candidates (   self,
List[InstallationCandidate candidates 
)
Return the applicable candidates from a list of candidates.

◆ sort_best_candidate()

Optional[InstallationCandidate] pip._internal.index.package_finder.CandidateEvaluator.sort_best_candidate (   self,
List[InstallationCandidate candidates 
)
Return the best candidate per the instance's sort order, or None if
no candidate is acceptable.

The documentation for this class was generated from the following file: