관리-도구
편집 파일: found_candidates.cpython-38.pyc
U &?�f� � @ s� d Z ddlZddlZddlmZ ddlmZmZmZm Z m Z mZmZ ddl mZ ddlmZ ddlmZ e�e�Zeeeg e e f f Zer�ee ZneZe e e e d �d d�Zee e e e d�d d�Zee e e e d�dd�ZG dd� de�ZdS )a� Utilities to lazily create and visit candidates found. Creating and visiting a candidate is a *very* costly operation. It involves fetching, extracting, potentially building modules from source, and verifying distribution metadata. It is therefore crucial for performance to keep everything here lazy all the way down, so we only touch candidates that we absolutely need, and not "download the world" when we only need one version of something. � N)�Sequence)� TYPE_CHECKING�Any�Callable�Iterator�Optional�Set�Tuple)�_BaseVersion)�MetadataInvalid� )� Candidate)�infos�returnc c s� t � }| D ]x\}}||krq z |� }W n@ tk rf } z"t�d||jj|� |�|� W 5 d}~X Y q X |dkrrq |V |�|� q dS )z�Iterator for ``FoundCandidates``. This iterator is used when the package is not already installed. Candidates from index come later in their normal ordering. zpIgnoring version %s of %s since it has invalid metadata: %s Please use pip<24.1 if you need to use this version.N)�setr �logger�warning�ireq�name�add)r �versions_found�version�func� candidate�e� r �b/opt/hc_python/lib/python3.8/site-packages/pip/_internal/resolution/resolvelib/found_candidates.py�_iter_built* s$ � r )� installedr r c c sJ | V | j h}|D ]2\}}||kr$q|� }|dkr4q|V |�|� qdS )aK Iterator for ``FoundCandidates``. This iterator is used when the resolver prefers the already-installed candidate and NOT to upgrade. The installed candidate is therefore always yielded first, and candidates from index come later in their normal ordering, except skipped when the version is already installed. N)r r �r r r r r r r r r �_iter_built_with_prependedI s r c c sn t � }|D ]N\}}||krq | j|kr8| V |�| j� |� }|dkrHq |V |�|� q | j|krj| V dS )a� Iterator for ``FoundCandidates``. This iterator is used when the resolver prefers to upgrade an already-installed package. Candidates from index are returned in their normal ordering, except replaced when the version is already installed. The implementation iterates through and yields other candidates, inserting the installed candidate exactly once before we start yielding older or equivalent candidates, or after all other candidates if they are all newer. N)r r r r r r r �_iter_built_with_inserted_ s r! c @ s� e Zd ZdZeg ee f ee e e e d�dd�Ze e d�dd�Zee d�d d �Zed�dd�Zejd d�e d�dd��ZdS )�FoundCandidatesac A lazy sequence to provide candidates to the resolver. The intended usage is to return this from `find_matches()` so the resolver can iterate through the sequence multiple times, but only access the index page when remote packages are actually needed. This improve performances when suitable candidates are already installed on disk. )� get_infosr �prefers_installed�incompatible_idsc C s || _ || _|| _|| _d S �N)� _get_infos� _installed�_prefers_installed�_incompatible_ids)�selfr# r r$ r% r r r �__init__� s zFoundCandidates.__init__)�indexr c C s t d��d S �Nz don't do this��NotImplementedError)r+ r- r r r �__getitem__� s zFoundCandidates.__getitem__)r c sJ � � � }� jst|�}n � jr,t� j|�}nt� j|�}� fdd�|D �S )Nc 3 s | ]}t |�� jkr|V qd S r&