관리-도구
편집 파일: package_finder.cpython-38.pyc
U &?�f"� � @ s� d Z ddlZddlZddlZddlZddlZddlmZ ddlm Z m Z mZmZm Z mZmZmZ ddlmZ ddlmZ ddlmZ ddlmZmZ dd lmZ dd lmZmZmZm Z ddl!m"Z"m#Z# ddl$m%Z% dd l&m'Z' ddl(m)Z) ddl*m+Z+ ddl,m-Z- ddl.m/Z/ ddl0m1Z1 ddl2m3Z3 ddl4m5Z5 ddl6m7Z7 ddl8m9Z9 ddl:m;Z; ddl<m=Z= ddl>m?Z? ddl@mAZA e �r�ddlBmCZC dddgZDe5eE�ZFeed eeGeHf f ZIeeGeGeGee eG eIf ZJd6e)eeGeGeGf eKeKd!�d"d#�ZLG d$d%� d%ejM�ZNG d&d'� d'�ZOee% e e9 eHee% d(�d)d*�ZPeG d+d,� d,��ZQG d-d� d�ZRG d.d/� d/�ZSG d0d� d�ZTeHeHeGd1�d2d3�ZUeHeHe eH d1�d4d5�ZVdS )7z!Routines related to PyPI, indexes� N)� dataclass)� TYPE_CHECKING� FrozenSet�Iterable�List�Optional�Set�Tuple�Union)� specifiers)�Tag)�canonicalize_name)�InvalidVersion�_BaseVersion)�parse)�BestVersionAlreadyInstalled�DistributionNotFound�InvalidWheelFilename�UnsupportedWheel)� LinkCollector�parse_links)�InstallationCandidate)� FormatControl)�Link)�SearchScope)�SelectionPreferences)�TargetPython)�Wheel)�InstallRequirement)� getLogger)�WHEEL_EXTENSION)�Hashes)� indent_log)�build_netloc)�check_requires_python)�SUPPORTED_EXTENSIONS)� TypeGuardr �BestCandidateResult� PackageFinder� F)�link�version_info�ignore_requires_python�returnc 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. )r+ z2Ignoring 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$ �requires_pythonr �InvalidSpecifier�logger�debug�join�map�str�verbose)r* r+ r, � is_compatible�versionr) r) �P/opt/hc_python/lib/python3.8/site-packages/pip/_internal/index/package_finder.py�_check_link_requires_python4 s8 � � ��r: c @ sD e Zd Ze�� Ze�� Ze�� Ze�� Ze�� Z e�� Z e�� ZdS )�LinkTypeN)�__name__� __module__�__qualname__�enum�auto� candidate�different_project�yanked�format_unsupported�format_invalid�platform_mismatch�requires_python_mismatchr) r) r) r9 r; c s r; c @ sV e Zd ZdZe�d�Zd eeee e e ee dd�dd�Ze eeef d�dd �ZdS )� LinkEvaluatorzD Responsible for evaluating links for a particular project. z-py([123]\.?[0-9]?)$N)�project_name�canonical_name�formats� target_python�allow_yankedr, r- c 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_pythonrI )�selfrI rJ rK rL rM r, r) r) r9 �__init__x s zLinkEvaluator.__init__)r* r- c C sB d}|j r*| js*|jpd}tjd|� �fS |jr@|j}|j}�n|�� \}}|sZtjdfS |t krrtjd|� �fS d| j kr�|tkr�d| j� �}tj|fS d|j kr�|d kr�tjd fS |tk�rXzt|j�}W n tk r� tjdf Y S X t|j�| jk�rd| j� d �}tj|fS | j�� }|�|��sRd�|�� �}d|� d�}tj|fS |j}d| j k�r�|tk�r�d| j� �}tj|fS |�s�t|| j�}|�s�d| j� �}tj|fS | j�|�} | �r�|d| � � � }| �!d�} | | jj"k�r�tjdfS t#|| jj$| j%d�}|�s*|� d|j&� �}tj'|fS t(�)d||� tj*|fS )a� Determine whether a link is a candidate for installation. :return: A tuple (result, detail), where *result* is an enum representing whether the evaluation found a candidate, or the reason why one is not found. If a candidate is found, *detail* will be the candidate's version string; if one is not found, it contains the reason the link fails to qualify. Nz<none given>zyanked for reason: z not a filezunsupported archive format: �binaryzNo binaries permitted for �macosx10z.zipzmacosx10 onezinvalid wheel filenamezwrong project name (not �)�, znone of the wheel's tags (zB) are compatible (run pip debug --verbose to show compatible tags)�sourcezNo sources permitted for zMissing project version for � zPython version is incorrect)r+ r, z Requires-Python zFound link %s, version: %s)+� is_yankedrN � yanked_reasonr; rC �egg_fragment�ext�splitextrD r% rQ r rI �pathr �filenamer rE r �namerO rB rR �get_unsorted_tags� supportedr3 �get_formatted_file_tagsrF r8 �_extract_version_from_fragment�_py_version_re�search�start�group� py_versionr: �py_version_inforP r/ rG r1 r2 rA )rS r* r8 �reason�egg_infor^ �wheel�supported_tags� file_tags�matchrk �supports_pythonr) r) r9 � evaluate_link� s� � � � � �� zLinkEvaluator.evaluate_link)N)r<