
    fl                     J   d dl Z 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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 d dlmZ d dlmZ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, d dl-m.Z. d dl/m0Z0 d dl1m2Z2m3Z3 d dl4m5Z5 d dl6m7Z7 d dl8m9Z9 d dl:m;Z; d dl<m=Z= ddl>m?Z?m@Z@mAZAmBZB ddlCmDZDmEZEmFZFmGZGmHZHmIZImJZJ ddlKmLZLmMZM ddlNmOZOmPZPmQZQmRZR erd dlmSZS  G d deS      ZT ej                  eV      ZW ed      ZXee*eXf   ZY G d de      ZZ G d  d!      Z[y)"    N)TYPE_CHECKINGDict	FrozenSetIterableIteratorListMapping
NamedTupleOptionalSequenceSetTupleTypeVarcast)InvalidRequirement)SpecifierSet)NormalizedNamecanonicalize_name)ResolutionImpossible)
CacheEntry
WheelCache)DistributionNotFoundInstallationErrorMetadataInconsistentUnsupportedPythonVersionUnsupportedWheel)PackageFinder)BaseDistributionget_default_environment)Link)Wheel)RequirementPreparer)install_req_from_link_and_ireq)InstallRequirementcheck_invalid_constraint_type)InstallRequirementProvider)get_supported)Hashes)get_requirement)running_under_virtualenv   )	CandidateCandidateVersion
ConstraintRequirement)AlreadyInstalledCandidateBaseCandidateEditableCandidateExtrasCandidateLinkCandidateRequiresPythonCandidateas_base_candidate)FoundCandidatesIndexCandidateInfo)ExplicitRequirementRequiresPythonRequirementSpecifierRequirementUnsatisfiableRequirement)Protocolc                   "    e Zd ZU eed<   eed<   y)ConflictCauserequirementparentN)__name__
__module____qualname__r:   __annotations__r,        RD:\switchATM\venv\Lib\site-packages\pip/_internal/resolution/resolvelib/factory.pyr?   r?   G   s    ..rG   r?   Cc                   F    e Zd ZU ee   ed<   eeef   ed<   eee	f   ed<   y)CollectedRootRequirementsrequirementsconstraintsuser_requestedN)
rB   rC   rD   r   r/   rE   r   strr.   intrF   rG   rH   rK   rK   R   s*    {##c:o&&cN"rG   rK   c                      e Zd Z	 d>dedededee   dededed	ed
ee	e
df      ddfdZedefd       ZdeddfdZdedee   defdZdedee   dedefdZdedee   dedee   dee   dee   fdZdee   dedededee
   de e   fdZ!d e e"   dee   de#e   fd!Z$d"ed#e%dede#e   fd$Z&d"ed%e'ee e"   f   d&e'ee#e   f   d#e%dede e   fd'Z(d(ed)e e   dee"   fd*Z)d+e*e   de+fd,Z,d-ede-fd.Z.	 d?ded/ee   d)e e   dee"   fd0Z/dedee"   fd1Z0dedee   dee1   fd2Z2d-edee   fd3Z3d4ed5   de4fd6Z5d7e"d8ee   de6fd9Z7d:d;d<e8ee%f   de9fd=Z:y)@FactoryNfinderpreparermake_install_reqwheel_cacheuse_user_siteforce_reinstallignore_installedignore_requires_pythonpy_version_info.returnc
                 ^   || _         || _        || _        t        |	      | _        || _        || _        || _        || _        i | _	        i | _
        i | _        i | _        i | _        |s;t               }
|
j                  d      D ci c]  }|j                   | c}| _        y i | _        y c c}w )NF)
local_only)_finderrT   _wheel_cacher5   _python_candidate_make_install_req_from_spec_use_user_site_force_reinstall_ignore_requires_python_build_failures_link_candidate_cache_editable_candidate_cache_installed_candidate_cache_extras_candidate_cacher   iter_installed_distributionscanonical_name_installed_dists)selfrS   rT   rU   rV   rW   rX   rY   rZ   r[   envdists               rH   __init__zFactory.__init__Y   s      '!8!I+;(+ /'=$9;;="CE&PR'  	$  )+C  <<<N% ##T)%D!
 %'D!%s   B*c                     | j                   S N)rd   )rn   s    rH   rX   zFactory.force_reinstall   s    $$$rG   linkc                     |j                   sy t        |j                        }|j                  | j                  j
                  j                               ry |j                   d}t        |      )Nz+ is not a supported wheel on this platform.)is_wheelr!   filename	supportedr_   target_pythonget_tagsr   )rn   rt   wheelmsgs       rH   "_fail_if_link_is_unsupported_wheelz*Factory._fail_if_link_is_unsupported_wheel   sX    }}dmm$??4<<55>>@AJKs##rG   baseextrasc                     t        |      |f}	 | j                  |   }|S # t        $ r t        ||      }|| j                  |<   Y |S w xY wrs   )idrj   KeyErrorr3   )rn   r~   r   	cache_key	candidates        rH   _make_extras_candidatezFactory._make_extras_candidate   se     Xv&		@44Y?I   	@'f5I6?D((3	@s     $AArp   templatec                     	 | j                   |j                     }|s|S | j	                  ||      S # t        $ r* t        |||       }|| j                   |j                  <   Y Hw xY w)N)factory)ri   rl   r   r0   r   )rn   rp   r   r   r~   s        rH   _make_candidate_from_distz!Factory._make_candidate_from_dist   sr    	H2243F3FGD K**488  	H,T8TJDCGD++D,?,?@	Hs   1 0A$#A$nameversionc                 R   || j                   v ry |j                  r<|| j                  vr	 t        ||| ||      | j                  |<   | j                  |   }n;|| j                  vr	 t        ||| ||      | j                  |<   | j                  |   }|s|S | j                  ||      S # t        $ r4}t
        j                  d||ddi       || j                   |<   Y d }~y d }~ww xY w# t        $ r4}t
        j                  d||ddi       || j                   |<   Y d }~y d }~ww xY w)N)r   r   r   z3Discarding [blue underline]%s[/]: [yellow]%s[reset]markupT)extra)
rf   editablerh   r2   r   loggerinforg   r4   r   )rn   rt   r   r   r   r   er~   s           rH   _make_candidate_from_linkz!Factory._make_candidate_from_link   s_    4''' 4999 ;L  $! '<D2248" #'"@"@"FD4555 7D  $! '8D..t4  --d3DK**488E ,  KKM'.	    23D((. * ,  KKM'.	    23D((. s/   B) 'C) )	C&2*C!!C&)	D&2*D!!D&ireqs	specifierhashesprefers_installedincompatible_idsc                    	
 |sy|d   j                   sJ d       t        j                   j                        
t               	|D ][  }|j                   sJ d       |j                   j                  z  |j                  d      z  	t        |j                        z  	] dt        t           f	
 fd}dt        t           f	
 fd}t        | |       |      S )	NrF   r   z)Candidates found on index must be PEP 508F)trust_internetr\   c                      j                   ry	 j                     } j                  | j                  d      syj                  |       }t        |      v ry|S # t        $ r Y yw xY w)z6Get the candidate for the currently-installed version.NT)prereleases)rp   r   r   )rd   rm   r   containsr   r   r   )installed_distr   r   r   r   rn   r   r   s     rH   _get_installed_candidatez@Factory._iter_found_candidates.<locals>._get_installed_candidate   s     $$!%!6!6t!<
 %%n&<&<$%O66#! 7 I )} 00  s   A! !	A-,A-c            	   3     K   
j                   j                  	      } t        | j                               }t	        d |D              }dt
        dt        fd} |      }t        |      D ]f  }|r|s|j                  j                  rt        j                  
j                  |j                  	|j                        }|j                  |f h y w)N)project_namer   r   c              3   H   K   | ]  }|j                   j                    y wrs   )rt   	is_yanked).0icans     rH   	<genexpr>zUFactory._iter_found_candidates.<locals>.iter_index_candidate_infos.<locals>.<genexpr>!  s     CTTYY00Cs    "r   r\   c                     | D ]@  }|j                   dk(  r y|j                   dk7  r$|j                  j                  d      r@ y y)Nz===T==z.*F)operatorr   endswith)r   sps     rH   	is_pinnedzUFactory._iter_found_candidates.<locals>.iter_index_candidate_infos.<locals>.is_pinned#  sL    #  B{{e+#{{d* zz**40   rG   )rt   r   r   r   r   )r_   find_best_candidatelistiter_applicableallr   boolreversedrt   r   	functoolspartialr   r   )resulticans
all_yankedr   pinnedr   funcr   r   r   rn   r   r   s          rH   iter_index_candidate_infoszBFactory._iter_found_candidates.<locals>.iter_index_candidate_infos  s     \\55!# 6 F
 //12E
 CUCCJ	\ 	d 	 y)F ! )"v4993F3F ((22!% LL llD(()s   CC)reqr   r   	frozensetr   r   r   r   r,   r   r8   r7   )rn   r   r   r   r   r   ireqr   r   r   r   r   s   ` `` `   @@@rH   _iter_found_candidateszFactory._iter_found_candidates   s      8||HHH !2!23!* 	-D88HHH+++Idkkk77Fi,,F		-	(9*= 	 	0&	)H5G,H &	) &	)P &$&	
 	
rG   base_requirementsc              #      K   |D ]@  }|j                         \  }}|t        |      }|J d       | j                  ||       B yw)a8  Produce explicit candidates from the base given an extra-ed package.

        :param base_requirements: Requirements known to the resolver. The
            requirements are guaranteed to not have extras.
        :param extras: The extras to inject into the explicit requirements'
            candidates.
        Nzno extras here)get_candidate_lookupr6   r   )rn   r   r   r   lookup_cand_	base_cands          rH   #_iter_explicit_candidates_from_basez+Factory._iter_explicit_candidates_from_baseE  sb      % 	AC 557NK" *+6I(:*::--i@@	As   AA	
identifier
constraintc           	   #      K   |j                   D ]K  }| j                  |       | j                  |t               t	        ||      t        |      d      }|sH| M yw)zProduce explicit candidates from constraints.

        This creates "fake" InstallRequirement objects that are basically clones
        of what "should" be the template, but with original_link set to link.
        Nr   r   r   r   )linksr}   r   r   r#   r   )rn   r   r   r   rt   r   s         rH   !_iter_candidates_from_constraintsz)Factory._iter_candidates_from_constraints[  sg      $$ 
	 D33D966 {7hG&z2 7 I 
	 s   AAArL   incompatibilitiesc           	         t               }g }   D ]<  }|j                         \  }	}
|	|j                  |	       |
,|j                  |
       > t	        j
                  t              5  t              }|j                  | j                  j                  |j                  d      t        |j                                     d d d        |r'	 |j                  | j                  |d                |j                  d      D ch c]  }t!        |       c}|s)| j#                  |j$                  j&                  |      S fd|D        S # 1 sw Y   xY w# t        $ r Y yw xY wc c}w )NrF   r   )r   c              3      K   | ];  t              vr,j                        rt        fd    D              r = yw)c              3   @   K   | ]  }|j                          y wrs   )is_satisfied_by)r   r   cs     rH   r   z4Factory.find_candidates.<locals>.<genexpr>.<genexpr>  s     OsC''*Os   N)r   r   r   )r   r   r   r   incompat_idsrL   s    @rH   r   z*Factory.find_candidates.<locals>.<genexpr>  sF      
!uL(**1-Ol:6NOO	 
s   AA)setr   addappend
contextlibsuppressr   r)   updater   getr   r   r   r   r   r   r   r   r   )rn   r   rL   r   r   r   explicit_candidatesr   r   candr   parsed_requirementr   r   s    `` `        @rH   find_candidateszFactory.find_candidatesr  s    /2e*,
+ 	#C113JD$#''-T"	#   !34 	!0!<&&88 $$%7%<%<bA0778	 #**::""!&q ;  (9'<'<Z'LM!1M #..$$!!! 
(
 	
U	 	, $   Ns%   .AE&E' E6E$'	E32E3r   requested_extrasc                 4   |j                  |      s,t        j                  d|j                  |j                         y |j
                  st        |      S | j                  |j
                         | j                  |j
                  t        |j                        ||j                  rt        |j                        nd d       }|C|j                  s| j                  |j
                     t        t        |j                              S | j                  |      S )Nz6Ignoring %s: markers '%s' don't match your environmentr   )match_markersr   r   r   markersrt   r;   r}   r   r   r   r   rf   r<   make_requirement_from_candidate)rn   r   r   r   s       rH   "_make_requirement_from_install_reqz*Factory._make_requirement_from_install_req  s     !!"23KKH		
 yy'--//		:--IIT[[)15"499- . 
 < 99**49955+,=dii,HII33D99rG   
root_ireqsc                 r   t        g i i       }t        |      D ]  \  }}|j                  rt        |      }|rt	        |      |j                         s<|j                  sJ d       t        |j                        }||j                  v r|j                  |xx   |z  cc<   t        j                  |      |j                  |<   | j                  |d      }||j                  r1|j                  |j                  vr||j                  |j                  <   |j                  j                  |        |S )NzConstraint must be namedrF   )r   )rK   	enumerater   r%   r   r   r   r   rM   r.   	from_ireqr   user_suppliedrN   rL   r   )rn   r   	collectedir   problemr   r   s           rH   collect_root_requirementsz!Factory.collect_root_requirements  s$    .b"b9	 , 	3GAt7=+G44))+yy<"<<(39000))$/47/2<2F2Ft2LI))$/==%' >  ;%%#(():R:R*R9:I,,SXX6&&--c2/	30 rG   r   c                     t        |      S rs   )r9   )rn   r   s     rH   r   z'Factory.make_requirement_from_candidate  s     #9--rG   
comes_fromc                 J    | j                  ||      }| j                  ||      S rs   )rb   r   )rn   r   r   r   r   s        rH   make_requirement_from_specz"Factory.make_requirement_from_spec  s*     //	:F66t=MNNrG   c                 `    | j                   ry t        |      sy t        || j                        S rs   )re   rO   r:   ra   )rn   r   s     rH    make_requires_python_requirementz(Factory.make_requires_python_requirement  s-     ''9~(D4J4JKKrG   c                 h    | j                   y| j                   j                  ||t                     S )a  Look up the link in the wheel cache.

        If ``preparer.require_hashes`` is True, don't use the wheel cache,
        because cached wheels, always built locally, have different hashes
        than the files downloaded from the index server and thus throw false
        hash mismatches. Furthermore, cached wheels at present have
        nondeterministic contents due to file modification times.
        N)rt   package_namesupported_tags)r`   get_cache_entryr'   )rn   rt   r   s      rH   get_wheel_cache_entryzFactory.get_wheel_cache_entry  s<     $  00(? 1 
 	
rG   c                    | j                   j                  |j                        }|y | j                  s|S |j                  r|S t               r3|j                  r'd|j                   d|j                   }t        |      y )NzNWill not install to the user site because it will lack sys.path precedence to z in )
rm   r   r   rc   in_usersiter*   in_site_packagesraw_namelocationr   )rn   r   rp   messages       rH   get_dist_to_uninstallzFactory.get_dist_to_uninstall"  s    $$(()?)?@<
 ""K K $%$*?*?**.--T]]OM  $G,,rG   causesr?   c                    |sJ d       | j                   j                  }t        |      dk(  rOt        |d   j                  j
                        }d|d   j                  j                  d| d|}t        |      S d| d}|D ]G  }|j                  j                         }t        |j                  j
                        }|d	|d
| dz  }I t        |      S )Nz,Requires-Python error reported with no causer+   r   zPackage z requires a different Python: z not in z%Packages require a different Python. z not in:
z (required by ))
ra   r   lenrO   r@   r   rA   r   r   format_for_error)rn   r   r   r   r   causepackages          rH   _report_requires_python_errorz%Factory._report_requires_python_error>  s     EEE((00v;!F1I11;;<I6!9++003 4")8I=:  ,G449'(K 	BEll335GE--778II=wiqAAG	B (00rG   r   rA   c                 R   |t        |      }n| d|j                   d}| j                  j                  |j                        }| j                  j                         }t        |D ch c]  }|j                   c}      D cg c]  }t        |       }}|r)t        j                  ddj                  |      xs d       t        j                  d|dj                  |      xs d       t        |      dk(  rt        j                  d	       t        d
|       S c c}w c c}w )Nz (from r  zJIgnored the following versions that require a different python version: %sz; nonezNCould not find a version that satisfies the requirement %s (from versions: %s), zrequirements.txtzHINT: You are attempting to install a package literally named "requirements.txt" (which cannot exist). Consider using the '-r' flag to install the packages listed in requirements.txtz#No matching distribution found for )rO   r   r_   find_all_candidatesr   requires_python_skipped_reasonssortedr   r   criticaljoinr   r   )	rn   r   rA   req_dispcandsskipped_by_requires_pythonr   vversionss	            rH   #_report_single_requirement_conflictz+Factory._report_single_requirement_conflictT  s    >3xHgfkk]!4H001A1AB%)\\%Q%Q%S"$*u+E!AII+E$FGqCFGG%OO		45?
 	"IIh)6		
 s8))KK# $&I#$OPP- ,FGs   )DD$r   z,ResolutionImpossible[Requirement, Candidate]rM   c                    |j                   sJ d       |j                   D cg c]C  }t        |j                  t              r'|j                  j	                  | j
                        s|E }}|r| j                  t        d|            S t        |j                         dk(  r2|j                   d   \  }}|j                  |vr| j                  ||      S dt        t           dt        fd}dt        dt        fd	}t               }	|j                   D ]1  \  }}||j                         }
n ||      }
|	j!                  |
       3 |	r |t#        |	            }nd
}dj%                  |      }t&        j)                  |       d}t               }|j                   D ]m  \  }}|j                  |v r|j!                  |j                         |dz   }|r ||j                   d|j*                   dz   }n|dz   }||j                         z   }o |D ]  }||   j,                  }|d| | z  } |dz   dz   dz   dz   dz   }t&        j/                  |       t1        d      S c c}w )Nz)Installation error reported with no causezSequence[ConflictCause]r+   r   partsr\   c                 b    t        |       dk(  r| d   S dj                  | d d       dz   | d   z   S )Nr+   r   r
  z and )r  r  )r  s    rH   	text_joinz1Factory.get_installation_error.<locals>.text_join  s9    5zQQx99U3BZ(72U2Y>>rG   rA   c                    | j                         }|r|j                  s| j                   d| j                   S t	        |j                  t
              rt        |j                  j                        S t        |j                        S )Nr   )get_install_requirementr   r   r   
isinstancer$   rO   )rA   r   s     rH   describe_triggerz8Factory.get_installation_error.<locals>.describe_trigger  sf    113Dt ++b(899$//+=>4??//00t''rG   zthe requested packageszOCannot install {} because these package versions have conflicting dependencies.z
The conflict is caused by:z
     z depends on zThe user requested z%
    The user requested (constraint) z

zTo fix this you could try to:
z91. loosen the range of package versions you've specified
z92. remove package versions to allow pip attempt to solve zthe dependency conflict
zResolutionImpossible: for help visit https://pip.pypa.io/en/latest/topics/dependency-resolution/#dealing-with-dependency-conflicts)r   r  r@   r:   r   ra   r  r   r  r   r  r   rO   r,   r   r  r   r  formatr   r  r   r   r   r   )rn   r   rM   r  requires_python_causesr   rA   r  r  triggerstriggerr   r|   relevant_constraintskeyspecs                   rH   get_installation_errorzFactory.get_installation_errorv  s   
 xxDDD "
%++-FG%%55d6L6LM "
 "
 " 55.0FG  qxx=A((1+KCxx{*??VLL	?T#Y 	?3 	?	(Y 	(3 	( 588 	"KC~..0*62LL!	" VH-.D+D--3VD\ 	 	,"u88 	/KCxx;&$((2.Cv{{m1V^^,<LII11,,..C	/ ( 	HCs#--D;C5GGC	H
 /0 KK J	J
 ** 	 	C#1
 	
o"
s   AIrs   )rF   );rB   rC   rD   r   r"   r&   r   r   r   r   rP   rq   propertyrX   r    r}   r1   r   rO   r3   r   r   r$   r,   r   r   r-   r   r   r   r(   r   r   r   r/   r   r   r.   r   r	   r   r   r   rK   r   r9   r   r   r   r   r   r   r   r  r   r  r   r   r'  rF   rG   rH   rR   rR   X   s    6:$'$' &$' 5	$'
 j)$' $' $' $' !%$' "%S/2$' 
$'L % % %$t $ $	!	+4S>			99 #9 %	9
 
9<9<9 #<9 %	<9
 ~&<9 *+<9 
)	<9|_
*+_
  _
 	_

  _
 c(_
 
)	_
BA#K0A #A 
)		A,     %	 
 
)	 .D
D
 c8K#889D
 #3(;#;<	D

 D
  D
 
)	D
L:&::B3-:	+	:@12	"<.".	. +-	OO /0O #3-	O
 
+	O	L	L 
+		L

 (
	*	
&y XFV=W 81/1	!1, Q Q(0(; Q	 QDd
9d
 #z/*d
 
	d
rG   rR   )\r   r   loggingtypingr   r   r   r   r   r   r	   r
   r   r   r   r   r   r   "pip._vendor.packaging.requirementsr    pip._vendor.packaging.specifiersr   pip._vendor.packaging.utilsr   r   pip._vendor.resolvelibr   pip._internal.cacher   r   pip._internal.exceptionsr   r   r   r   r   "pip._internal.index.package_finderr   pip._internal.metadatar   r   pip._internal.models.linkr    pip._internal.models.wheelr!    pip._internal.operations.preparer"   pip._internal.req.constructorsr#   pip._internal.req.req_installr$   r%   pip._internal.resolution.baser&   &pip._internal.utils.compatibility_tagsr'   pip._internal.utils.hashesr(   pip._internal.utils.packagingr)   pip._internal.utils.virtualenvr*   r~   r,   r-   r.   r/   
candidatesr0   r1   r2   r3   r4   r5   r6   found_candidatesr7   r8   rL   r9   r:   r;   r<   r=   r?   	getLoggerrB   r   rI   CacherK   rR   rF   rG   rH   <module>rA     s         " B 9 I 7 6  = L * , @ I E @ - 9 C F F   B   
 
		8	$CLT1W#
 #B

 B

rG   