o
    Ëý°jŠn  ã                   @   s  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#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l0m1Z1 d dl2m3Z3m4Z4 d dl5m6Z6 d dl7m8Z8 d dl9m:Z: d dl;m<Z< d dl=m>Z> ddl?m@Z@mAZAmBZBmCZC ddlDmEZEmFZFmGZGmHZHmIZImJZJmKZK ddlLmMZMmNZN ddlOmPZPmQZQmRZRmSZS erìd dlmTZT G dd„ deTƒZUe VeW¡ZXedƒZYee+eYf ZZG dd„ deƒZ[G d d!„ d!ƒZ\dS )"é    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ÚInstallationSubprocessErrorÚ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                   @   s   e Zd ZU eed< eed< dS )ÚConflictCauseÚrequirementÚparentN)Ú__name__Ú
__module__Ú__qualname__r:   Ú__annotations__r,   © rE   rE   úž/root/aizidognhua/tmp/workspace/projects/ec89d86c-575f-41c9-af57-ac45cbdbf775/venv/lib/python3.10/site-packages/pip/_internal/resolution/resolvelib/factory.pyr>   H   s   
 r>   ÚCc                   @   s:   e Zd ZU ee ed< eeef ed< eee	f ed< dS )ÚCollectedRootRequirementsÚrequirementsÚconstraintsÚuser_requestedN)
rA   rB   rC   r   r/   rD   r   Ústrr.   ÚintrE   rE   rE   rF   rH   S   s   
 rH   c                   @   s˜  e Zd Z	dTdedededee dededed	ed
edee	e
df  ddfdd„Zedefdd„ƒZdeddfdd„Zdedee defdd„Zdedee dedefdd„Zdedee dedee dee dee fdd „Zd!ee d"ed#ed$ed%ee
 de e fd&d'„Z!d(e e" dee de#e fd)d*„Z$d+ed,e%dede#e fd-d.„Z&d+ed/e'ee e" f d0e'ee#e f d,e%d$ede e fd1d2„Z(d3ed4e e dee" fd5d6„Z)d7e*e de+fd8d9„Z,d:ede-fd;d<„Z.	=dUd"ed>ee d4e e dee" fd?d@„Z/d"edee" fdAdB„Z0dedee dee1 fdCdD„Z2d:edee fdEdF„Z3dGedH de4fdIdJ„Z5dKe"dLee de6fdMdN„Z7dOdPdQe8ee%f de9fdRdS„Z:dS )VÚFactoryNÚfinderÚpreparerÚmake_install_reqÚwheel_cacheÚuse_user_siteÚforce_reinstallÚignore_installedÚignore_requires_pythonÚsuppress_build_failuresÚpy_version_info.Úreturnc                 C   sˆ   || _ || _|| _t|
ƒ| _|| _|| _|| _|| _|	| _	i | _
i | _i | _i | _i | _|s?tƒ }dd„ |jdd�D ƒ| _d S i | _d S )Nc                 S   s   i | ]}|j |“qS rE   )Úcanonical_name)Ú.0ÚdistrE   rE   rF   Ú
<dictcomp>{   s    ÿÿz$Factory.__init__.<locals>.<dictcomp>F)Ú
local_only)Ú_finderrP   Ú_wheel_cacher5   Ú_python_candidateÚ_make_install_req_from_specÚ_use_user_siteÚ_force_reinstallÚ_ignore_requires_pythonÚ_suppress_build_failuresÚ_build_failuresÚ_link_candidate_cacheÚ_editable_candidate_cacheÚ_installed_candidate_cacheÚ_extras_candidate_cacher   Úiter_installed_distributionsÚ_installed_dists)ÚselfrO   rP   rQ   rR   rS   rT   rU   rV   rW   rX   ÚenvrE   rE   rF   Ú__init__Z   s*   
þ
þ
zFactory.__init__c                 C   s   | j S ©N)rd   ©rn   rE   rE   rF   rT   ‚   s   zFactory.force_reinstallÚlinkc                 C   s>   |j sd S t|jƒ}| | jj ¡ ¡rd S |j› d�}t|ƒ‚)Nz+ is not a supported wheel on this platform.)Úis_wheelr!   ÚfilenameÚ	supportedr_   Útarget_pythonÚget_tagsr   )rn   rs   ÚwheelÚmsgrE   rE   rF   Ú"_fail_if_link_is_unsupported_wheel†   s   
z*Factory._fail_if_link_is_unsupported_wheelÚbaseÚextrasc                 C   sF   t |ƒ|f}z| j| }W |S  ty"   t||ƒ}|| j|< Y |S w rq   )Úidrk   ÚKeyErrorr3   )rn   r|   r}   Ú	cache_keyÚ	candidaterE   rE   rF   Ú_make_extras_candidate�   s   ý
ýzFactory._make_extras_candidater\   Útemplatec                 C   sR   z| j |j }W n ty   t||| d�}|| j |j< Y nw |s#|S |  ||¡S )N)Úfactory)rj   rZ   r   r0   r‚   )rn   r\   r}   rƒ   r|   rE   rE   rF   Ú_make_candidate_from_distš   s   þz!Factory._make_candidate_from_distÚnameÚversionc              
   C   s¢  || j v rd S |jri|| jvrczt||| ||d�| j|< W nE ty@ } ztjd||ddid� || j |< W Y d }~d S d }~w tyb } z| jsK‚ t 	d||¡ || j |< W Y d }~d S d }~ww | j| }n^|| j
vrÂzt||| ||d�| j
|< W nE tyŸ } ztjd||ddid� || j |< W Y d }~d S d }~w tyÁ } z| jsª‚ t 	d||¡ || j |< W Y d }~d S d }~ww | j
| }|sË|S |  ||¡S )N)r„   r†   r‡   z3Discarding [blue underline]%s[/]: [yellow]%s[reset]ÚmarkupT)Úextraz&Discarding %s due to build failure: %s)rg   Úeditableri   r2   r   ÚloggerÚinfor   rf   Úwarningrh   r4   r‚   )rn   rs   r}   rƒ   r†   r‡   Úer|   rE   rE   rF   Ú_make_candidate_from_link©   s|   

ûü
€
€û
ûü
€
€û
z!Factory._make_candidate_from_linkÚireqsÚ	specifierÚhashesÚprefers_installedÚincompatible_idsc           	         sÂ   |sdS |d ‰ˆj sJ dƒ‚tˆj jƒ‰tƒ ‰ |D ]}|j s#J dƒ‚ˆ|j jM ‰ˆ|jdd�M ‰ˆ t|jƒO ‰ qdtt f‡ ‡‡‡‡‡fdd„}dt	t
 f‡ ‡‡‡‡‡fd	d
„}t||ƒ |ˆƒS )NrE   r   z)Candidates found on index must be PEP 508F)Útrust_internetrY   c                     sf   ˆj rdS zˆjˆ } W n
 ty   Y dS w ˆj| jdd�s!dS ˆj| ˆ ˆd�}t|ƒˆv r1dS |S )z6Get the candidate for the currently-installed version.NT)Úprereleases)r\   r}   rƒ   )rd   rm   r   Úcontainsr‡   r…   r~   )Úinstalled_distr�   )r}   r”   r†   rn   r‘   rƒ   rE   rF   Ú_get_installed_candidate  s"   ÿýz@Factory._iter_found_candidates.<locals>._get_installed_candidatec               	   3   s˜   � ˆj jˆˆˆd�} t|  ¡ ƒ}tdd„ |D ƒƒ}dtdtfdd„}|ˆƒ}t|ƒD ]}|r0|s5|jj	r5q*t
jˆj|jˆ ˆˆ|jd�}|j|fV  q*d S )	N)Úproject_namer‘   r’   c                 s   s   � | ]}|j jV  qd S rq   )rs   Ú	is_yanked)r[   ÚicanrE   rE   rF   Ú	<genexpr>0  s   € zUFactory._iter_found_candidates.<locals>.iter_index_candidate_infos.<locals>.<genexpr>r‘   rY   c                 S   s<   | D ]}|j dkr dS |j dkrq|j d¡rq dS dS )Nz===Tú==z.*F)Úoperatorr‡   Úendswith)r‘   ÚsprE   rE   rF   Ú	is_pinned2  s   

zUFactory._iter_found_candidates.<locals>.iter_index_candidate_infos.<locals>.is_pinned)rs   r}   rƒ   r†   r‡   )r_   Úfind_best_candidateÚlistÚiter_applicableÚallr   ÚboolÚreversedrs   r›   Ú	functoolsÚpartialr�   r‡   )ÚresultÚicansÚ
all_yankedr¢   Úpinnedrœ   Úfunc)r}   r’   r†   rn   r‘   rƒ   rE   rF   Úiter_index_candidate_infos%  s.   €ýúõzBFactory._iter_found_candidates.<locals>.iter_index_candidate_infos)Úreqr   r†   Ú	frozensetr‘   r’   r}   r
   r,   r   r8   r7   )	rn   r�   r‘   r’   r“   r”   Úireqr™   r°   rE   )r}   r’   r”   r†   rn   r‘   rƒ   rF   Ú_iter_found_candidatesó   s&     (üzFactory._iter_found_candidatesÚbase_requirementsc                 c   sL   � |D ] }|  ¡ \}}|du rqt|ƒ}|dusJ dƒ‚|  ||¡V  qdS )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_candrE   rE   rF   Ú#_iter_explicit_candidates_from_baseT  s   €øz+Factory._iter_explicit_candidates_from_baseÚ
identifierÚ
constraintc                 c   sF   � |j D ]}|  |¡ | j|tƒ t||ƒt|ƒdd�}|r |V  qdS )zÖProduce 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ƒ   rs   r�   rE   rE   rF   Ú!_iter_candidates_from_constraintsj  s   €

û€öz)Factory._iter_candidates_from_constraintsrI   Úincompatibilitiesc              	      s  t ƒ }g }ˆˆ D ]}| ¡ \}	}
|	d ur| |	¡ |
d ur#| |
¡ q	t t¡� tˆƒ}| |  	ˆ 
|jd¡t|jƒ¡¡ W d   ƒ n1 sIw   Y  |rjz| | jˆˆ |d d�¡ W n
 tyi   Y dS w dd„ | 
ˆd¡D ƒ‰|s‚|  |ˆ jˆ j|ˆ¡S ‡ ‡‡‡fdd„|D ƒS )NrE   r   )rƒ   c                 S   s   h | ]}t |ƒ’qS rE   )r~   ©r[   ÚcrE   rE   rF   Ú	<setcomp>²  ó    z*Factory.find_candidates.<locals>.<setcomp>c                 3   sD   � | ]‰ t ˆ ƒˆvrˆ ˆ ¡rt‡ fd d„ˆˆ D ƒƒrˆ V  qdS )c                 3   s   � | ]}|  ˆ ¡V  qd S rq   )Úis_satisfied_by)r[   r±   ©rÂ   rE   rF   r�   Ä  s   € z4Factory.find_candidates.<locals>.<genexpr>.<genexpr>N)r~   rÅ   r¦   )r[   ©r¼   r»   Úincompat_idsrI   rÆ   rF   r�   ¿  s   € ÿþþýz*Factory.find_candidates.<locals>.<genexpr>)Úsetr¶   ÚaddÚappendÚ
contextlibÚsuppressr   r)   Úupdaterº   Úgetr†   r²   r}   r¿   r   r´   r‘   r’   )rn   r»   rI   rÀ   r¼   r“   Úexplicit_candidatesr�   r±   Úcandr³   Úparsed_requirementrE   rÇ   rF   Úfind_candidates�  sT   	

€þÿþýÿýûþzFactory.find_candidatesr³   Úrequested_extrasc                 C   s˜   |  |¡st d|j|j¡ d S |jst|ƒS |  |j¡ | j|jt	|j
ƒ||jr.t|jƒnd d d�}|d u rG|js@| j|j ‚tt|jƒƒS |  |¡S )Nz6Ignoring %s: markers '%s' don't match your environmentr½   )Úmatch_markersr‹   rŒ   r†   Úmarkersrs   r;   r{   r�   r²   r}   r   rg   r<   Úmake_requirement_from_candidate)rn   r³   rÔ   rÑ   rE   rE   rF   Ú"_make_requirement_from_install_reqÇ  s,   
ýû
z*Factory._make_requirement_from_install_reqÚ
root_ireqsc                 C   sÐ   t g i i ƒ}t|ƒD ][\}}|jrDt|ƒ}|rt|ƒ‚| ¡ s q
|js'J dƒ‚t|jƒ}||jv r;|j|  |M  < q
t	 
|¡|j|< q
| j|dd�}|d u rPq
|jr_|j|jvr_||j|j< |j |¡ q
|S )NzConstraint must be namedrE   )rÔ   )rH   Ú	enumerater¼   r%   r   rÕ   r†   r   rJ   r.   Ú	from_ireqrØ   Úuser_suppliedrK   rI   rË   )rn   rÙ   Ú	collectedÚir³   Úproblemr†   r±   rE   rE   rF   Úcollect_root_requirementsç  s.   

þz!Factory.collect_root_requirementsr�   c                 C   s   t |ƒS rq   )r9   )rn   r�   rE   rE   rF   r×     s   z'Factory.make_requirement_from_candidaterE   Ú
comes_fromc                 C   s   |   ||¡}|  ||¡S rq   )rb   rØ   )rn   r‘   rá   rÔ   r³   rE   rE   rF   Úmake_requirement_from_spec
  s   z"Factory.make_requirement_from_specc                 C   s"   | j rd S t|ƒsd S t|| jƒS rq   )re   rL   r:   ra   )rn   r‘   rE   rE   rF   Ú make_requires_python_requirement  s
   z(Factory.make_requires_python_requirementc                 C   s*   | j du s	| jjrdS | j j||tƒ d�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)rs   Úpackage_nameÚsupported_tags)r`   rP   Úrequire_hashesÚget_cache_entryr'   )rn   rs   r†   rE   rE   rF   Úget_wheel_cache_entry  s   ýzFactory.get_wheel_cache_entryc                 C   sZ   | j  |j¡}|d u rd S | js|S |jr|S tƒ r+|jr+d|j› d|j› �}t	|ƒ‚d S )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�   r\   ÚmessagerE   rE   rF   Úget_dist_to_uninstall1  s    ÿÿÿzFactory.get_dist_to_uninstallÚcausesr>   c                 C   s    |sJ dƒ‚| j j}t|ƒdkr+t|d jjƒ}d|d jj›d|› d|›�}t|ƒS d|› d�}|D ]}|j 	¡ }t|jjƒ}|d	|›d
|› d�7 }q3t|ƒ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‡   ÚlenrL   r?   r‘   r@   r†   r   Úformat_for_error)rn   rï   r‡   r‘   rí   ÚcauseÚpackagerE   rE   rF   Ú_report_requires_python_errorM  s"   ÿÿÿ
z%Factory._report_requires_python_errorr±   r@   c                 C   sŠ   |d u r	t |ƒ}n	|› d|j› d�}| j |j¡}dd„ tdd„ |D ƒƒD ƒ}t d|d |¡p1d	¡ t |ƒd
kr>t 	d¡ t
d|› �ƒS )Nz (from rñ   c                 S   s   g | ]}t |ƒ‘qS rE   )rL   )r[   ÚvrE   rE   rF   Ú
<listcomp>l  rÄ   z?Factory._report_single_requirement_conflict.<locals>.<listcomp>c                 S   s   h | ]}|j ’qS rE   )r‡   rÁ   rE   rE   rF   rÃ   l  s    z>Factory._report_single_requirement_conflict.<locals>.<setcomp>zNCould not find a version that satisfies the requirement %s (from versions: %s)ú, Únonezrequirements.txtz¶HINT: 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 )rL   r†   r_   Úfind_all_candidatesrš   Úsortedr‹   ÚcriticalÚjoinrŒ   r   )rn   r±   r@   Úreq_dispÚcandsÚversionsrE   rE   rF   Ú#_report_single_requirement_conflictc  s   
üÿz+Factory._report_single_requirement_conflictrŽ   z,ResolutionImpossible[Requirement, Candidate]rJ   c                    s®  |j sJ dƒ‚‡ fdd„|j D ƒ}|rˆ  td|ƒ¡S t|j ƒdkr4|j d \}}|j|vr4ˆ  ||¡S dtt dtfd	d
„}dtdtfdd„}t	ƒ }|j D ]\}}|d u r[| 
¡ }	n||ƒ}	| |	¡ qN|rn|t|ƒƒ}
nd}
d |
¡}t |¡ d}t	ƒ }|j D ],\}}|j|v r‘| |j¡ |d }|r¤||j› d|j› d� }n|d }|| 
¡  }q‚|D ]}|| j}|d|› |› �7 }q±|d d d d d }t |¡ tdƒS )Nz)Installation error reported with no causec                    s*   g | ]}t |jtƒr|j ˆ j¡s|‘qS rE   )Ú
isinstancer?   r:   rÅ   ra   )r[   rô   rr   rE   rF   rø   ˆ  s    
ýüÿz2Factory.get_installation_error.<locals>.<listcomp>zSequence[ConflictCause]r+   r   ÚpartsrY   c                 S   s2   t | ƒdkr
| d S d | d d… ¡d | d  S )Nr+   r   rù   éÿÿÿÿz and )rò   rþ   )r  rE   rE   rF   Ú	text_join£  s   z1Factory.get_installation_error.<locals>.text_joinr@   c                 S   sF   |   ¡ }|r	|js| j› d| j› �S t|jtƒrt|jjƒS t|jƒS )Nrž   )Úget_install_requirementrá   r†   r‡   r  r$   rL   )r@   r³   rE   rE   rF   Údescribe_trigger©  s   

z8Factory.get_installation_error.<locals>.describe_triggerz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
z‚ResolutionImpossible: for help visit https://pip.pypa.io/en/latest/topics/dependency-resolution/#dealing-with-dependency-conflicts)rï   rö   r   rò   r†   r  r   rL   r,   rÉ   ró   rÊ   rü   Úformatr‹   rý   r‡   r‘   rŒ   r   )rn   rŽ   rJ   Úrequires_python_causesr±   r@   r  r  ÚtriggersÚtriggerrŒ   rz   Úrelevant_constraintsÚkeyÚspecrE   rr   rF   Úget_installation_error~  sp   
þÿ	

þ


ÿþýüûÿ
	ÿzFactory.get_installation_errorrq   )rE   );rA   rB   rC   r   r"   r&   r
   r   r§   r   rM   rp   ÚpropertyrT   r    r{   r1   r   rL   r3   r‚   r   r$   r,   r…   r   r-   r�   r   r   r(   r   r   r´   r/   r   rº   r.   r¿   r   rÓ   rØ   r   rH   rà   r9   r×   râ   rã   r   rè   rî   r   rö   r   r  r   r   r  rE   rE   rE   rF   rN   Y   s<   õþýüûúùø	÷
öõ
ô(	ÿÿ
þþýü
ûþýüûú
ùJþýüûú
ùaþý
üþýü
ûþýüûú
ùFÿÿ
þ ÿ
þÿ
þ	üþýü
û	þ
ýÿÿ
þÿ
þÿÿ
þþ
ýürN   )]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   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   rI   r9   r:   r;   r<   r=   r>   Ú	getLoggerrA   r‹   rG   ÚCacherH   rN   rE   rE   rE   rF   Ú<module>   sD    @ $	
