o
    =g                     @   s   d dl mZmZ d dlmZ d dlmZmZ d dlm	Z	 d dl
mZ ddlmZmZmZmZ G dd	 d	eZG d
d deZG dd deZG dd deZG dd deZdS )    )AnyOptional)SpecifierSet)NormalizedNamecanonicalize_name)install_req_drop_extras)InstallRequirement   )	CandidateCandidateLookupRequirementformat_namec                   @   s   e Zd ZdeddfddZdefddZdefdd	Zdefd
dZ	de
defddZedefddZedefddZdefddZdefddZdedefddZdS )ExplicitRequirement	candidatereturnNc                 C   
   || _ d S Nr   selfr    r   c/var/www/html/venv/lib/python3.10/site-packages/pip/_internal/resolution/resolvelib/requirements.py__init__      
zExplicitRequirement.__init__c                 C   
   t | jS r   )strr   r   r   r   r   __str__   r   zExplicitRequirement.__str__c                 C   s   | j j d| jdS N())	__class____name__r   r   r   r   r   __repr__   s   zExplicitRequirement.__repr__c                 C   r   r   )hashr   r   r   r   r   __hash__   r   zExplicitRequirement.__hash__otherc                 C   s   t |tsdS | j|jkS NF)
isinstancer   r   r   r&   r   r   r   __eq__      
zExplicitRequirement.__eq__c                 C      | j jS r   )r   project_namer   r   r   r   r-         z ExplicitRequirement.project_namec                 C   r,   r   )r   namer   r   r   r   r/   #   r.   zExplicitRequirement.namec                 C   s
   | j  S r   )r   format_for_errorr   r   r   r   r0   (   r   z$ExplicitRequirement.format_for_errorc                 C   s
   | j d fS r   r   r   r   r   r   get_candidate_lookup+   r   z(ExplicitRequirement.get_candidate_lookupc                 C   s
   || j kS r   r   r   r   r   r   is_satisfied_by.   r   z#ExplicitRequirement.is_satisfied_by)r"   
__module____qualname__r
   r   r   r   r#   intr%   r   boolr*   propertyr   r-   r/   r0   r   r1   r2   r   r   r   r   r      s    r   c                   @   s   e Zd ZdeddfddZedefddZdefdd	Zdefd
dZ	de
defddZdefddZedefddZedefddZdefddZdefddZdedefddZdS )SpecifierRequirementireqr   Nc                 C   s@   |j d u s	J d|| _d | _d | _tdd | jjD | _d S )NThis is a link, not a specifierc                 s       | ]}t |V  qd S r   r   .0er   r   r   	<genexpr>8       z0SpecifierRequirement.__init__.<locals>.<genexpr>)link_ireq_equal_cache_hash	frozensetextras_extrasr   r9   r   r   r   r   3   s
   zSpecifierRequirement.__init__c                 C   "   | j d ur| j S t| j| _ | j S r   rD   r   rC   r   r   r   r   _equal:      
zSpecifierRequirement._equalc                 C   s   t | jjS r   )r   rC   reqr   r   r   r   r   B      zSpecifierRequirement.__str__c                 C   s   | j j dt| jjdS r   )r!   r"   r   rC   rN   r   r   r   r   r#   E   s   zSpecifierRequirement.__repr__r&   c                 C      t |tstS | j|jkS r   )r(   r8   NotImplementedrL   r)   r   r   r   r*   H   r+   zSpecifierRequirement.__eq__c                 C   rJ   r   rE   r$   rL   r   r   r   r   r%   M      
zSpecifierRequirement.__hash__c                 C   s   | j jsJ dt| j jjS )N'Specifier-backed ireq is always PEP 508)rC   rN   r   r/   r   r   r   r   r-   T   s   z!SpecifierRequirement.project_namec                 C   s   t | j| jS r   )r   r-   rH   r   r   r   r   r/   Y   s   zSpecifierRequirement.namec                 C   sZ   dd t | dD }t|dkrdS t|dkr|d S d|d d d	 |d  S )
Nc                 S   s   g | ]}|  qS r   )strip)r>   sr   r   r   
<listcomp>b   s    z9SpecifierRequirement.format_for_error.<locals>.<listcomp>,r    r	   z, z and )r   splitlenjoin)r   partsr   r   r   r0   ]   s   z%SpecifierRequirement.format_for_errorc                 C   s
   d | j fS r   )rC   r   r   r   r   r1   j   r   z)SpecifierRequirement.get_candidate_lookupr   c                 C   sN   |j | j ksJ d|j  d| j  | jjsJ d| jjj}|j|jddS )Nz6Internal issue: Candidate is not for this requirement z vs rT   Tprereleases)r/   rC   rN   	specifiercontainsversion)r   r   specr   r   r   r2   m   s   
z$SpecifierRequirement.is_satisfied_by)r"   r3   r4   r   r   r7   r   rL   r   r#   objectr6   r*   r5   r%   r   r-   r/   r0   r   r1   r
   r2   r   r   r   r   r8   2   s    r8   c                   @   sT   e Zd ZdZdeddfddZedefddZd	e	de
fd
dZdefddZdS )!SpecifierWithoutExtrasRequirementz
    Requirement backed by an install requirement on a base package.
    Trims extras from its install requirement if there are any.
    r9   r   Nc                 C   sD   |j d u s	J dt|| _d | _d | _tdd | jjD | _d S )Nr:   c                 s   r;   r   r<   r=   r   r   r   r@      rA   z=SpecifierWithoutExtrasRequirement.__init__.<locals>.<genexpr>)rB   r   rC   rD   rE   rF   rG   rH   rI   r   r   r   r      s
   
z*SpecifierWithoutExtrasRequirement.__init__c                 C   rJ   r   rK   r   r   r   r   rL      rM   z(SpecifierWithoutExtrasRequirement._equalr&   c                 C   rP   r   )r(   rf   rQ   rL   r)   r   r   r   r*      r+   z(SpecifierWithoutExtrasRequirement.__eq__c                 C   rJ   r   rR   r   r   r   r   r%      rS   z*SpecifierWithoutExtrasRequirement.__hash__)r"   r3   r4   __doc__r   r   r7   r   rL   re   r6   r*   r5   r%   r   r   r   r   rf   z   s    rf   c                   @   s   e Zd ZdZdededdfddZdefdd	Zdefd
dZ	de
fddZdedefddZedefddZedefddZdefddZdefddZdedefddZdS )RequiresPythonRequirementz4A requirement representing Requires-Python metadata.ra   matchr   Nc                 C   s    || _ t|| _d | _|| _d S r   )ra   r   _specifier_stringrE   
_candidate)r   ra   ri   r   r   r   r      s   

z"RequiresPythonRequirement.__init__c                 C   s   d| j  S )NzPython )ra   r   r   r   r   r      rO   z!RequiresPythonRequirement.__str__c                 C      | j j dt| jdS r   )r!   r"   r   ra   r   r   r   r   r#         z"RequiresPythonRequirement.__repr__c                 C   s(   | j d ur| j S t| j| jf| _ | j S r   )rE   r$   rj   rk   r   r   r   r   r%      s   
z"RequiresPythonRequirement.__hash__r&   c                 C   s&   t |tsdS | j|jko| j|jkS r'   )r(   rh   rj   rk   r)   r   r   r   r*      s
   

z RequiresPythonRequirement.__eq__c                 C   r,   r   )rk   r-   r   r   r   r   r-         z&RequiresPythonRequirement.project_namec                 C   r,   r   )rk   r/   r   r   r   r   r/      rn   zRequiresPythonRequirement.namec                 C      t | S r   r   r   r   r   r   r0         z*RequiresPythonRequirement.format_for_errorc                 C   s"   | j j| jjddr| jd fS dS )NTr_   NN)ra   rb   rk   rc   r   r   r   r   r1      s   
z.RequiresPythonRequirement.get_candidate_lookupr   c                 C   s(   |j | jj ksJ d| jj|jddS )NzNot Python candidateTr_   )r/   rk   ra   rb   rc   r   r   r   r   r2      s   z)RequiresPythonRequirement.is_satisfied_by)r"   r3   r4   rg   r   r
   r   r   r   r#   r5   r%   r   r6   r*   r7   r   r-   r/   r0   r   r1   r2   r   r   r   r   rh      s    rh   c                   @   s   e Zd ZdZdeddfddZdefddZdefd	d
Zde	de
fddZdefddZedefddZedefddZdefddZdefddZdede
fddZdS )UnsatisfiableRequirementz'A requirement that cannot be satisfied.r/   r   Nc                 C   r   r   _name)r   r/   r   r   r   r      r   z!UnsatisfiableRequirement.__init__c                 C   s   | j  dS )Nz (unavailable)rt   r   r   r   r   r      rO   z UnsatisfiableRequirement.__str__c                 C   rl   r   )r!   r"   r   ru   r   r   r   r   r#      rm   z!UnsatisfiableRequirement.__repr__r&   c                 C   rP   r   )r(   rs   rQ   ru   r)   r   r   r   r*      r+   zUnsatisfiableRequirement.__eq__c                 C   r   r   )r$   ru   r   r   r   r   r%      r   z!UnsatisfiableRequirement.__hash__c                 C      | j S r   rt   r   r   r   r   r-         z%UnsatisfiableRequirement.project_namec                 C   rv   r   rt   r   r   r   r   r/      rw   zUnsatisfiableRequirement.namec                 C   ro   r   rp   r   r   r   r   r0      rq   z)UnsatisfiableRequirement.format_for_errorc                 C      dS )Nrr   r   r   r   r   r   r1         z-UnsatisfiableRequirement.get_candidate_lookupr   c                 C   rx   r'   r   r   r   r   r   r2      ry   z(UnsatisfiableRequirement.is_satisfied_by)r"   r3   r4   rg   r   r   r   r   r#   re   r6   r*   r5   r%   r7   r-   r/   r0   r   r1   r
   r2   r   r   r   r   rs      s    rs   N)typingr   r    pip._vendor.packaging.specifiersr   pip._vendor.packaging.utilsr   r   pip._internal.req.constructorsr   pip._internal.req.req_installr   baser
   r   r   r   r   r8   rf   rh   rs   r   r   r   r   <module>   s    &H"6