Ë
    äØjjð!  ã                   óÄ  — 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	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 d dlmZmZ d dlmZ  e j8                  e«      Zee   Zee   Z eegee   f   Z!eege"f   Z# G d	„ d
«      Z$de%de"fd„Z& G d„ d«      Z' G d„ de$«      Z( G d„ de$«      Z) G d„ de$«      Z* G d„ de$«      Z+de%de!de#de"de"de%dee
e%   e
e$   f   fd„Z,y)é    N)Údefaultdict)ÚCallableÚDictÚIterableÚListÚOptionalÚTuple)ÚInvalidSdistFilenameÚInvalidVersionÚInvalidWheelFilenameÚcanonicalize_nameÚparse_sdist_filenameÚparse_wheel_filename)ÚInstallationCandidate)ÚLink)Úpath_to_urlÚurl_to_path)Úis_urlc                   ó@   — e Zd Zedee   fd„«       Zdefd„Zde	fd„Z
y)Ú
LinkSourceÚreturnc                 ó   — t        «       ‚)z,Returns the underlying link, if there's one.©ÚNotImplementedError©Úselfs    ú]/opt/eval-harness/bench_task/venv/lib/python3.12/site-packages/pip/_internal/index/sources.pyÚlinkzLinkSource.link   s   € ô "Ó#Ð#ó    c                 ó   — t        «       ‚)z9Candidates found by parsing an archive listing HTML file.r   r   s    r   Úpage_candidateszLinkSource.page_candidates#   ó   € ä!Ó#Ð#r   c                 ó   — t        «       ‚)z,Links found by specifying archives directly.r   r   s    r   Ú
file_linkszLinkSource.file_links'   r"   r   N)Ú__name__Ú
__module__Ú__qualname__Úpropertyr   r   r   ÚFoundCandidatesr!   Ú
FoundLinksr$   © r   r   r   r      s7   „ Øð$�h˜t‘nò $ó ð$ð$ ó $ð$˜Jô $r   r   Úfile_urlr   c                 ó<   — t        j                  | d¬«      d   dk(  S )NF)Ústrictr   z	text/html)Ú	mimetypesÚ
guess_type)r,   s    r   Ú_is_html_filer1   ,   s   € Ü×Ñ °Ô7¸Ñ:¸kÑIÐIr   c                   ój   — e Zd ZdZdeddfd„Zd	d„Zedee   fd„«       Z	ede
eee   f   fd„«       Zy)
Ú_FlatDirectoryToUrlsz"Scans directory and caches resultsÚpathr   Nc                 óV   — || _         g | _        t        t        «      | _        d| _        y )NF)Ú_pathÚ_page_candidatesr   ÚlistÚ_project_name_to_urlsÚ_scanned_directory)r   r4   s     r   Ú__init__z_FlatDirectoryToUrls.__init__3   s&   € ØˆŒ
Ø+-ˆÔÜ;FÄtÓ;LˆÔ"Ø"'ˆÕr   c                 óÊ  — t        j                  | j                  «      D ]u  }t        |j                  «      }t        |«      r| j                  j                  |«       Œ?	 t        |j                  «      d   }| j                  |   j                  |«       Œw d| _        y# t        t        f$ r3 	 t        |j                  «      d   }n# t        t        f$ r Y Y Œ»w xY wY Œiw xY w)zrScans directory once and populates both page_candidates
        and project_name_to_urls at the same time
        r   TN)ÚosÚscandirr6   r   r4   r1   r7   Úappendr   Únamer   r   r   r
   r9   r:   )r   ÚentryÚurlÚproject_filenames       r   Ú_scan_directoryz$_FlatDirectoryToUrls._scan_directory9   sÙ   € ô —Z‘Z §
¡
Ó+ò 	EˆEÜ˜eŸj™jÓ)ˆCÜ˜SÔ!Ø×%Ñ%×,Ñ,¨SÔ1ØðÜ#7¸¿
¹
Ó#CÀAÑ#FÐ ð ×&Ñ&Ð'7Ñ8×?Ñ?ÀÕDð!	Eð" #'ˆÕøô )¬.Ð9ò ðÜ';¸E¿J¹JÓ'GÈÑ'JÑ$øÜ,¬nÐ=ò Úðúñ %ðús6   Á B Â C"Â0C	ÃC"Ã	CÃC"ÃCÃC"Ã!C"c                 óR   — | j                   s| j                  «        | j                  S ©N)r:   rD   r7   r   s    r   r!   z$_FlatDirectoryToUrls.page_candidatesP   s#   € à×&Ò&Ø× Ñ Ô"à×$Ñ$Ð$r   c                 óR   — | j                   s| j                  «        | j                  S rF   )r:   rD   r9   r   s    r   Úproject_name_to_urlsz)_FlatDirectoryToUrls.project_name_to_urlsW   s#   € à×&Ò&Ø× Ñ Ô"à×)Ñ)Ð)r   )r   N)r%   r&   r'   Ú__doc__Ústrr;   rD   r(   r   r!   r   rH   r+   r   r   r3   r3   0   sd   „ Ù,ð(˜Sð ( Tó (ó'ð. ð%  c¡ò %ó ð%ð ð* d¨3°°S±	¨>Ñ&:ò *ó ñ*r   r3   c                   óv   — e Zd ZU dZi Zeeef   ed<   de	dededdfd„Z
edee   fd	„«       Zdefd
„Zdefd„Zy)Ú_FlatDirectorySourcezûLink source specified by ``--find-links=<path-to-dir>``.

    This looks the content of the directory, and returns:

    * ``page_candidates``: Links listed on each HTML file in the directory.
    * ``file_candidates``: Archives in the directory.
    Ú_paths_to_urlsÚcandidates_from_pager4   Úproject_namer   Nc                 óÌ   — || _         t        |«      | _        || j                  v r| j                  |   | _        y t        |¬«      | _        | j                  | j                  |<   y )N)r4   )Ú_candidates_from_pager   Ú_project_namerM   Ú_path_to_urlsr3   )r   rN   r4   rO   s       r   r;   z_FlatDirectorySource.__init__j   s_   € ð &:ˆÔ"Ü.¨|Ó<ˆÔð �4×&Ñ&Ñ&Ø!%×!4Ñ!4°TÑ!:ˆDÕä!5¸4Ô!@ˆDÔØ(,×(:Ñ(:ˆD×Ñ Ò%r   c                  ó   — y rF   r+   r   s    r   r   z_FlatDirectorySource.linkz   s   € àr   c              #   óŠ   K  — | j                   j                  D ]$  }| j                  t        |«      «      E d {  –—†  Œ& y 7 Œ­wrF   )rS   r!   rQ   r   ©r   rB   s     r   r!   z$_FlatDirectorySource.page_candidates~   s<   è ø€ Ø×%Ñ%×5Ñ5ò 	=ˆCØ×1Ñ1´$°s³)Ó<×<Ñ<ñ	=Ø<ús   ‚7A¹AºAc              #   óv   K  — | j                   j                  | j                     D ]  }t        |«      –— Œ y ­wrF   )rS   rH   rR   r   rV   s     r   r$   z_FlatDirectorySource.file_links‚   s5   è ø€ Ø×%Ñ%×:Ñ:¸4×;MÑ;MÑNò 	ˆCÜ�s“)‹Oñ	ùs   ‚79)r%   r&   r'   rI   rM   r   rJ   r3   Ú__annotations__ÚCandidatesFromPager;   r(   r   r   r   r)   r!   r*   r$   r+   r   r   rL   rL   _   s€   … ñð 79€N�D˜Ð2Ð2Ñ3Ó8ð;à0ð;ð ð;ð ð	;ð
 
ó;ð  ð�h˜t‘nò ó ðð= ó =ð˜Jô r   rL   c                   óX   — e Zd ZdZdededdfd„Zedee   fd„«       Z	de
fd„Zdefd	„Zy)
Ú_LocalFileSourceaC  ``--find-links=<path-or-url>`` or ``--[extra-]index-url=<path-or-url>``.

    If a URL is supplied, it must be a ``file:`` URL. If a path is supplied to
    the option, it is converted to a URL first. This returns:

    * ``page_candidates``: Links listed on an HTML file.
    * ``file_candidates``: The non-HTML file.
    rN   r   r   Nc                 ó    — || _         || _        y rF   ©rQ   Ú_link©r   rN   r   s      r   r;   z_LocalFileSource.__init__‘   ó   € ð
 &:ˆÔ"Øˆ�
r   c                 ó   — | j                   S rF   ©r^   r   s    r   r   z_LocalFileSource.link™   ó   € à�z‰zÐr   c              #   ó–   K  — t        | j                  j                  «      sy | j                  | j                  «      E d {  –—†  y 7 Œ­wrF   )r1   r^   rB   rQ   r   s    r   r!   z _LocalFileSource.page_candidates�   s1   è ø€ Ü˜TŸZ™ZŸ^™^Ô,ØØ×-Ñ-¨d¯j©jÓ9×9Ò9ús   ‚?A	ÁAÁA	c              #   óh   K  — t        | j                  j                  «      ry | j                  –— y ­wrF   )r1   r^   rB   r   s    r   r$   z_LocalFileSource.file_links¢   s#   è ø€ Ü˜Ÿ™Ÿ™Ô(ØØ�j‰jÓùs   ‚02©r%   r&   r'   rI   rY   r   r;   r(   r   r   r)   r!   r*   r$   r+   r   r   r[   r[   ‡   s_   „ ñðà0ðð ðð 
ó	ð ð�h˜t‘nò ó ðð: ó :ð
˜Jô r   r[   c                   ó\   — e Zd ZdZdedededdfd„Zede	e   fd„«       Z
defd	„Zdefd
„Zy)Ú_RemoteFileSourcez¸``--find-links=<url>`` or ``--[extra-]index-url=<url>``.

    This returns:

    * ``page_candidates``: Links listed on an HTML file.
    * ``file_candidates``: The non-HTML file.
    rN   Úpage_validatorr   r   Nc                 ó.   — || _         || _        || _        y rF   )rQ   Ú_page_validatorr^   )r   rN   ri   r   s       r   r;   z_RemoteFileSource.__init__±   s   € ð &:ˆÔ"Ø-ˆÔØˆ�
r   c                 ó   — | j                   S rF   rb   r   s    r   r   z_RemoteFileSource.link»   rc   r   c              #   óŽ   K  — | j                  | j                  «      sy | j                  | j                  «      E d {  –—†  y 7 Œ­wrF   )rk   r^   rQ   r   s    r   r!   z!_RemoteFileSource.page_candidates¿   s3   è ø€ Ø×#Ñ# D§J¡JÔ/ØØ×-Ñ-¨d¯j©jÓ9×9Ò9ús   ‚;A½A¾Ac              #   ó(   K  — | j                   –— y ­wrF   rb   r   s    r   r$   z_RemoteFileSource.file_linksÄ   s   è ø€ Ø�j‰jÓùs   ‚)r%   r&   r'   rI   rY   ÚPageValidatorr   r;   r(   r   r   r)   r!   r*   r$   r+   r   r   rh   rh   ¨   si   „ ñðà0ðð &ðð ð	ð
 
óð ð�h˜t‘nò ó ðð: ó :ð
˜Jô r   rh   c                   óX   — e Zd ZdZdededdfd„Zedee   fd„«       Z	de
fd„Zdefd	„Zy)
Ú_IndexDirectorySourcez·``--[extra-]index-url=<path-to-directory>``.

    This is treated like a remote URL; ``candidates_from_page`` contains logic
    for this by appending ``index.html`` to the link.
    rN   r   r   Nc                 ó    — || _         || _        y rF   r]   r_   s      r   r;   z_IndexDirectorySource.__init__Ï   r`   r   c                 ó   — | j                   S rF   rb   r   s    r   r   z_IndexDirectorySource.link×   rc   r   c              #   óV   K  — | j                  | j                  «      E d {  –—†  y 7 Œ­wrF   r]   r   s    r   r!   z%_IndexDirectorySource.page_candidatesÛ   s   è ø€ Ø×-Ñ-¨d¯j©jÓ9×9Ò9ús   ‚)¡'¢)c                  ó   — y)Nr+   r+   r   s    r   r$   z _IndexDirectorySource.file_linksÞ   s   € Ør   rf   r+   r   r   rq   rq   È   s_   „ ñðà0ðð ðð 
ó	ð ð�h˜t‘nò ó ðð: ó :ð˜Jô r   rq   ÚlocationrN   ri   Ú
expand_dirÚcache_link_parsingrO   c                óx  — d }d }t         j                  j                  | «      rt        | «      }| }n,| j	                  d«      r| }t        | «      }nt        | «      r| }|€d}t        j                  || «       y|€t        ||t        ||¬«      ¬«      }	||	fS t         j                  j                  |«      r0|rt        |||¬«      }	||	fS t        |t        ||¬«      ¬«      }	||	fS t         j                  j                  |«      rt        |t        ||¬«      ¬«      }	||	fS t        j                  d| «       |d fS )	Nzfile:zVLocation '%s' is ignored: it is either a non-existing path or lacks a specific scheme.)NN)rx   )rN   ri   r   )rN   r4   rO   )rN   r   z?Location '%s' is ignored: it is neither a file nor a directory.)r=   r4   Úexistsr   Ú
startswithr   r   ÚloggerÚwarningrh   r   ÚisdirrL   rq   Úisfiler[   )
rv   rN   ri   rw   rx   rO   r4   rB   ÚmsgÚsources
             r   Úbuild_sourcer‚   â   sP  € ð €DØ€CÜ	‡w�w‡~�~�hÔÜ˜(Ó#ˆØ‰Ø	×	Ñ	˜WÔ	%ØˆÜ˜8Ó$‰Ü	�Ô	Øˆà
€{ðKð 	ô 	�‰�s˜HÔ%Øà€|Ü.Ø!5Ø)Ü�cÐ.@ÔAô
ˆð
 �Vˆ}Ðä	‡w�w‡}�}�TÔÙÜ)Ø%9ØØ)ôˆFð �Vˆ}Ðô	 +Ø%9Ü˜#Ð2DÔEôˆFð �Vˆ}ÐÜ	�‰�‰˜Ô	Ü!Ø!5Ü�cÐ.@ÔAô
ˆð �Vˆ}ÐÜ
‡N�NØIØôð �ˆ;Ðr   )-Úloggingr/   r=   Úcollectionsr   Útypingr   r   r   r   r   r	   Úpip._vendor.packaging.utilsr
   r   r   r   r   r   Úpip._internal.models.candidater   Úpip._internal.models.linkr   Úpip._internal.utils.urlsr   r   Úpip._internal.vcsr   Ú	getLoggerr%   r|   r)   r*   rY   Úboolro   r   rJ   r1   r3   rL   r[   rh   rq   r‚   r+   r   r   ú<module>r�      s8  ðÛ Û Û 	Ý #ß B× B÷÷ õ AÝ *ß =Ý $à	ˆ×	Ñ	˜8Ó	$€àÐ0Ñ1€Ø�d‰^€
Ø˜t˜f hÐ/DÑ&EÐEÑFÐ Ø˜$˜ ˜Ñ&€÷$ñ $ðJ˜Cð J Dó J÷,*ñ ,*ô^%˜:ô %ôP�zô ôB˜
ô ô@˜Jô ð4;Øð;ð -ð;ð "ð	;ð
 ð;ð ð;ð ð;ð ˆ8�C‰=˜( :Ñ.Ð.Ñ/ô;r   