Ë
    äØjjº   ã                   óx  — d dl Z d dlZd dlZd dlZd dlZd dlZd dlZd dl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 d dlmZ d dlmZ d dlmZ d d	lmZ d d
lmZ d dlm Z  d dl!m"Z" d dl#m$Z$ d dl%m&Z& d dl'm(Z(m)Z) d dl*m+Z+m,Z,m-Z- d dl.m/Z/  e j`                  d¬«      Z1 ejd                  e3«      Z4de5de5fd„Z6de5de j                   fd„Z7 G d„ d«      Z8e
 G d„ d«      «       Z9de5de:fd„Z;de$d ejx                  dee5   fd!„Z=d"e8d#e j                   d$e d%eg ee5   f   dee9   f
d&„Z>de$d ejx                  ddfd'„Z?y)(é    N)Ú	dataclass)ÚAnyÚCallableÚDictÚOptional)Úparse)ÚGroup)Úescape)ÚText)ÚLinkCollector)ÚPackageFinder)Úget_default_environment)ÚDistributionVersion)ÚSelectionPreferences)Ú
PipSession)ÚWINDOWS)Ú get_best_invocation_for_this_pipÚ#get_best_invocation_for_this_python)Úadjacent_tmp_fileÚcheck_path_ownerÚreplace)Ú
ensure_diré   )ÚdaysÚkeyÚreturnc                 ól   — | j                  «       }t        j                  |«      j                  «       }|S ©N)ÚencodeÚhashlibÚsha224Ú	hexdigest)r   Ú	key_bytesÚnames      úc/opt/eval-harness/bench_task/venv/lib/python3.12/site-packages/pip/_internal/self_outdated_check.pyÚ_get_statefile_namer&   $   s)   € Ø—
‘
“€IÜ�>‰>˜)Ó$×.Ñ.Ó0€DØ€Kó    Úisodatec                 ó`   — t         j                   j                  | j                  dd«      «      S )z¥Convert an ISO format string to a date.

    Handles the format 2020-01-22T14:24:01Z (trailing Z)
    which is not supported by older versions of fromisoformat.
    ÚZz+00:00)ÚdatetimeÚfromisoformatr   )r(   s    r%   Ú_convert_dater-   *   s&   € ô ×Ñ×*Ñ*¨7¯?©?¸3ÀÓ+IÓJÐJr'   c                   ó„   — e Zd Zdeddfd„Zedefd„«       Zdej                  dee   fd„Z	dedej                  ddfd	„Z
y)
ÚSelfCheckStateÚ	cache_dirr   Nc                 óZ  — i | _         d | _        |rut        j                  j	                  |dt        | j                  «      «      | _        	 t        | j                  d¬«      5 }t        j                  |«      | _         d d d «       y y # 1 sw Y   y xY w# t        t        t        f$ r Y y w xY w)NÚ	selfcheckzutf-8)Úencoding)Ú_stateÚ_statefile_pathÚosÚpathÚjoinr&   r   ÚopenÚjsonÚloadÚOSErrorÚ
ValueErrorÚKeyError)Úselfr0   Ú	statefiles      r%   Ú__init__zSelfCheckState.__init__4   sœ   € Ø&(ˆŒØ#ˆÔñ Ü#%§7¡7§<¡<Ø˜;Ô(;¸D¿H¹HÓ(Eó$ˆDÔ ðÜ˜$×.Ñ.¸ÔAð 7ÀYÜ"&§)¡)¨IÓ"6�D”K÷7ð 7ð ÷
7ð 7ûäœZ¬Ð2ò ñ ðús0   ÁB Á"BÁ=B ÂBÂB ÂB ÂB*Â)B*c                 ó"   — t         j                  S r   )ÚsysÚprefix)r?   s    r%   r   zSelfCheckState.keyE   s   € ä�z‰zÐr'   Úcurrent_timec                 óÄ   — | j                   syd| j                   vryd| j                   vryt        | j                   d   «      }||z
  }|t        kD  ry| j                   d   S )z7Check if we have a not-outdated version loaded already.NÚ
last_checkÚpypi_version)r4   r-   Ú_WEEK)r?   rE   rG   Útime_since_last_checks       r%   ÚgetzSelfCheckState.getI   sd   € à�{Š{Øà˜tŸ{™{Ñ*Øà §¡Ñ,Øô # 4§;¡;¨|Ñ#<Ó=ˆ
Ø ,¨zÑ 9ÐØ ¤5Ò(Øà�{‰{˜>Ñ*Ð*r'   rH   c                 óF  — | j                   sy t        t        j                  j	                  | j                   «      «      sy t        t        j                  j	                  | j                   «      «       | j                  |j                  «       |dœ}t        j                  |dd¬«      }t        | j                   «      5 }|j                  |j                  «       «       d d d «       	 t        j                  | j                   «       y # 1 sw Y   Œ+xY w# t        $ r Y y w xY w)N)r   rG   rH   T)ú,ú:)Ú	sort_keysÚ
separators)r5   r   r6   r7   Údirnamer   r   Ú	isoformatr:   Údumpsr   Úwriter   r   r$   r<   )r?   rH   rE   ÚstateÚtextÚfs         r%   ÚsetzSelfCheckState.set\   sã   € à×#Ò#Øô  ¤§¡§¡°×0DÑ0DÓ EÔFØô 	”2—7‘7—?‘? 4×#7Ñ#7Ó8Ô9ð
 —8‘8Ø&×0Ñ0Ó2Ø(ñ
ˆô �z‰z˜%¨4¸JÔGˆä˜t×3Ñ3Ó4ð 	#¸Ø�G‰G�D—K‘K“MÔ"÷	#ð	ô �A—F‘F˜D×0Ñ0Õ1÷	#ð 	#ûô ò 	áð	ús   Â> DÃ' D ÄDÄ	D ÄD )Ú__name__Ú
__module__Ú__qualname__ÚstrrA   Úpropertyr   r+   r   rK   rX   © r'   r%   r/   r/   3   sm   „ ð #ð ¨$ó ð" ð�Sò ó ðð+ × 1Ñ 1ð +°h¸s±mó +ð&  ð  °8×3DÑ3Dð  Èô  r'   r/   c                   ó.   — e Zd ZU eed<   eed<   defd„Zy)ÚUpgradePromptÚoldÚnewr   c                 ó  — t         rt        «       › d�}n
t        «       }d}t        t	        «       t	        j
                  |› d| j                  › d| j                  › d�«      t	        j
                  |› dt        |«      › d�«      «      S )Nz -m pipz/[bold][[reset][blue]notice[reset][bold]][reset]z) A new release of pip is available: [red]z[reset] -> [green]z[reset]z To update, run: [green]z install --upgrade pip)	r   r   r   r	   r   Úfrom_markupra   rb   r
   )r?   Úpip_cmdÚnotices      r%   Ú__rich__zUpgradePrompt.__rich__„   s•   € ÝÜ<Ó>Ð?¸wÐG‰Gä6Ó8ˆGàBˆÜÜ‹FÜ×ÑØ�(ð ØŸ™�zÐ!3°D·H±H°:¸WðFóô ×ÑØ�(ð Ü  ›/Ð*Ð*@ðBóó

ð 
	
r'   N)rY   rZ   r[   r\   Ú__annotations__r	   rg   r^   r'   r%   r`   r`      s   … à	ƒHØ	ƒHð
˜%ô 
r'   r`   Úpkgc                 ó^   — t        «       j                  | «      }|duxr d|j                  k(  S )zµChecks whether pkg was installed by pip

    This is used not to display the upgrade message when pip is in fact
    installed by system package manager, such as dnf on Fedora.
    NÚpip)r   Úget_distributionÚ	installer)ri   Údists     r%   Úwas_installed_by_pipro   ˜   s0   € ô #Ó$×5Ñ5°cÓ:€DØ�tÐÒ7 ¨¯©Ñ 7Ð7r'   ÚsessionÚoptionsc                 óà   — t        j                  | |d¬«      }t        dd¬«      }t        j                  ||¬«      }|j	                  d«      j
                  }|€y t        |j                  «      S )NT)rq   Úsuppress_no_indexF)Úallow_yankedÚallow_all_prereleases)Úlink_collectorÚselection_prefsrk   )r   Úcreater   r   Úfind_best_candidateÚbest_candidater\   Úversion)rp   rq   rv   rw   Úfinderrz   s         r%   Ú_get_current_remote_pip_versionr}   ¢   sy   € ô #×)Ñ)ØØØô€Nô +ØØ#ô€Oô
 ×!Ñ!Ø%Ø'ô€Fð ×/Ñ/°Ó6×EÑE€NØÐØäˆ~×%Ñ%Ó&Ð&r'   rU   rE   Úlocal_versionÚget_remote_versionc                 ó²  — | j                  |«      }|€1 |«       }|€t        j                  d«       y | j                  ||«       t	        |«      }t        j                  d|«       t        j                  d|«       t        d«      }t        j                  d|«       |sy ||k  xr |j                  |j                  k7  }|rt        t        |«      |¬«      S y )NzNo remote pip version foundzRemote version of pip: %szLocal version of pip:  %srk   zWas pip installed by pip? %s)ra   rb   )	rK   ÚloggerÚdebugrX   Úparse_versionro   Úbase_versionr`   r\   )rU   rE   r~   r   Úremote_version_strÚremote_versionÚpip_installed_by_pipÚlocal_version_is_olders           r%   Ú_self_version_check_logicr‰   ¾   sÕ   € ð Ÿ™ <Ó0ÐØÐ!Ù/Ó1ÐØÐ%Ü�L‰LÐ6Ô7ØØ�	‰	Ð$ lÔ3ä"Ð#5Ó6€NÜ
‡L�LÐ,¨nÔ=Ü
‡L�LÐ,¨mÔ<ä/°Ó6ÐÜ
‡L�LÐ/Ð1EÔFÙØð 	˜Ñ&ò 	FØ×&Ñ&¨.×*EÑ*EÑEð ñ Ü¤ ]Ó!3Ð9KÔLÐLàr'   c           
      óä  — t        «       j                  d«      }|sy	 t        t        |j                  ¬«      t
        j
                  j                  t
        j                  j                  «      |j                  t        j                  t        | |«      ¬«      }|�t        j                  d|ddi¬«       yy# t        $ r/ t        j                  d	«       t        j!                  d
d¬«       Y yw xY w)zÛCheck for an update for pip.

    Limit the frequency of checks to once per week. State is stored either in
    the active virtualenv or in the user's USER_CACHE_DIR keyed off the prefix
    of the pip script path.
    rk   N)r0   )rU   rE   r~   r   z%sÚrichT)Úextraz6There was an error checking the latest version of pip.zSee below for error)Úexc_info)r   rl   r‰   r/   r0   r+   ÚnowÚtimezoneÚutcr{   Ú	functoolsÚpartialr}   r�   ÚwarningÚ	Exceptionr‚   )rp   rq   Úinstalled_distÚupgrade_prompts       r%   Úpip_self_version_checkr—   à   sÈ   € ô -Ó.×?Ñ?ÀÓF€NÙØð;Ü2Ü ¨7×+<Ñ+<Ô=Ü!×*Ñ*×.Ñ.¬x×/@Ñ/@×/DÑ/DÓEØ(×0Ñ0Ü(×0Ñ0Ü/°¸'ó ô	
ˆð Ð%Ü�N‰N˜4 ¸À°~ˆNÕFð &øäò ;Ü�‰ÐOÔPÜ�‰Ð*°TˆÖ:ð;ús   žBB7 Â75C/Ã.C/)@r+   r‘   r    r:   ÚloggingÚoptparseÚos.pathr6   rC   Údataclassesr   Útypingr   r   r   r   Úpip._vendor.packaging.versionr   rƒ   Úpip._vendor.rich.consoler	   Úpip._vendor.rich.markupr
   Úpip._vendor.rich.textr   Úpip._internal.index.collectorr   Ú"pip._internal.index.package_finderr   Úpip._internal.metadatar   Úpip._internal.metadata.baser   Ú$pip._internal.models.selection_prefsr   Úpip._internal.network.sessionr   Úpip._internal.utils.compatr   Úpip._internal.utils.entrypointsr   r   Úpip._internal.utils.filesystemr   r   r   Úpip._internal.utils.miscr   Ú	timedeltarI   Ú	getLoggerrY   r�   r\   r&   r-   r/   r`   Úboolro   ÚValuesr}   r‰   r—   r^   r'   r%   ú<module>r¯      sv  ðÛ Û Û Û Û Û Û Û 
Ý !ß 0Ó 0å @Ý *Ý *Ý &å 7Ý <Ý :Ý ;Ý EÝ 4Ý .÷÷ XÑ WÝ /àˆ×Ñ Ô"€à	ˆ×	Ñ	˜8Ó	$€ð˜Sð  Só ðK˜3ð K 8×#4Ñ#4ó K÷Iñ IðX ÷
ð 
ó ð
ð08˜cð 8 dó 8ð'Øð'Ø"*§/¡/ð'àˆc�]ó'ð8àðð ×#Ñ#ðð 'ð	ð
 !  X¨c¡]Ð!2Ñ3ðð ˆmÑóðD; Jð ;¸¿¹ð ;ÈTô ;r'   