
    )h+              
       :   d dl Z d dlmZ d dlmZmZ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 ddlmZmZmZ ddlmZ dd	lmZ dd
lmZ erd dlmZ d dlmZ eeef   Zeeee f   Z!neZ! ed      Z" ed      Z#dee e#f   de de"dee"e#f   fdZ$ G d de!      Z%y)    N)	lru_cache)
TYPE_CHECKINGDictIterableIteratorMappingOptionalSequenceTupleTypeVarUnion)AbstractProvider)InstallRequirement   )	Candidate
ConstraintRequirement)REQUIRES_PYTHON_IDENTIFIER)Factory)ExplicitRequirement)
Preference)RequirementInformationDVmapping
identifierdefaultreturnc                 X    || v r| |   S |j                  d      \  }}}|r	|| v r| |   S |S )ai  Get item from a package name lookup mapping with a resolver identifier.

    This extra logic is needed when the target mapping is keyed by package
    name, which cannot be directly looked up with an identifier (which may
    contain requested extras). Additional logic is added to also look up a value
    by "cleaning up" the extras from the identifier.
    [)	partition)r   r   r   nameopen_bracket_s         _/var/www/html/venv/lib/python3.12/site-packages/pip/_internal/resolution/resolvelib/provider.py_get_with_identifierr&   :   sH     Wz"" '005D,t}N    c                      e Zd ZdZdedeeef   dededeee	f   ddfd	Z
d
eeef   defdZdee   deeef   deeee   f   deeed   f   ded   dee   fdZdedeeef   deeee   f   deeed   f   ded   ddfdZdedeeee   f   deeee   f   dee   fdZe ed      dededefd              Zdedee   fdZy)PipProvidera  Pip's provider implementation for resolvelib.

    :params constraints: A mapping of constraints specified by the user. Keys
        are canonicalized project names.
    :params ignore_dependencies: Whether the user specified ``--no-deps``.
    :params upgrade_strategy: The user-specified upgrade strategy.
    :params user_requested: A set of canonicalized package names that the user
        supplied for pip to install/upgrade.
    factoryconstraintsignore_dependenciesupgrade_strategyuser_requestedr   Nc                 J    || _         || _        || _        || _        || _        y N)_factory_constraints_ignore_dependencies_upgrade_strategy_user_requested)selfr*   r+   r,   r-   r.   s         r%   __init__zPipProvider.__init__^   s+      '$7!!1-r'   requirement_or_candidatec                     |j                   S r0   )r"   )r6   r8   s     r%   identifyzPipProvider.identifyl   s    ',,,r'   identifiersresolutions
candidatesinformationPreferenceInformationbacktrack_causesc                 8   t               }|D ]Y  }|j                  |j                  j                         |j                  5|j                  |j                  j                         [ g }|D ]&  }	|	t
        k(  r|	gc S |	|v s|j                  |	       ( |r|S |S )a  Produce a subset of identifiers that should be considered before others.

        Currently pip narrows the following selection:
            * Requires-Python, if present is always returned by itself
            * Backtrack causes are considered next because they can be identified
              in linear time here, whereas because get_preference() is called
              for each identifier, it would be quadratic to check for them there.
              Further, the current backtrack causes likely need to be resolved
              before other requirements as a resolution can't be found while
              there is a conflict.
        )setaddrequirementr"   parentr   append)
r6   r;   r<   r=   r>   r@   backtrack_identifiersinfocurrent_backtrack_causesr   s
             r%   narrow_requirement_selectionz(PipProvider.narrow_requirement_selectiono   s    & !$$ 	<D!%%d&6&6&;&;<{{&%))$++*:*:;	<
 $& % 
	J 77"|# 22(//
;
	 $++r'   r   r   c                    	 t        t        ||                d}|sd}d}n t        d ||   D         \  }	}t	        |	      }d |D        D 
cg c]!  }
|
D ]  }|j
                  |j                  f # }}
}t	        d |D              }t	        d |D              }t        |      }| j                  j                  |t        j                        }| | | || |fS # t        $ r d}Y w xY wc c}}
w )a~  Produce a sort key for given requirement based on preference.

        The lower the return value is, the more preferred this group of
        arguments is.

        Currently pip considers the following in order:

        * Any requirement that is "direct", e.g., points to an explicit URL.
        * Any requirement that is "pinned", i.e., contains the operator ``===``
          or ``==`` without a wildcard.
        * Any requirement that imposes an upper version limit, i.e., contains the
          operator ``<``, ``<=``, ``~=``, or ``==`` with a wildcard. Because
          pip prioritizes the latest version, preferring explicit upper bounds
          can rule out infeasible candidates sooner. This does not imply that
          upper bounds are good practice; they can make dependency management
          and resolution harder.
        * Order user-specified requirements as they are specified, placing
          other requirements afterward.
        * Any "non-free" requirement, i.e., one that contains at least one
          operator, such as ``>=`` or ``!=``.
        * Alphabetical order for consistency (aids debuggability).
        TF c              3   h   K   | ]*  \  }}t        |t              |j                         d    f , yw)r   N)
isinstancer   get_candidate_lookup).0rr$   s      r%   	<genexpr>z-PipProvider.get_preference.<locals>.<genexpr>   s8      1  #679O9O9QRS9TUs   02c              3   :   K   | ]  }|s|j                     y wr0   )	specifier)rP   ireqs     r%   rR   z-PipProvider.get_preference.<locals>.<genexpr>   s     !KTd$..!Ks   c              3   >   K   | ]  \  }}|d d dk(  xr d|v  y w)N   ==*rL   rP   opvers      r%   rR   z-PipProvider.get_preference.<locals>.<genexpr>   s*     VSr"1v~;CsN;Vs   c              3   D   K   | ]  \  }}|d v xs |dk(  xr d|v   yw))<z<=z~=rX   rY   NrL   rZ   s      r%   rR   z-PipProvider.get_preference.<locals>.<genexpr>   s7      
C %%E2:+D#*E
s    )nextiterStopIterationzipanyoperatorversionboolr5   getmathinf)r6   r   r<   r=   r>   r@   has_informationdirectireqsdirectsspecifier_setrT   	operatorspinnedupper_boundedunfreerequested_orders                    r%   get_preferencezPipProvider.get_preference   s9   <	#k*-./ #OF>@E
 ! +J 7NGU \F "LU!K,
*,
  !2!23,
3,
	 ,
 VIVV 
$
 
 i..22:txxH JJJ
 	
I  	$ $O	$,,
s   C &C-C*)C*requirementsincompatibilitiesc                      dt         dt        f fd}t         j                  |t	        j
                               } j                  j                  ||| ||       | j                        S )Nr   r   c                 |    j                   dk(  ryj                   dk(  rt        j                  | d      }|duS y)a  Are upgrades allowed for this project?

            This checks the upgrade strategy, and whether the project was one
            that the user specified in the command line, in order to decide
            whether we should upgrade if there's a newer version available.

            (Note that we don't need access to the `--upgrade` flag, because
            an upgrade strategy of "to-satisfy-only" means that `--upgrade`
            was not specified).
            eagerTzonly-if-neededNr   F)r4   r&   r5   )r   
user_orderr6   s     r%   _eligible_for_upgradez7PipProvider.find_matches.<locals>._eligible_for_upgrade   sN     %%0''+;;1(( 

 "--r'   rz   )r   ru   
constraintprefers_installedrv   is_satisfied_by)	strrf   r&   r2   r   emptyr1   find_candidatesr   )r6   r   ru   rv   r|   r}   s   `     r%   find_matcheszPipProvider.find_matches   sx    	c 	d 	, *$$&


 }},,!%!#8#DD/ 00 - 
 	
r'   )maxsizerD   	candidatec                 $    | j                  |      S r0   )r   )rD   r   s     r%   r   zPipProvider.is_satisfied_by  s     **955r'   c                 L    | j                    }d |j                  |      D        S )Nc              3   &   K   | ]	  }||  y wr0   rL   )rP   rQ   s     r%   rR   z/PipProvider.get_dependencies.<locals>.<genexpr>  s     WaWs   )r3   iter_dependencies)r6   r   with_requiress      r%   get_dependencieszPipProvider.get_dependencies  s&     555W966}EWWr'   )__name__
__module____qualname____doc__r   r   r   r   rf   intr7   r   r   r   r:   r   r   r   r
   rJ   rt   r   staticmethodr   r   r   rL   r'   r%   r)   r)   S   s    .. #z/*. "	.
 . S#X. 
.-{I7M1N -SV -)c]) S)^,) C)!445	)
 S(+B"CCD) ##:;) 
#)VK
K
 S)^,K
 C)!445	K

 S(+B"CCDK
 ##:;K
 
K
Z(
(
 c8K#889(
 #3(;#;<	(

 
)	(
T t6[ 6Y 64 6  6X) X8M Xr'   r)   )&rh   	functoolsr   typingr   r   r   r   r   r	   r
   r   r   r    pip._vendor.resolvelib.providersr   pip._internal.req.req_installr   baser   r   r   r=   r   r*   r   ru   r   r    pip._vendor.resolvelib.resolversr   r?   r   _ProviderBaser   r   r&   r)   rL   r'   r%   <module>r      s        > < 4 4 2  -;G2;	3IJ$[)S%@AM$M* CLCLS!V_  1a4[	2FX- FXr'   