
    Q$goM                     F   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 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.          Z/e	d         Z0 e
ed          Z1de(dee0         fdZ2dede"de"fdZ3dede"de"fdZ4dede"de"fdZ5 G d de(          Z6 G d de6          Z7 G d  d!e6          Z8 G d" d#e(          Z9 G d$ d%e(          Z: G d& d'e(          Z;dS )(    N)TYPE_CHECKINGAny	FrozenSetIterableOptionalTupleUnioncast)InvalidRequirement)NormalizedNamecanonicalize_name)Version)	HashErrorInstallationSubprocessError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                 R    t           t          t          f}t          | |          r| S dS )z%The runtime version of BaseCandidate.N)r!   r"   r#   
isinstance)r$   base_candidate_classess     n/var/www/html/netbox-4.1.3/venv/lib/python3.11/site-packages/pip/_internal/resolution/resolvelib/candidates.pyas_base_candidater*   +   s5     	"
 )344 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   r0   r1   r2   r3   r4   r5   r6   r7   original_linkr,   extras)r,   r-   lineireqs       r)   make_install_req_from_linkr@   7   s      88"8888| 8<  x ,&&"&.* 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)	r0   r1   r2   r3   r4   permit_editable_wheelsr5   r6   r7   )r8   r   r;   r0   r1   r2   r3   r4   rB   r5   r6   r7   r=   )r,   r-   r?   s      r)   make_install_req_from_editablerC   P   s{     555555$,&&"&'>.* 0  D /DKKr+   distc                 *   |j         rt          |j                   }n/|j        r| j         d|j        j         }n| j         d| j         }t          ||j        |j        |j	        |j
        |j        |j        |j        |j        	  	        }| |_        |S )Nz @ z==r/   )r9   r:   r,   canonical_namer;   versionr   r0   r1   r2   r3   r4   r5   r6   r7   satisfied_by)rD   r-   r>   r?   s       r)   _make_install_req_from_distrI   d   s     | 88<  	 8%==(-*;==%7777 ,&&"&.* 0
 
 
D DKr+   c                      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!dS )"_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).
    rD   FNr,   source_linkr?   factoryr    namerG   r%   c                     || _         || _        || _        || _        || _        || _        |                                 | _        d | _        d S N)	_link_source_link_factory_ireq_name_version_preparerD   _hash)selfr,   rL   r?   rM   rN   rG   s          r)   __init__z+_InstallRequirementBackedCandidate.__init__   sI     
'

MMOO	$(


r+   c                 $    | j          d| j         S )N rN   rG   rY   s    r)   __str__z*_InstallRequirementBackedCandidate.__str__   s    ),,dl,,,r+   c                 J    | j         j         dt          | j                  dS N())	__class____name__r:   rQ   r^   s    r)   __repr__z+_InstallRequirementBackedCandidate.__repr__   s&    .)@@C
OO@@@@r+   c                 l    | j         | j         S t          | j        | j        f          | _         | j         S rP   )rX   hashrd   rQ   r^   s    r)   __hash__z+_InstallRequirementBackedCandidate.__hash__   s2    :!:4>4:677
zr+   otherc                 d    t          || j                  rt          | j        |j                  S dS NF)r'   rd   r   rQ   rY   rj   s     r)   __eq__z)_InstallRequirementBackedCandidate.__eq__   s/    eT^,, 	=#DJ<<<ur+   c                     | j         S rP   )rR   r^   s    r)   rL   z._InstallRequirementBackedCandidate.source_link         r+   c                 @    | j         | j        j        | _         | j         S z:The normalised name of the project the candidate refers to)rU   rD   rF   r^   s    r)   project_namez/_InstallRequirementBackedCandidate.project_name   s      :1DJzr+   c                     | j         S rP   rs   r^   s    r)   rN   z'_InstallRequirementBackedCandidate.name   rp   r+   c                 @    | j         | j        j        | _         | j         S rP   rV   rD   rG   r^   s    r)   rG   z*_InstallRequirementBackedCandidate.version       =  I-DM}r+   c                 f    | j          d| j         d| j        j        r| j        j        n| j         dS )Nr\   z (from rc   )rN   rG   rQ   is_file	file_pathr^   s    r)   format_for_errorz3_InstallRequirementBackedCandidate.format_for_error   sS    y S S4< S S-1Z-?OTZ))TZS S S	
r+   c                      t          d          )NzOverride in subclass)NotImplementedErrorr^   s    r)   _prepare_distributionz8_InstallRequirementBackedCandidate._prepare_distribution   s    !"8999r+   c                    | j         1| j         |j        k    r!t          | j        d| j         |j                  | j        K| j        |j        k    r;t          | j        dt          | j                  t          |j                            	 t          |                    t          |	                                                               dS # t          $ r'}t          | j        t          |                    d}~ww xY w)z:Check for consistency of project name and version of dist.NrN   rG   )rU   rF   r   rT   rV   rG   r:   listiter_dependenciesiter_provided_extrasr   r   )rY   rD   es      r)   _check_metadata_consistencyz>_InstallRequirementBackedCandidate._check_metadata_consistency   s    :!djD4G&G&G&

#	   =$$,)F)F&
DM""DL!!	  	6''T-F-F-H-H(I(IJJKKKKK! 	6 	6 	6!$*c!ff555	6s   AC 
D "C;;D c                     	 |                                  }n4# t          $ r}| j        |_         d }~wt          $ r}d|_         d }~ww xY w|                     |           |S )NzSee above for output.)r   r   rT   r9   r   contextr   )rY   rD   r   excs       r)   rW   z+_InstallRequirementBackedCandidate._prepare   s    	--//DD 	 	 	 JAE* 	 	 	1CK	
 	((...s    
A.AAAwith_requiresc              #      K   |r| j                                         nd}|D ]5}| j                            t	          |          | j                  E d {V  6| j                            | j         j                  V  d S N )rD   r   rS   make_requirements_from_specr:   rT    make_requires_python_requirementrequires_python)rY   r   requiresrs       r)   r   z4_InstallRequirementBackedCandidate.iter_dependencies   s      4AI49..000r 	U 	UA}@@QTTTTTTTTTTm<<TY=VWWWWWWWr+   c                     | j         S rP   )rT   r^   s    r)   get_install_requirementz:_InstallRequirementBackedCandidate.get_install_requirement   s
    zr+   NN)"re   
__module____qualname____doc__r   __annotations__is_installedr   r   r   r   r   rZ   r:   r_   rf   intri   r   boolrn   propertyrL   rs   rN   rG   r|   r   r   rW   r   r   r   r   r   r+   r)   rK   rK   |   s          L *.%)) )) ) !	)
 ) ~&) '") 
) ) ) )$- - - - -A# A A A A#    C D    
 !Xd^ ! ! ! X! n    X !c ! ! ! X!     X

# 
 
 
 
:'7 : : : :60@ 6T 6 6 6 60*    "Xt X+AV8W X X X X2D)E      r+   rK   c                   f     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-   rM   r    rN   rG   r%   c                    |}|                     ||          }|'t                              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|             |g|j        j        sJ |j        j        sJ |j        r|j        |j        u r||_        |j        |j        |_        nt%          ||j                  |_        t'                                          ||||||           d S )NzUsing cached wheel link: %sz != z
 for wheelz for wheel )link_is_in_wheel_cacher,   rL   r?   rM   rN   rG   )get_wheel_cache_entryloggerdebugr,   r@   is_wheelrz   r   filenamer   rN   r   rG   
persistentr<   cached_wheel_source_linkorigindownload_infor   superrZ   )rY   r,   r-   rM   rN   rG   rL   cache_entryr?   wheel
wheel_namewheel_versionrd   s               r)   rZ   zLinkCandidate.__init__  s    33KFF"LL68HIII#D)$99yD    9 		Hdi&7 		H$),--E*5:66J:%%%$'N'Nj'N'N'N%%%" ' 6 6},,,GG]GGGG -,, "9%%%%9$$$$% <(-8;Q*Q*Q0;-!-%0%7"" &:8N& & &" 	# 	 	
 	
 	
 	
 	
r+   c                 R    | j         j        }|                    | j        d          S )NT)parallel_builds)rS   preparerprepare_linked_requirementrT   )rY   r   s     r)   r   z#LinkCandidate._prepare_distribution8  s'    =)224:t2TTTr+   r   re   r   r   is_editabler   r   r   r   r   rZ   r   r   __classcell__rd   s   @r)   r#   r#     s        K *.%)/
 /
/
 %/
 	/

 ~&/
 '"/
 
/
 /
 /
 /
 /
 /
bU'7 U U U U U U U Ur+   r#   c                   f     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-   rM   r    rN   rG   r%   c                 r    t                                          ||t          ||          |||           d S )Nr   )r   rZ   rC   )rY   r,   r-   rM   rN   rG   rd   s         r)   rZ   zEditableCandidate.__init__@  sL     	/h?? 	 	
 	
 	
 	
 	
r+   c                 J    | j         j                            | j                  S rP   )rS   r   prepare_editable_requirementrT   r^   s    r)   r   z'EditableCandidate._prepare_distributionQ  s    }%BB4:NNNr+   r   r   r   s   @r)   r"   r"   =  s        K *.%)
 

 %
 	

 ~&
 '"
 

 
 
 
 
 
"O'7 O O O O O O O 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dS )r!   TNrD   r-   rM   r    r%   c                     || _         t          ||          | _        || _        d | _        d}|j                            | j        |           d S )Nzalready satisfied)rD   rI   rT   rS   rV   r   prepare_installed_requirement)rY   rD   r-   rM   skip_reasons        r)   rZ   z"AlreadyInstalledCandidate.__init__Y  sR     	0x@@
 *66tz;OOOOOr+   c                 *    t          | j                  S rP   )r:   rD   r^   s    r)   r_   z!AlreadyInstalledCandidate.__str__k  s    49~~r+   c                 0    | j         j         d| j        dS ra   )rd   re   rD   r^   s    r)   rf   z"AlreadyInstalledCandidate.__repr__n  s     .)::DI::::r+   rj   c                 z    t          |t                    st          S | j        |j        k    o| j        |j        k    S rP   )r'   r!   NotImplementedrN   rG   rm   s     r)   rn   z AlreadyInstalledCandidate.__eq__q  s8    %!:;; 	"!!yEJ&H4<5=+HHr+   c                 8    t          | j        | j        f          S rP   )rh   rN   rG   r^   s    r)   ri   z"AlreadyInstalledCandidate.__hash__v  s    TY-...r+   c                     | j         j        S rP   )rD   rF   r^   s    r)   rs   z&AlreadyInstalledCandidate.project_namey  s    y''r+   c                     | j         S rP   ru   r^   s    r)   rN   zAlreadyInstalledCandidate.name}  rp   r+   c                 @    | j         | j        j        | _         | j         S rP   rw   r^   s    r)   rG   z!AlreadyInstalledCandidate.version  rx   r+   c                     | j         j        S rP   )rD   r8   r^   s    r)   r   z%AlreadyInstalledCandidate.is_editable  s    y!!r+   c                 &    | j          d| j         dS )Nr\   z (Installed)r]   r^   s    r)   r|   z*AlreadyInstalledCandidate.format_for_error  s    )88dl8888r+   r   c              #      K   |sd S | j                                         D ]5}| j                            t	          |          | j                  E d {V  6d S rP   )rD   r   rS   r   r:   rT   )rY   r   r   s      r)   r   z+AlreadyInstalledCandidate.iter_dependencies  ss       	F,,.. 	U 	UA}@@QTTTTTTTTTT	U 	Ur+   c                     d S rP   r   r^   s    r)   r   z1AlreadyInstalledCandidate.get_install_requirement      tr+   )re   r   r   r   rL   r   r   rZ   r:   r_   rf   objectr   rn   r   ri   r   r   rs   rN   r   rG   r   r|   r   r   r   r   r   r   r+   r)   r!   r!   U  s       LKPP %P 	P
 
P P P P$    ;# ; ; ; ;IF It I I I I
/# / / / / (n ( ( ( X( !c ! ! ! X!     X
 "T " " " X"9# 9 9 9 9Ut U+AV8W U U U U2D)E      r+   r!   c            	       |   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dS )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)r1   baser=   r1   r%   c                z    || _         t          d |D                       | _        ||n| j         j        | _        dS )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   4   K   | ]}t          |          V  d S rP   )r   ).0r   s     r)   	<genexpr>z+ExtrasCandidate.__init__.<locals>.<genexpr>  s+      EE 1! 4 4EEEEEEr+   N)r   	frozensetr=   rT   _comes_from)rY   r   r=   r1   s       r)   rZ   zExtrasCandidate.__init__  sD     	EEfEEEEE)3)?::TY_r+   c                     t          | j                                      dd          \  }}d                    |d                    | j                  |          S )Nr\   r   z	{}[{}] {},)r:   r   splitformatjoinr=   )rY   rN   rests      r)   r_   zExtrasCandidate.__str__  sI    ^^))#q11
d!!$(=(=tDDDr+   c                 @    | j         j         d| j        d| j        dS )Nz(base=z	, extras=rc   )rd   re   r   r=   r^   s    r)   rf   zExtrasCandidate.__repr__  s*    .)WWWWt{WWWWr+   c                 8    t          | j        | j        f          S rP   )rh   r   r=   r^   s    r)   ri   zExtrasCandidate.__hash__  s    TY,---r+   rj   c                 p    t          || j                  r | j        |j        k    o| j        |j        k    S dS rl   )r'   rd   r   r=   rm   s     r)   rn   zExtrasCandidate.__eq__  s9    eT^,, 	K9
*Jt{el/JJur+   c                     | j         j        S rP   )r   rs   r^   s    r)   rs   zExtrasCandidate.project_name      y%%r+   c                 @    t          | j        j        | j                  S rr   )r   r   rs   r=   r^   s    r)   rN   zExtrasCandidate.name  s     4914;???r+   c                     | j         j        S rP   )r   rG   r^   s    r)   rG   zExtrasCandidate.version  s    y  r+   c                     d                     | j                                        d                    t	          | j                                      S )Nz{} [{}]z, )r   r   r|   r   sortedr=   r^   s    r)   r|   z ExtrasCandidate.format_for_error  sC    I&&(($))F4;4G4G*H*H
 
 	
r+   c                     | j         j        S rP   )r   r   r^   s    r)   r   zExtrasCandidate.is_installed  r   r+   c                     | j         j        S rP   )r   r   r^   s    r)   r   zExtrasCandidate.is_editable      y$$r+   c                     | j         j        S rP   )r   rL   r^   s    r)   rL   zExtrasCandidate.source_link  r   r+   r   c              #   X  K   | j         j        }|                    | j                   V  |sd S | j                            | j         j                                                  }| j                            | j         j                                                  }t          |          D ].}t          
                    d| j         j        | j        |           /| j         j                            |          D ]1}|                    t          |          | j        |          E d {V  2d S )Nz%%s %s does not provide the extra '%s')r   rS   make_requirement_from_candidater=   intersectionrD   r   
differencer   r   warningrN   rG   r   r   r:   r   )rY   r   rM   valid_extrasinvalid_extrasextrar   s          r)   r   z!ExtrasCandidate.iter_dependencies  sE     )$ 55di@@@@@ 	F {//	0S0S0U0UVV//	0S0S0U0UVVN++ 	 	ENN7		    11,?? 	 	A::A          	 	r+   c                     d S rP   r   r^   s    r)   r   z'ExtrasCandidate.get_install_requirement  s	     tr+   ) re   r   r   r   BaseCandidater   r:   r   r   rZ   r_   rf   r   ri   r   r   rn   r   r   rs   rN   r   rG   r|   r   r   r   rL   r   r   r   r   r   r+   r)   r   r     sS        : 48U U UU #U
 /0U 
U U U U&E E E E EX# X X X X.# . . . .C D    
 &n & & & X& @c @ @ @ X@ ! ! ! ! X!
# 
 
 
 

 &d & & & X& %T % % % X% %Xd^ % % % X%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
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dS )RequiresPythonCandidateFNpy_version_info.r%   c                     |t          |          }nt          j        d d         }t          d                    d |D                                 | _        d S )N   .c              3   4   K   | ]}t          |          V  d S rP   )r:   )r   cs     r)   r   z3RequiresPythonCandidate.__init__.<locals>.<genexpr>  s(      (F(FAQ(F(F(F(F(F(Fr+   )r   sysversion_infor   r   rV   )rY   r   r   s      r)   rZ   z RequiresPythonCandidate.__init__  sV    &1/BBLL+BQB/L(F(F(F(F(F F FGGr+   c                     d| j          S NzPython rV   r^   s    r)   r_   zRequiresPythonCandidate.__str__#  s    ((((r+   c                     t           S rP   REQUIRES_PYTHON_IDENTIFIERr^   s    r)   rs   z$RequiresPythonCandidate.project_name&      ))r+   c                     t           S rP   r  r^   s    r)   rN   zRequiresPythonCandidate.name*  r  r+   c                     | j         S rP   r   r^   s    r)   rG   zRequiresPythonCandidate.version.  s
    }r+   c                     d| j          S r   )rG   r^   s    r)   r|   z(RequiresPythonCandidate.format_for_error2  s    ''''r+   r   c                     dS r   r   )rY   r   s     r)   r   z)RequiresPythonCandidate.iter_dependencies5  s    rr+   c                     d S rP   r   r^   s    r)   r   z/RequiresPythonCandidate.get_install_requirement8  r   r+   )re   r   r   r   rL   r   r   r   rZ   r:   r_   r   r   rs   rN   r   rG   r|   r   r   r   r   r   r   r   r+   r)   r   r     sK       LKHsCx(A Hd H H H H) ) ) ) ) *n * * * X* *c * * * X*     X(# ( ( ( (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   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   rM   r    	getLoggerre   r   r   r  r*   r@   rC   rI   rK   r#   r"   r!   r   r   r   r+   r)   <module>r     s    



 X X X X X X X X X X X X X X X X X X X X A A A A A A I I I I I I I I 1 1 1 1 1 1            4 3 3 3 3 3 < < < < < < < < , , , , , ,        = < < < < < G G G G G G ; ; ; ; ; ; 5 5 5 5 5 5 5 5 5 5 !      		8	$	$ "T.2QRR 	 	x/F 	 	 	 	
,   2
,   (
&8   0E E E E E E E EP6U 6U 6U 6U 6U6 6U 6U 6UrO O O O O: O O O0@ @ @ @ @	 @ @ @Fy y y y yi y y yx% % % % %i % % % % %r+   