OwlCyberSecurity - MANAGER
Edit File: package_finder.cpython-39.pyc
a �F�fe� � @ 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 g d�ZDe5eE�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 d/d0� d0�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)� TypeGuard)r �BestCandidateResult� PackageFinder� F)�link�version_info�ignore_requires_python�returnc C s| zt | j|d�}W n$ tjy6 t�d| j| � Y nB0 |sxd�tt|��}|sft� 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, Z is_compatible�versionr) r) �d/home/gouroczh/virtualenv/test/3.9/lib/python3.9/site-packages/pip/_internal/index/package_finder.py�_check_link_requires_python4 s8 � � ��r9 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) r8 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 |du rd}|| _ || _|| _|| _|| _|| _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_pythonrH )�selfrH rI rJ rK rL r, r) r) r8 �__init__x s zLinkEvaluator.__init__)r* r- c C s@ d}|j r*| js*|jpd}tjd|� �fS |jr@|j}|j}�n|�� \}}|sZtjdfS |t vrrtjd|� �fS d| j vr�|tkr�d| j� �}tj|fS d|j v r�|d kr�tjd fS |tk�rVzt|j�}W n ty� tjdf Y S 0 t|j�| jk�rd| j� d �}tj|fS | j�� }|�|��sPd�|�� �}d|� d�}tj|fS |j}d| j v�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 Zmacosx10z.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_yankedrM � yanked_reasonr: rB �egg_fragment�ext�splitextrC r% rP r rH �pathr �filenamer rD r �namerN rA rQ �get_unsorted_tags� supportedr3 �get_formatted_file_tagsrE r7 �_extract_version_from_fragment�_py_version_re�search�start�group� py_versionr9 �py_version_inforO r/ rF r1 r2 r@ )rR r* r7 �reasonZegg_infor\ �wheel�supported_tags� file_tags�matchri Zsupports_pythonr) r) r8 � evaluate_link� s� � � � � �� zLinkEvaluator.evaluate_link)N)r; r<