
    xiO                       d dl mZ d dlZd dlZd dlmZ d dlmZmZ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mZmZmZ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!m"Z" d dl#m$Z$ d dl%m&Z& d dl'm(Z( ddl)m*Z*m+Z+m,Z, erddl-m.Z.  ej^                  e0      Z1e	d   Z2 e
ed      Z3d%dZ4	 	 	 	 	 	 d&dZ5	 	 	 	 	 	 d&dZ6	 	 	 	 	 	 d'dZ7 G d de*      Z8 G d de8      Z9 G d de8      Z: G d d e*      Z; G d! d"e*      Z< G d# d$e*      Z=y)(    )annotationsN)Iterable)TYPE_CHECKINGAnyUnioncast)InvalidRequirement)NormalizedNamecanonicalize_name)Version)FailedToPrepareCandidate	HashErrorInstallationSubprocessErrorInvalidInstalledPackageMetadataInconsistentMetadataInvalid)BaseDistribution)Linklinks_equivalent)Wheel)install_req_from_editableinstall_req_from_line)InstallRequirement)direct_url_from_link)normalize_version_info   )	CandidateRequirementformat_name)Factory)AlreadyInstalledCandidateEditableCandidateLinkCandidatez<Python from Requires-Python>c                B    t         t        t        f}t        | |      r| S y)z%The runtime version of BaseCandidate.N)r!   r"   r#   
isinstance)	candidatebase_candidate_classess     i/var/www/html/binance/venv/lib/python3.12/site-packages/pip/_internal/resolution/resolvelib/candidates.pyas_base_candidater)   0   s+     	"
 )34    c           	     v   |j                   rJ d       |j                  rt        |j                        }n| j                  }t	        ||j
                  |j                  |j                  |j                  |j                  |j                        }|j                  |_        | |_        |j                  |_        |S )Nztemplate is editableuser_supplied
comes_fromisolated
constrainthash_optionsconfig_settings)editablereqstrurlr   r-   r.   r/   r0   r1   r2   original_linklinkextras)r8   templatelineireqs       r(   make_install_req_from_linkr=   <   s       8"88 ||8<< xx ,,&&""&&** 00D "//DDI//DKKr*   c           
     h   |j                   sJ d       |j                  r|j                   d| j                   }n| j                  }t        ||j                  |j
                  |j                  |j                  |j                  |j                  |j                        }|j                  |_        |S )Nztemplate not editable @ )r-   r.   r/   r0   permit_editable_wheelsr1   r2   )r3   namer6   r   r-   r.   r/   r0   r@   r1   r2   r9   )r8   r:   
req_stringr<   s       r(   make_install_req_from_editablerC   S   s     555}} c$((4
XX
$,,&&""&&'>>** 00	D //DKKr*   c           	        |j                   rt        |j                         }nM|j                  r&| j                   d|j                  j                   }n| j                   d| j
                   }t        ||j                  |j                  |j                  |j                  |j                  |j                        }| |_        |S )Nr?   z==r,   )r4   r5   r8   canonical_namer6   versionr   r-   r.   r/   r0   r1   r2   satisfied_by)distr:   r;   r<   s       r(   _make_install_req_from_distrI   i   s     ||8<< 	%%&c(--*;*;)<=%%&b7 ,,&&""&&** 00D DKr*   c                      e Zd ZU dZded<   dZ	 	 d	 	 	 	 	 	 	 	 	 	 	 	 	 ddZddZddZdd	Z	dd
Z
edd       Zedd       Zedd       Zedd       ZddZddZddZddZddZd dZy)!"_InstallRequirementBackedCandidatea  A candidate backed by an ``InstallRequirement``.

    This represents a package request with the target not being already
    in the environment, and needs to be fetched and installed. The backing
    ``InstallRequirement`` is responsible for most of the leg work; this
    class exposes appropriate information to the resolver.

    :param link: The link passed to the ``InstallRequirement``. The backing
        ``InstallRequirement`` will use this link to fetch the distribution.
    :param source_link: The link this candidate "originates" from. This is
        different from ``link`` when the link is found in the wheel cache.
        ``link`` would point to the wheel cache, while this points to the
        found remote link (e.g. from pypi.org).
    r   rH   FNc                    || _         || _        || _        || _        || _        || _        | j                         | _        d | _        y N)	_link_source_link_factory_ireq_name_version_preparerH   _hash)selfr8   source_linkr<   factoryrA   rF   s          r(   __init__z+_InstallRequirementBackedCandidate.__init__   sC     
'

MMO	!%
r*   c                8    | j                    d| j                   S )N rA   rF   rV   s    r(   __str__z*_InstallRequirementBackedCandidate.__str__   s    ))Adll^,,r*   c                `    | j                   j                   dt        | j                        dS N())	__class____name__r5   rN   r]   s    r(   __repr__z+_InstallRequirementBackedCandidate.__repr__   s)    ..))*!C

O+>a@@r*   c                    | j                   | j                   S t        | j                  | j                  f      | _         | j                   S rM   )rU   hashrc   rN   r]   s    r(   __hash__z+_InstallRequirementBackedCandidate.__hash__   s9    ::!::4>>4::67
zzr*   c                p    t        || j                        r t        | j                  |j                        S yNF)r%   rc   r   rN   rV   others     r(   __eq__z)_InstallRequirementBackedCandidate.__eq__   s(    eT^^,#DJJ<<r*   c                    | j                   S rM   )rO   r]   s    r(   rW   z._InstallRequirementBackedCandidate.source_link          r*   c                h    | j                   | j                  j                  | _         | j                   S z:The normalised name of the project the candidate refers to)rR   rH   rE   r]   s    r(   project_namez/_InstallRequirementBackedCandidate.project_name   s)     ::11DJzzr*   c                    | j                   S rM   rr   r]   s    r(   rA   z'_InstallRequirementBackedCandidate.name   ro   r*   c                h    | j                   | j                  j                  | _         | j                   S rM   rS   rH   rF   r]   s    r(   rF   z*_InstallRequirementBackedCandidate.version   '    ==  II--DM}}r*   c                    | j                    d| j                   d| j                  j                  r| j                  j                   dS | j                   dS )Nr[   z (from rb   )rA   rF   rN   is_file	file_pathr]   s    r(   format_for_errorz3_InstallRequirementBackedCandidate.format_for_error   s\    yyk4<<. )-1ZZ-?-?TZZ))PPQS	
EIZZPPQS	
r*   c                    t        d      )NzOverride in subclass)NotImplementedErrorr]   s    r(   _prepare_distributionz8_InstallRequirementBackedCandidate._prepare_distribution   s    !"899r*   c                0   | j                   E| j                   |j                  k7  r,t        | j                  d| j                   |j                        | j                  W| j                  |j
                  k7  r>t        | j                  dt        | j                        t        |j
                              	 t        |j                  t        |j                                            y# t        $ r$}t        | j                  t        |            d}~ww xY w)z:Check for consistency of project name and version of dist.NrA   rF   )rR   rE   r   rQ   rS   rF   r5   listiter_dependenciesiter_provided_extrasr	   r   )rV   rH   es      r(   _check_metadata_consistencyz>_InstallRequirementBackedCandidate._check_metadata_consistency   s    ::!djjD4G4G&G&



##	  ==$$,,)F&

DMM"DLL!	 	6''T-F-F-H(IJK! 	6!$**c!f55	6s   61C( (	D1DDc                   	 | j                         }| j                  |       |S # t        $ r}| j                  |_         d }~wt        $ r}t        | j                  j                  t              r%| j                  j                  j                         }n| j                  j                  }|d}t        | j                  j                  xs t        | j                        ||j                        d }~ww xY w)Nzdirectly requested)package_namerequirement_chainfailed_step)r~   r   rQ   r4   r   r%   r.   r   	from_pathr   rA   r5   rN   command_descriptionr   )rV   rH   r   excrequest_chains        r(   rT   z+_InstallRequirementBackedCandidate._prepare   s    	--/D, 	((.-  	 JJAE* 	$**//1CD $

 5 5 ? ? A $

 5 5$ 4*!ZZ__?DJJ"/33 	s!   % 	C7A  C7B&C22C7c              #  *  K   | j                   j                  | j                  j                         |r| j                  j	                         nd}|D ]9  }| j                   j                  t        |      | j                        E d {    ; y 7 wN )rP    make_requires_python_requirementrH   requires_pythonr   make_requirements_from_specr5   rQ   )rV   with_requiresrequiresrs       r(   r   z4_InstallRequirementBackedCandidate.iter_dependencies  ss      mm<<TYY=V=VWW4A499..0r 	UA}}@@QTTT	UTs   BB	B
Bc                    | j                   S rM   )rQ   r]   s    r(   get_install_requirementz:_InstallRequirementBackedCandidate.get_install_requirement  s    zzr*   NN)r8   r   rW   r   r<   r   rX   r    rA   NormalizedName | NonerF   Version | NonereturnNoner   r5   r   intrl   r   r   boolr   zLink | Noner   r
   r   r   r   r   )rH   r   r   r   r   r   r   zIterable[Requirement | None]r   InstallRequirement | None)rd   
__module____qualname____doc____annotations__is_installedrY   r^   re   rh   rm   propertyrW   rr   rA   rF   r{   r~   r   rT   r   r   r   r*   r(   rK   rK      s     L '+"&&& & !	&
 & $&  & 
&$-A
 ! !   ! !  

:606Ur*   rK   c                  H     e Zd ZdZ	 	 d	 	 	 	 	 	 	 	 	 	 	 d fdZddZ xZS )r#   Fc                D   |}|j                  ||      }|,t        j                  d|j                         |j                  }t	        ||      }|j                  |k(  sJ |j                  j
                  r~|j                  j                  sht        |j                  j                        }	|	j                  }
||
k(  sJ |d|
d       |)t        |	j                        }||k(  sJ |d|d|        ||j                  j
                  sJ |j                  j                  sJ |j                  r|j                  |j                  u r||_        |j                  |j                  |_        nt#        ||j                        |_        t$        | M  ||||||       y )NzUsing cached wheel link: %sz != z
 for wheelz for wheel )link_is_in_wheel_cacher8   rW   r<   rX   rA   rF   )get_wheel_cache_entryloggerdebugr8   r=   is_wheelry   r   filenamerA   r   rF   
persistentr7   cached_wheel_source_linkorigindownload_infor   superrY   )rV   r8   r:   rX   rA   rF   rW   cache_entryr<   wheel
wheel_namewheel_versionrc   s               r(   rY   zLinkCandidate.__init__  s    33KF"LL68H8HI##D)$9yyD   99dii&7&7$)),,-EJ:%N$j^:'NN%" ' 6},H[]$5[GH, "99%%%%99$$$$%%(--8;Q;Q*Q0;-!!-%0%7%7" &:8N8N&" 	# 	 	
r*   c                h    | j                   j                  }|j                  | j                  d      S )NT)parallel_builds)rP   preparerprepare_linked_requirementrQ   )rV   r   s     r(   r~   z#LinkCandidate._prepare_distributionG  s+    ==))224::t2TTr*   r   r8   r   r:   r   rX   r    rA   r   rF   r   r   r   r   rd   r   r   is_editablerY   r~   __classcell__rc   s   @r(   r#   r#     sV    K '+"&/
/
 %/
 	/

 $/
  /
 
/
bUr*   r#   c                  H     e Zd ZdZ	 	 d	 	 	 	 	 	 	 	 	 	 	 d fdZddZ xZS )r"   Tc                D    t         |   ||t        ||      |||       y )Nr   )r   rY   rC   )rV   r8   r:   rX   rA   rF   rc   s         r(   rY   zEditableCandidate.__init__O  s0     	/h? 	 	
r*   c                `    | j                   j                  j                  | j                        S rM   )rP   r   prepare_editable_requirementrQ   r]   s    r(   r~   z'EditableCandidate._prepare_distribution`  s!    }}%%BB4::NNr*   r   r   r   r   r   s   @r(   r"   r"   L  sU    K '+"&

 %
 	

 $
  
 

"Or*   r"   c                      e Zd ZdZdZ	 	 	 	 	 	 	 	 ddZddZddZddZddZ	e
dd       Ze
dd	       Ze
dd
       Ze
dd       ZddZddZddZy)r!   TNc                    || _         t        ||      | _        || _        d | _        d}|j
                  j                  | j                  |       y )Nzalready satisfied)rH   rI   rQ   rP   rS   r   prepare_installed_requirement)rV   rH   r:   rX   skip_reasons        r(   rY   z"AlreadyInstalledCandidate.__init__h  sH     	0x@
 *66tzz;Or*   c                ,    t        | j                        S rM   )r5   rH   r]   s    r(   r^   z!AlreadyInstalledCandidate.__str__z  s    499~r*   c                N    | j                   j                   d| j                  dS r`   )rc   rd   rH   r]   s    r(   re   z"AlreadyInstalledCandidate.__repr__}  s$    ..))*!DII=::r*   c                    t        |t              st        S | j                  |j                  k(  xr | j                  |j                  k(  S rM   )r%   r!   NotImplementedrA   rF   rk   s     r(   rm   z AlreadyInstalledCandidate.__eq__  s8    %!:;!!yyEJJ&H4<<5==+HHr*   c                D    t        | j                  | j                  f      S rM   )rg   rA   rF   r]   s    r(   rh   z"AlreadyInstalledCandidate.__hash__  s    TYY-..r*   c                .    | j                   j                  S rM   )rH   rE   r]   s    r(   rr   z&AlreadyInstalledCandidate.project_name  s    yy'''r*   c                    | j                   S rM   rt   r]   s    r(   rA   zAlreadyInstalledCandidate.name  ro   r*   c                h    | j                   | j                  j                  | _         | j                   S rM   rv   r]   s    r(   rF   z!AlreadyInstalledCandidate.version  rw   r*   c                .    | j                   j                  S rM   )rH   r3   r]   s    r(   r   z%AlreadyInstalledCandidate.is_editable  s    yy!!!r*   c                :    | j                    d| j                   dS )Nr[   z (Installed)r\   r]   s    r(   r{   z*AlreadyInstalledCandidate.format_for_error  s    ))Adll^<88r*   c              #    K   |sy 	 | j                   j                         D ]9  }| j                  j                  t	        |      | j
                        E d {    ; y 7 # t        $ r}t        | j                   |      d d }~ww xY ww)N)rH   invalid_exc)rH   r   rP   r   r5   rQ   r	   r   )rV   r   r   r   s       r(   r   z+AlreadyInstalledCandidate.iter_dependencies  sz     	UYY002 Y==DDSVTZZXXXYX! 	U)tyycJPTT	Us;   B	AA  AA  B	A   	B)BBB	c                     y rM   r   r]   s    r(   r   z1AlreadyInstalledCandidate.get_install_requirement      r*   )rH   r   r:   r   rX   r    r   r   r   )rl   objectr   r   r   r   r   r   r   r   r   )rd   r   r   r   rW   rY   r^   re   rm   rh   r   rr   rA   rF   r   r{   r   r   r   r*   r(   r!   r!   d  s    LKPP %P 	P
 
P$;I
/ ( ( ! !  
 " "9Ur*   r!   c                      e Zd ZdZdd	 	 	 	 	 	 	 ddZddZddZddZddZe	dd	       Z
e	dd
       Ze	dd       ZddZe	dd       Ze	dd       Ze	dd       ZddZddZy)ExtrasCandidatea  A candidate that has 'extras', indicating additional dependencies.

    Requirements can be for a project with dependencies, something like
    foo[extra].  The extras don't affect the project/version being installed
    directly, but indicate that we need additional dependencies. We model that
    by having an artificial ExtrasCandidate that wraps the "base" candidate.

    The ExtrasCandidate differs from the base in the following ways:

    1. It has a unique name, of the form foo[extra]. This causes the resolver
       to treat it as a separate node in the dependency graph.
    2. When we're getting the candidate's dependencies,
       a) We specify that we want the extra dependencies as well.
       b) We add a dependency on the base candidate.
          See below for why this is needed.
    3. We return None for the underlying InstallRequirement, as the base
       candidate will provide it, and we don't want to end up with duplicates.

    The dependency on the base candidate is needed so that the resolver can't
    decide that it should recommend foo[extra1] version 1.0 and foo[extra2]
    version 2.0. Having those candidates depend on foo=1.0 and foo=2.0
    respectively forces the resolver to recognise that this is a conflict.
    N)r.   c                   || _         t        d |D              | _        ||| _        y| j                   j                  | _        y)a  
        :param comes_from: the InstallRequirement that led to this candidate if it
            differs from the base's InstallRequirement. This will often be the
            case in the sense that this candidate's requirement has the extras
            while the base's does not. Unlike the InstallRequirement backed
            candidates, this requirement is used solely for reporting purposes,
            it does not do any leg work.
        c              3  2   K   | ]  }t        |        y wrM   )r   ).0r   s     r(   	<genexpr>z+ExtrasCandidate.__init__.<locals>.<genexpr>  s     E 1! 4E   N)base	frozensetr9   rQ   _comes_from)rV   r   r9   r.   s       r(   rY   zExtrasCandidate.__init__  s9     	EfEE)3)?:TYY__r*   c                    t        | j                        j                  dd      \  }}dj                  |dj	                  | j
                        |      S )Nr[   r   z	{}[{}] {},)r5   r   splitformatjoinr9   )rV   rA   rests      r(   r^   zExtrasCandidate.__str__  sB    ^))#q1
d!!$(=tDDr*   c                h    | j                   j                   d| j                  d| j                  dS )Nz(base=z	, extras=rb   )rc   rd   r   r9   r]   s    r(   re   zExtrasCandidate.__repr__  s/    ..))*&Yt{{oUVWWr*   c                D    t        | j                  | j                  f      S rM   )rg   r   r9   r]   s    r(   rh   zExtrasCandidate.__hash__  s    TYY,--r*   c                    t        || j                        r4| j                  |j                  k(  xr | j                  |j                  k(  S yrj   )r%   rc   r   r9   rk   s     r(   rm   zExtrasCandidate.__eq__  s8    eT^^,99

*Jt{{ell/JJr*   c                .    | j                   j                  S rM   )r   rr   r]   s    r(   rr   zExtrasCandidate.project_name      yy%%%r*   c                V    t        | j                  j                  | j                        S rq   )r   r   rr   r9   r]   s    r(   rA   zExtrasCandidate.name  s     499114;;??r*   c                .    | j                   j                  S rM   )r   rF   r]   s    r(   rF   zExtrasCandidate.version  s    yy   r*   c                    dj                  | j                  j                         dj                  t	        | j
                                    S )Nz{} [{}]z, )r   r   r{   r   sortedr9   r]   s    r(   r{   z ExtrasCandidate.format_for_error  s9    II&&($))F4;;4G*H
 	
r*   c                .    | j                   j                  S rM   )r   r   r]   s    r(   r   zExtrasCandidate.is_installed  r   r*   c                .    | j                   j                  S rM   )r   r   r]   s    r(   r   zExtrasCandidate.is_editable      yy$$$r*   c                .    | j                   j                  S rM   )r   rW   r]   s    r(   rW   zExtrasCandidate.source_link   r   r*   c              #    K   | j                   j                  }|j                  | j                          |sy | j                  j	                  | j                   j
                  j                               }| j                  j                  | j                   j
                  j                               }t        |      D ]8  }t        j                  d| j                   j                  | j                  |       : | j                   j
                  j                  |      D ]0  }|j                  t        |      | j                   |      E d {    2 y 7 w)Nz%%s %s does not provide the extra '%s')r   rP   make_requirement_from_candidater9   intersectionrH   r   
differencer   r   warningrA   rF   r   r   r5   r   )rV   r   rX   valid_extrasinvalid_extrasextrar   s          r(   r   z!ExtrasCandidate.iter_dependencies  s
    ))$$ 55dii@@ {{//		0S0S0UV//		0S0S0UVN+ 	ENN7				 11,? 	A::A    	s   EE
EEc                     y rM   r   r]   s    r(   r   z'ExtrasCandidate.get_install_requirement   s     r*   )r   BaseCandidater9   zfrozenset[str]r.   r   r   r   r   r   r   r   r   r   r   r   r   )rd   r   r   r   rY   r^   re   rh   rm   r   rr   rA   rF   r{   r   r   rW   r   r   r   r*   r(   r   r     s    : 15UU U
 .U 
U&EX.
 & & @ @ ! !

 & & % % % %8r*   r   c                  z    e Zd ZdZdZddZddZddZedd       Z	edd       Z
edd       Zdd	Zdd
ZddZy)RequiresPythonCandidateFNc                    |t        |      }nt        j                  d d }t        dj	                  d |D                    | _        y )N   .c              3  2   K   | ]  }t        |        y wrM   )r5   )r   cs     r(   r   z3RequiresPythonCandidate.__init__.<locals>.<genexpr>0  s     (FAQ(Fr   )r   sysversion_infor   r   rS   )rV   py_version_infor  s      r(   rY   z RequiresPythonCandidate.__init__+  s?    &1/BL++BQ/L(F(F FGr*   c                     d| j                    S NzPython rS   r]   s    r(   r^   zRequiresPythonCandidate.__str__6  s    ((r*   c                N    | j                   j                   d| j                  dS r`   )rc   rd   rS   r]   s    r(   re   z RequiresPythonCandidate.__repr__9  s%    ..))*!DMM+<A>>r*   c                    t         S rM   REQUIRES_PYTHON_IDENTIFIERr]   s    r(   rr   z$RequiresPythonCandidate.project_name<      ))r*   c                    t         S rM   r  r]   s    r(   rA   zRequiresPythonCandidate.name@  r  r*   c                    | j                   S rM   r  r]   s    r(   rF   zRequiresPythonCandidate.versionD  s    }}r*   c                     d| j                    S r  )rF   r]   s    r(   r{   z(RequiresPythonCandidate.format_for_errorH  s    ''r*   c                     yr   r   )rV   r   s     r(   r   z)RequiresPythonCandidate.iter_dependenciesK  s    r*   c                     y rM   r   r]   s    r(   r   z/RequiresPythonCandidate.get_install_requirementN  r   r*   )r  ztuple[int, ...] | Noner   r   r   r   r   r   r   )rd   r   r   r   rW   rY   r^   re   r   rr   rA   rF   r{   r   r   r   r*   r(   r
  r
  '  sg    LKH)? * * * *  (r*   r
  )r&   r   r   zBaseCandidate | None)r8   r   r:   r   r   r   )rH   r   r:   r   r   r   )>
__future__r   loggingr  collections.abcr   typingr   r   r   r   "pip._vendor.packaging.requirementsr	   pip._vendor.packaging.utilsr
   r   pip._vendor.packaging.versionr   pip._internal.exceptionsr   r   r   r   r   r   pip._internal.metadatar   pip._internal.models.linkr   r   pip._internal.models.wheelr   pip._internal.req.constructorsr   r   pip._internal.req.req_installr   &pip._internal.utils.direct_url_helpersr   pip._internal.utils.miscr   r   r   r   r   rX   r    	getLoggerrd   r   r  r  r)   r=   rC   rI   rK   r#   r"   r!   r   r
  r   r*   r(   <module>r0     s6   "  
 $ 2 2 A I 1  4 < , = G ; 5 5 			8	$ ".2QR 	
,.
,,
&8,Q Qh6U6 6UrO: O0D	 DNyi yx(i (r*   