
    )hO                        d dl Z d dlZd dlmZmZ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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\                  e/      Z0e	d   Z1 e
ed      Z2de)dee1   fdZ3dede#de#fdZ4dede#de#fdZ5dede#de#fdZ6 G d de)      Z7 G d de7      Z8 G d  d!e7      Z9 G d" d#e)      Z: G d$ d%e)      Z; G d& d'e)      Z<y)(    N)TYPE_CHECKINGAny	FrozenSetIterableOptionalTupleUnioncast)InvalidRequirement)NormalizedNamecanonicalize_name)Version)	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>	candidatereturnc                 B    t         t        t        f}t        | |      r| S y)z%The runtime version of BaseCandidate.N)r"   r#   r$   
isinstance)r%   base_candidate_classess     a/var/www/html/venv/lib/python3.12/site-packages/pip/_internal/resolution/resolvelib/candidates.pyas_base_candidater+   ,   s+     	"
 )34    linktemplatec                    |j                   rJ d       |j                  rt        |j                        }n| j                  }t	        ||j
                  |j                  |j                  |j                  |j                  |j                  |j                  |j                  	      }|j                  |_        | |_        |j                  |_        |S )Nztemplate is editableuser_supplied
comes_from
use_pep517isolated
constraintglobal_optionshash_optionsconfig_settings)editablereqstrurlr   r1   r2   r3   r4   r5   r6   r7   r8   original_linkr-   extras)r-   r.   lineireqs       r*   make_install_req_from_linkrA   8   s       8"88 ||8<< xx ,,&&&&""&&..** 00
D "//DDI//DKKr,   c                 @   |j                   sJ d       t        | j                  |j                  |j                  |j
                  |j                  |j                  |j                  |j                  |j                  |j                  
      }|j                  |_        |S )Nztemplate not editable)	r1   r2   r3   r4   r5   permit_editable_wheelsr6   r7   r8   )r9   r   r<   r1   r2   r3   r4   r5   rC   r6   r7   r8   r>   )r-   r.   r@   s      r*   make_install_req_from_editablerD   Q   s     555$,,&&&&""&&'>>..** 00D //DKKr,   distc                    |j                   rt        |j                         }nM|j                  r&| j                   d|j                  j                   }n| j                   d| j
                   }t        ||j                  |j                  |j                  |j                  |j                  |j                  |j                  |j                  	      }| |_        |S )Nz @ z==r0   )r:   r;   r-   canonical_namer<   versionr   r1   r2   r3   r4   r5   r6   r7   r8   satisfied_by)rE   r.   r?   r@   s       r*   _make_install_req_from_distrJ   e   s     ||8<< 	%%&c(--*;*;)<=%%&b7 ,,&&&&""&&..** 00
D DKr,   c                   J   e Zd ZU dZeed<   dZ	 	 ddedededd	d
e	e
   de	e   ddfdZdefdZdefdZdefdZdedefdZede	e   fd       Zede
fd       Zedefd       Zedefd       ZdefdZdefdZdeddfdZdefdZdedee	e      fdZ de	e   f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).
    rE   FNr-   source_linkr@   factoryr!   namerH   r&   c                     || _         || _        || _        || _        || _        || _        | j                         | _        d | _        y N)	_link_source_link_factory_ireq_name_version_preparerE   _hash)selfr-   rM   r@   rN   rO   rH   s          r*   __init__z+_InstallRequirementBackedCandidate.__init__   sC     
'

MMO	$(
r,   c                 8    | j                    d| j                   S )N rO   rH   rZ   s    r*   __str__z*_InstallRequirementBackedCandidate.__str__   s    ))Adll^,,r,   c                 `    | j                   j                   dt        | j                        dS N())	__class____name__r;   rR   r_   s    r*   __repr__z+_InstallRequirementBackedCandidate.__repr__   s)    ..))*!C

O+>a@@r,   c                     | j                   | j                   S t        | j                  | j                  f      | _         | j                   S rQ   )rY   hashre   rR   r_   s    r*   __hash__z+_InstallRequirementBackedCandidate.__hash__   s9    ::!::4>>4::67
zzr,   otherc                 p    t        || j                        r t        | j                  |j                        S yNF)r(   re   r   rR   rZ   rk   s     r*   __eq__z)_InstallRequirementBackedCandidate.__eq__   s(    eT^^,#DJJ<<r,   c                     | j                   S rQ   )rS   r_   s    r*   rM   z._InstallRequirementBackedCandidate.source_link          r,   c                 h    | j                   | j                  j                  | _         | j                   S z:The normalised name of the project the candidate refers to)rV   rE   rG   r_   s    r*   project_namez/_InstallRequirementBackedCandidate.project_name   s)     ::11DJzzr,   c                     | j                   S rQ   rt   r_   s    r*   rO   z'_InstallRequirementBackedCandidate.name   rq   r,   c                 h    | j                   | j                  j                  | _         | j                   S rQ   rW   rE   rH   r_   s    r*   rH   z*_InstallRequirementBackedCandidate.version   '    ==  II--DM}}r,   c                     | j                    d| j                   d| j                  j                  r| j                  j                   dS | j                   dS )Nr]   z (from rd   )rO   rH   rR   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.NrO   rH   )rV   rG   r   rU   rW   rH   r;   listiter_dependenciesiter_provided_extrasr   r   )rZ   rE   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}d|_         d }~ww xY w)NzSee above for output.)r   r   rU   r:   r   contextr   )rZ   rE   r   excs       r*   rX   z+_InstallRequirementBackedCandidate._prepare   s_    	--/D 	((.  	 JJAE* 	1CK	s    % 	AA  AAAwith_requiresc              #   *  K   | j                   j                  | j                  j                         |r| j                  j	                         nd}|D ]9  }| j                   j                  t        |      | j                        E d {    ; y 7 wN )rT    make_requires_python_requirementrE   requires_pythonr   make_requirements_from_specr;   rU   )rZ   r   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 rQ   )rU   r_   s    r*   get_install_requirementz:_InstallRequirementBackedCandidate.get_install_requirement  s    zzr,   NN)"rf   
__module____qualname____doc__r   __annotations__is_installedr   r   r   r   r   r[   r;   r`   rg   intrj   r   boolro   propertyrM   rt   rO   rH   r}   r   r   rX   r   r   r   r   r   r,   r*   rL   rL   }   s    L *.%))) ) !	)
 ) ~&) '") 
)$- -A# A# C D 
 !Xd^ ! ! n   !c ! !   

# 
:'7 :60@ 6T 60* "Ut U+AV8W U2D)E r,   rL   c                   Z     e Zd ZdZ	 	 ddededddee   dee   d	df fd
Z	d	e
fdZ xZS )r$   FNr-   r.   rN   r!   rO   rH   r&   c                 V   |}|j                  ||      }|,t        j                  d|j                         |j                  }t	        ||      }|j                  |k(  sJ |j                  j
                  r|j                  j                  sqt        |j                  j                        }	t        |	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&        | Q  ||||||       y )NzUsing cached wheel link: %sz != z
 for wheelz for wheel )link_is_in_wheel_cacher-   rM   r@   rN   rO   rH   )get_wheel_cache_entryloggerdebugr-   rA   is_wheelr{   r   filenamer   rO   r   rH   
persistentr=   cached_wheel_source_linkorigindownload_infor   superr[   )rZ   r-   r.   rN   rO   rH   rM   cache_entryr@   wheel
wheel_namewheel_versionre   s               r*   r[   zLinkCandidate.__init__
  s    33KF"LL68H8HI##D)$9yyD   99dii&7&7$)),,-E*5::6J:%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)rT   preparerprepare_linked_requirementrU   )rZ   r   s     r*   r   z#LinkCandidate._prepare_distribution;  s+    ==))224::t2TTr,   r   rf   r   r   is_editabler   r   r   r   r   r[   r   r   __classcell__re   s   @r*   r$   r$     si    K *.%)/
/
 %/
 	/

 ~&/
 '"/
 
/
bU'7 Ur,   r$   c                   Z     e Zd ZdZ	 	 ddededddee   dee   d	df fd
Z	d	e
fdZ xZS )r#   TNr-   r.   rN   r!   rO   rH   r&   c                 D    t         |   ||t        ||      |||       y )Nr   )r   r[   rD   )rZ   r-   r.   rN   rO   rH   re   s         r*   r[   zEditableCandidate.__init__C  s0     	/h? 	 	
r,   c                 `    | j                   j                  j                  | j                        S rQ   )rT   r   prepare_editable_requirementrU   r_   s    r*   r   z'EditableCandidate._prepare_distributionT  s!    }}%%BB4::NNr,   r   r   r   s   @r*   r#   r#   @  sh    K *.%)

 %
 	

 ~&
 '"
 

"O'7 Or,   r#   c                       e Zd ZdZdZdededdddfdZdefd	Z	defd
Z
dedefdZdefdZedefd       Zedefd       Zedefd       Zedefd       ZdefdZdedeee      fdZdee   fdZy)r"   TNrE   r.   rN   r!   r&   c                     || _         t        ||      | _        || _        d | _        d}|j
                  j                  | j                  |       y )Nzalready satisfied)rE   rJ   rU   rT   rW   r   prepare_installed_requirement)rZ   rE   r.   rN   skip_reasons        r*   r[   z"AlreadyInstalledCandidate.__init__\  sH     	0x@
 *66tzz;Or,   c                 ,    t        | j                        S rQ   )r;   rE   r_   s    r*   r`   z!AlreadyInstalledCandidate.__str__n  s    499~r,   c                 N    | j                   j                   d| j                  dS rb   )re   rf   rE   r_   s    r*   rg   z"AlreadyInstalledCandidate.__repr__q  s$    ..))*!DII=::r,   rk   c                     t        |t              st        S | j                  |j                  k(  xr | j                  |j                  k(  S rQ   )r(   r"   NotImplementedrO   rH   rn   s     r*   ro   z AlreadyInstalledCandidate.__eq__t  s8    %!:;!!yyEJJ&H4<<5==+HHr,   c                 D    t        | j                  | j                  f      S rQ   )ri   rO   rH   r_   s    r*   rj   z"AlreadyInstalledCandidate.__hash__y  s    TYY-..r,   c                 .    | j                   j                  S rQ   )rE   rG   r_   s    r*   rt   z&AlreadyInstalledCandidate.project_name|  s    yy'''r,   c                     | j                   S rQ   rv   r_   s    r*   rO   zAlreadyInstalledCandidate.name  rq   r,   c                 h    | j                   | j                  j                  | _         | j                   S rQ   rx   r_   s    r*   rH   z!AlreadyInstalledCandidate.version  ry   r,   c                 .    | j                   j                  S rQ   )rE   r9   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,   r   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)rE   invalid_exc)rE   r   rT   r   r;   rU   r   r   )rZ   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 rQ   r   r_   s    r*   r   z1AlreadyInstalledCandidate.get_install_requirement      r,   )rf   r   r   r   rM   r   r   r[   r;   r`   rg   objectr   ro   r   rj   r   r   rt   rO   r   rH   r   r}   r   r   r   r   r   r   r,   r*   r"   r"   X  s    LKPP %P 	P
 
P$ ;# ;IF It I
/# / (n ( ( !c ! !   
 "T " "9# 9Ut U+AV8W U2D)E r,   r"   c            	       2   e Zd ZdZdddedee   dee   ddfdZ	defd	Z
defd
ZdefdZdedefdZedefd       Zedefd       Zedefd       ZdefdZedefd       Zedefd       Zedee   fd       Zdedeee      fdZdee   f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)r2   baser>   r2   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rQ   )r   ).0r   s     r*   	<genexpr>z+ExtrasCandidate.__init__.<locals>.<genexpr>  s     E 1! 4E   N)r   	frozensetr>   rU   _comes_from)rZ   r   r>   r2   s       r*   r[   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	{}[{}] {},)r;   r   splitformatjoinr>   )rZ   rO   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=rd   )re   rf   r   r>   r_   s    r*   rg   zExtrasCandidate.__repr__  s/    ..))*&Yt{{oUVWWr,   c                 D    t        | j                  | j                  f      S rQ   )ri   r   r>   r_   s    r*   rj   zExtrasCandidate.__hash__  s    TYY,--r,   rk   c                     t        || j                        r4| j                  |j                  k(  xr | j                  |j                  k(  S yrm   )r(   re   r   r>   rn   s     r*   ro   zExtrasCandidate.__eq__  s8    eT^^,99

*Jt{{ell/JJr,   c                 .    | j                   j                  S rQ   )r   rt   r_   s    r*   rt   zExtrasCandidate.project_name      yy%%%r,   c                 V    t        | j                  j                  | j                        S rs   )r    r   rt   r>   r_   s    r*   rO   zExtrasCandidate.name  s     499114;;??r,   c                 .    | j                   j                  S rQ   )r   rH   r_   s    r*   rH   zExtrasCandidate.version  s    yy   r,   c                     dj                  | j                  j                         dj                  t	        | j
                                    S )Nz{} [{}]z, )r   r   r}   r   sortedr>   r_   s    r*   r}   z ExtrasCandidate.format_for_error  s9    II&&($))F4;;4G*H
 	
r,   c                 .    | j                   j                  S rQ   )r   r   r_   s    r*   r   zExtrasCandidate.is_installed  r   r,   c                 .    | j                   j                  S rQ   )r   r   r_   s    r*   r   zExtrasCandidate.is_editable      yy$$$r,   c                 .    | j                   j                  S rQ   )r   rM   r_   s    r*   rM   zExtrasCandidate.source_link  r   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   rT   make_requirement_from_candidater>   intersectionrE   r   
differencer   r   warningrO   rH   r   r   r;   r   )rZ   r   rN   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 rQ   r   r_   s    r*   r   z'ExtrasCandidate.get_install_requirement  s     r,   ) rf   r   r   r   BaseCandidater   r;   r   r   r[   r`   rg   r   rj   r   r   ro   r   r   rt   rO   r   rH   r}   r   r   r   rM   r   r   r   r   r   r,   r*   r   r     se   : 48UU #U
 /0U 
U&E EX# X.# .C D 
 &n & & @c @ @ ! ! !
# 

 &d & & %T % % %Xd^ % %t +AV8W 82D)E r,   r   c                       e Zd ZdZdZdeeedf      ddfdZde	fdZ
de	fdZedefd	       Zede	fd
       Zedefd       Zde	fdZdedeee      fdZdee   fdZy)RequiresPythonCandidateFNpy_version_info.r&   c                     |t        |      }nt        j                  d d }t        dj	                  d |D                    | _        y )N   .c              3   2   K   | ]  }t        |        y wrQ   )r;   )r   cs     r*   r   z3RequiresPythonCandidate.__init__.<locals>.<genexpr>$  s     (FAQ(Fr   )r   sysversion_infor   r   rW   )rZ   r   r   s      r*   r[   z RequiresPythonCandidate.__init__  s?    &1/BL++BQ/L(F(F FGr,   c                      d| j                    S NzPython rW   r_   s    r*   r`   zRequiresPythonCandidate.__str__*  s    ((r,   c                 N    | j                   j                   d| j                  dS rb   )re   rf   rW   r_   s    r*   rg   z RequiresPythonCandidate.__repr__-  s%    ..))*!DMM+<A>>r,   c                     t         S rQ   REQUIRES_PYTHON_IDENTIFIERr_   s    r*   rt   z$RequiresPythonCandidate.project_name0      ))r,   c                     t         S rQ   r  r_   s    r*   rO   zRequiresPythonCandidate.name4  r  r,   c                     | j                   S rQ   r  r_   s    r*   rH   zRequiresPythonCandidate.version8  s    }}r,   c                      d| j                    S r  )rH   r_   s    r*   r}   z(RequiresPythonCandidate.format_for_error<  s    ''r,   r   c                      yr   r   )rZ   r   s     r*   r   z)RequiresPythonCandidate.iter_dependencies?  s    r,   c                      y rQ   r   r_   s    r*   r   z/RequiresPythonCandidate.get_install_requirementB  r   r,   )rf   r   r   r   rM   r   r   r   r[   r;   r`   rg   r   r   rt   rO   r   rH   r}   r   r   r   r   r   r   r   r,   r*   r   r     s    LKHsCx(A Hd H) )?# ? *n * * *c * *   (# (t +AV8W 2D)E r,   r   )=loggingr   typingr   r   r   r   r   r   r	   r
   "pip._vendor.packaging.requirementsr   pip._vendor.packaging.utilsr   r   pip._vendor.packaging.versionr   pip._internal.exceptionsr   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    rN   r!   	getLoggerrf   r   r   r  r+   rA   rD   rJ   rL   r$   r#   r"   r   r   r   r,   r*   <module>r     sF    
 X X X A I 1  4 < , = G ; 5 5 			8	$ ".2QR 	 	x/F 	
,2
,(
&80G GT6U6 6UrO: O0D	 DNyi yx(i (r,   