관리-도구
편집 파일: index.cpython-38.pyc
U ��.e� � @ s( d Z ddlmZ ddlZddlZddlmZ ddlmZ ddl m Z ddlm Z mZmZmZ ddlmZ dd lmZ dd lmZ ddlmZ ddlmZ dd lmZ ddlmZ ddlm Z ddl!m"Z" ddl#m$Z$ ddl%m&Z& ddl'm(Z( ddl)m*Z* e$�r�ddl+m,Z,m-Z-m.Z.m/Z/m0Z0m1Z1m2Z2m3Z3 ddl m4Z4 ddl5m6Z6 ddl7m8Z8 ddl9m:Z: ddl;m<Z< ddl=m>Z> e3e2d e2e?e@f f ZAe2e?e?e?e4eAe/e? f ZBdddgZCe�DeE�ZFd1d!d"�ZGG d#d$� d$eH�ZId%d&� ZJG d'd(� d(eH�ZKG d)d� deH�ZLG d*d+� d+eH�ZMG d,d� deH�ZNd-d.� ZOd/d0� ZPdS )2z!Routines related to PyPI, indexes� )�absolute_importN)� specifiers)�canonicalize_name)�parse)�BestVersionAlreadyInstalled�DistributionNotFound�InvalidWheelFilename�UnsupportedWheel)�InstallationCandidate)� FormatControl)�Link)�SelectionPreferences)�TargetPython)�WHEEL_EXTENSION)� indent_log)�build_netloc)�check_requires_python)�MYPY_CHECK_RUNNING)�SUPPORTED_EXTENSIONS)�url_to_path)�Wheel)� FrozenSet�Iterable�List�Optional�Set�Text�Tuple�Union)�_BaseVersion)� LinkCollector)�SearchScope)�InstallRequirement)� Pep425Tag)�Hashes� r �BestCandidateResult� PackageFinderFc C s~ zt | j|d�}W n& tjk r8 t�d| j| � Y nBX |szd�tt|��}|sht�d|| j| � dS t�d|| j| � dS )aa Return whether the given Python version is compatible with a link's "Requires-Python" value. :param version_info: A 3-tuple of ints representing the Python major-minor-micro version to check. :param ignore_requires_python: Whether to ignore the "Requires-Python" value if the given Python version isn't compatible. )�version_infoz2Ignoring invalid Requires-Python (%r) for link: %s�.z4Link requires a different Python (%s not in: %r): %sFzBIgnoring failed Requires-Python check (%s not in: %r) for link: %sT) r Zrequires_pythonr ZInvalidSpecifier�logger�debug�join�map�str)�linkr( �ignore_requires_pythonZ is_compatible�versionr% r% �7/usr/lib/python3.8/site-packages/pip/_internal/index.py�_check_link_requires_python; s8 � � � �r3 c @ s, e Zd ZdZe�d�Zddd�Zdd� ZdS ) � LinkEvaluatorzD Responsible for evaluating links for a particular project. z-py([123]\.?[0-9]?)$Nc C s4 |dkrd}|| _ || _|| _|| _|| _|| _dS )a� :param project_name: The user supplied package name. :param canonical_name: The canonical package name. :param formats: The formats allowed for this package. Should be a set with 'binary' or 'source' or both in it. :param target_python: The target Python interpreter to use when evaluating link compatibility. This is used, for example, to check wheel compatibility, as well as when checking the Python version, e.g. the Python version embedded in a link filename (or egg fragment) and against an HTML link's optional PEP 503 "data-requires-python" attribute. :param allow_yanked: Whether files marked as yanked (in the sense of PEP 592) are permitted to be candidates for install. :param ignore_requires_python: Whether to ignore incompatible PEP 503 "data-requires-python" values in HTML links. Defaults to False. NF)� _allow_yanked�_canonical_name�_ignore_requires_python�_formats�_target_python�project_name)�selfr: �canonical_name�formats� target_python�allow_yankedr0 r% r% r2 �__init__r s zLinkEvaluator.__init__c C s� d}|j r(| js(|jpd}dd�|�fS |jr<|j}|j}n�|�� \}}|sPdS |tkrddd| fS d| jkr�|t kr�d| j }d|fS d |jkr�|d kr�dS |t k�r,zt|j �}W n tk r� Y dS X t|j�| jkr�d | j }d|fS | j�� }|�|��s&|�� }d�d�|��}d|fS |j}d| jk�rP|t k�rPdd| j fS |�sbt|| j�}|�svdd| j fS | j�|�} | �r�|d| �� � }| �d�} | | jjk�r�dS t|| jj| j d�}|�s�dS t!�"d||� d|fS )aG Determine whether a link is a candidate for installation. :return: A tuple (is_candidate, result), where `result` is (1) a version string if `is_candidate` is True, and (2) if `is_candidate` is False, an optional string to log the reason the link fails to qualify. N�<none given>Fzyanked for reason: {})Fz not a filezunsupported archive format: %sZbinaryzNo binaries permitted for %sZmacosx10z.zip)Fzmacosx10 one)Fzinvalid wheel filenamezwrong project name (not %s)z"none of the wheel's tags match: {}�, �sourcezNo sources permitted for %szMissing project version for %s� )FzPython version is incorrect)r( r0 )FNzFound link %s, version: %sT)#� is_yankedr5 � yanked_reason�format�egg_fragment�ext�splitextr r8 r r: �pathr �filenamer r �namer6 r9 �get_tags� supportedZget_formatted_file_tagsr, r1 �_extract_version_from_fragment�_py_version_re�search�start�group� py_versionr3 Zpy_version_infor7 r* r+ )r; r/ r1 �reasonZegg_inforI �wheel�supported_tagsZ file_tags�matchrU Zsupports_pythonr% r% r2 � evaluate_link� sx �� � � �zLinkEvaluator.evaluate_link)N) �__name__� __module__�__qualname__�__doc__�re�compilerQ r@ rZ r% r% r% r2 r4 f s � &r4 c C s� |st �dt| �|� t| �S g }g }d}| D ]>}|j}|js@n"|j|d�rV|d7 }n|�|� q.|�|� q.|rx|}nt| �}t|�t| �kr�d} n d�t|�d� dd � |D ���} t �d t| �||j |t|�| | � |S )a� Filter out candidates whose hashes aren't allowed, and return a new list of candidates. If at least one candidate has an allowed hash, then all candidates with either an allowed hash or no hash specified are returned. Otherwise, the given candidates are returned. Including the candidates with no hash specified when there is a match allows a warning to be logged if there is a more preferred candidate with no hash specified. Returning all candidates in the case of no matches lets pip report the hash of the candidate that would otherwise have been installed (e.g. permitting the user to more easily update their requirements file with the desired hash). zJGiven no hashes to check %s links for project %r: discarding no candidatesr )�hashesrD zdiscarding no candidateszdiscarding {} non-matches: {}z c s s | ]}t |j�V qd S �N)r. r/ ��.0� candidater% r% r2 � <genexpr>+ s z*filter_unallowed_hashes.<locals>.<genexpr>zPChecked %s links for project %r against %s hashes (%s matches, %s no digest): %s)r* r+ �len�listr/ Zhas_hash�is_hash_allowed�appendrG r, Zdigest_count) � candidatesra r: Zmatches_or_no_digestZnon_matchesZmatch_countre r/ ZfilteredZdiscard_messager% r% r2 �filter_unallowed_hashes� sL � � �rl c @ s e Zd ZdZddd�ZdS )�CandidatePreferenceszk Encapsulates some of the preferences for filtering and sorting InstallationCandidate objects. Fc C s || _ || _dS )zR :param allow_all_prereleases: Whether to allow all pre-releases. N)�allow_all_prereleases� prefer_binary)r; ro rn r% r% r2 r@ C s zCandidatePreferences.__init__N)FF)r[ r\ r] r^ r@ r% r% r% r2 rm < s �rm c @ s( e Zd ZdZdd� Zdd� Zdd� ZdS ) r&