ó
    ‰óýj²  ã            
       óH  • S r SSKrSSKrSSKrSSKrSSKrSSKrSSKrSSKrSSK	J
r
  SSKJrJrJr  SSKJr  SSKJr  SSKJr  SSKJr  SS	KJr  SS
KJrJrJrJr  \(       a  SSKJr  SSK J!r!J"r"  \" S\#5      r$\%\$S4   r&/ SQr'\RP                  S:H  r)\)(       a  SOSr*\RV                  " S\RX                  \RZ                  -  5      r.\
" S/ SQ5      r/\RV                  " S\RX                  \RZ                  -  5      r0\" SS5      r1S\#S\4S jr2S\#S\#4S jr3S\#S\/4S jr4S \S!\S"\#S\%\#\54   4S# jr6S \S\54S$ jr7S4S% jr8\Rr                  S&\S'\#S\\   4S( j5       r:S) 4S*\\%\$S+4      S,\\$/\#S-  4   S\4S- jjr;S.\#S\\%\#\#\#S/4      4S0 jr<S\54S1 jr=S2\SS4S3 jr>g)5z=Utilities related to handling / interacting with wheel files.é    N)Ú
namedtuple)ÚCallableÚIterableÚIterator)ÚConfigParser)ÚMessage)Ú
FeedParser)Úcompat32)ÚPath)ÚTYPE_CHECKINGÚBinaryIOÚNewTypeÚcast)ÚRecordEntry)ÚLauncherKindÚScriptSectionÚScheme.)
ÚSCHEME_NAMESÚWheelFilenameÚconstruct_record_fileÚcopyfileobj_with_hashingÚfix_shebangÚget_launcher_kindÚmake_file_executableÚparse_entrypointsÚparse_metadata_fileÚparse_wheel_filenameÚnti   i   z‡
    ^
    (?P<distribution>.+?)
    -(?P<version>.*?)
    (?:-(?P<build_tag>\d[^-]*?))?
    -(?P<tag>.+?-.+?-.+?)
    \.whl
    $
    r   )ÚdistributionÚversionÚ	build_tagÚtagzZ
    (?P<module>[\w.]+)\s*
    (:\s*(?P<attrs>[\w.]+))\s*
    (?P<extras>\[.*\])?\s*$
    Ú
AllSchemes)ÚpurelibÚplatlibÚheadersÚscriptsÚdataÚcontentsÚreturnc                 ó^   • [        [        S9nUR                  U 5        UR                  5       $ )zÜParse :pep:`376` ``PKG-INFO``-style metadata files.

``METADATA`` and ``WHEEL`` files (as per :pep:`427`) use the same syntax
and can also be parsed using this function.

:param contents: The entire contents of the file
)Úpolicy)r	   r
   ÚfeedÚclose)r)   Úfeed_parsers     Ú:/usr/local/lib/python3.13/site-packages/installer/utils.pyr   r   P   s+   € ô ¤HÑ-€KØ×Ñ�XÔØ×ÑÓÐó    Únamec                 óN   • [         R                  " SSU 5      R                  5       $ )zaCanonicalize a project name according to PEP-503.

:param name: The project name to canonicalize
z[-_.]+Ú-)ÚreÚsubÚlower)r2   s    r0   Úcanonicalize_namer8   ]   s    € ô
 �6Š6�)˜S $Ó'×-Ñ-Ó/Ð/r1   Úfilenamec                 ó‚   • [         R                  U 5      nU(       d  [        SU  35      e[        UR	                  5       6 $ )z^Parse a wheel filename, into it's various components.

:param filename: The filename to parse
zNot a valid wheel filename: )Ú_WHEEL_FILENAME_REGEXÚmatchÚ
ValueErrorr   Úgroups)r9   Ú
wheel_infos     r0   r   r   e   s>   € ô
 '×,Ñ,¨XÓ6€JÞÜÐ7¸°zÐBÓCÐCÜ˜*×+Ñ+Ó-Ð.Ð.r1   ÚsourceÚdestÚhash_algorithmc                 óZ  • [         R                  " U5      nSn U R                  [        5      nU(       d  O2UR	                  U5        UR                  U5        U[        U5      -  nMO  [        R                  " UR                  5       5      R                  S5      R                  S5      U4$ )aw  Copy a buffer while computing the content's hash and size.

Copies the source buffer into the destination buffer while computing the
hash of the contents. Adapted from :any:`shutil.copyfileobj`.

:param source: buffer holding the source data
:param dest: destination buffer
:param hash_algorithm: hashing algorithm

:return: hash digest of the contents, size of the contents
r   ÚasciiÚ=)ÚhashlibÚnewÚreadÚ_COPY_BUFSIZEÚupdateÚwriteÚlenÚbase64Úurlsafe_b64encodeÚdigestÚdecodeÚrstrip)r@   rA   rB   ÚhasherÚsizeÚbufs         r0   r   r   p   s�   € ô  �[Š[˜Ó(€FØ€DØ
Ø�k‰kœ-Ó(ˆÞØØ�‰�cÔØ�
‰
�3ŒØ”�C“Ñˆñ ô ×#Ò# F§M¡M£OÓ4×;Ñ;¸GÓD×KÑKÈCÓPÐRVÐVÐVr1   c                 óf   • Sn U R                  [        5      nU(       d   U$ U[        U5      -  nM/  )zRead a buffer while computing the content's size.

:param source: buffer holding the source data
:return: size of the contents
r   )rH   rI   rL   )r@   rS   rT   s      r0   Úget_stream_lengthrV   �   s<   € ð €DØ
Ø�k‰kœ-Ó(ˆÞØð €Kð 	”�C“Ñˆñ	 r1   c                  ó>  • [         R                  S:w  a  gS[        R                  R	                  5       ;   a  gS[        R                  R	                  5       ;   a  gS[        R                  R	                  5       ;   a  g[        R
                  S	:X  a  g
[        S5      e)z.Get the launcher kind for the current machine.r   ÚposixÚamd64z	win-amd64z(arm64)z	win-arm64z(arm)zwin-armÚwin32zwin-ia32z&Unknown launcher kind for this machine)Úosr2   Úsysr    r7   ÚplatformÚNotImplementedError© r1   r0   r   r   �   ss   € ä	‡w�w�$ƒØà”#—+‘+×#Ñ#Ó%Ó%ØØ”C—K‘K×%Ñ%Ó'Ó'ØØ”#—+‘+×#Ñ#Ó%Ó%ØÜ
‡|�|�wÓØä
ÐFÓ
GÐGr1   ÚstreamÚinterpreterc              #   óâ  #   • U R                  S5        U R                  S5      S:X  a°  [        R                  " 5       nUR	                  SU S3R                  5       5        U R                  S5        U R                  5          U R                  [        5      nU(       d  OUR	                  U5        M0  UR                  S5        Uv •  UR                  5         gU R                  S5        U v •  g7f)zÿReplace ``#!python`` shebang in a stream with the correct interpreter.

:param stream: stream to modify
:param interpreter: "correct interpreter" to substitute the shebang with

:returns: A context manager, that provides an appropriately modified stream.
r   é   s   #!pythonz#!Ú
N)	ÚseekrH   ÚioÚBytesIOrK   ÚencodeÚreadlinerI   r.   )r`   ra   Ú
new_streamrT   s       r0   r   r   ®   s¼   é € ð ‡K�K�„NØ‡{�{�1ƒ~˜Ó$Ü—Z’Z“\ˆ
à×Ñ˜2˜k˜]¨"Ð-×4Ñ4Ó6Ô7à�‰�AŒØ�‰ÔØØ—+‘+œmÓ,ˆCÞØØ×Ñ˜SÔ!ñ	 ð
 	�‰˜ÔØÒØ×ÑÕà�‰�AŒØ‹ùs   ‚C-C/c                 ó   • g )Nr_   )Ú_s    r0   Ú<lambda>rm   Î   s   € À$r1   Úrecordsr   Úprefix_for_schemec                 ó:  • [         R                  " [         R                  " 5       SSSS9n[        R                  " USSSS9n[        U S	 S
9 H+  u  pEUR                  UR                  U" U5      5      5        M-     UR                  S5        UR                  5       $ )a'  Construct a RECORD file.

:param records:
    ``records`` as passed into :any:`WheelDestination.finalize_installation`
:param prefix_for_scheme:
    function to get a prefix to add for RECORD entries, within a scheme

:return: A stream that can be written to file. Must be closed by the caller.
zutf-8TÚ )ÚencodingÚwrite_throughÚnewlineÚ,Ú"rd   )Ú	delimiterÚ	quotecharÚlineterminatorc                 ó    • U S   R                   $ )Né   ©Úpath)Úxs    r0   rm   Ú'construct_record_file.<locals>.<lambda>Ý   s   € ¸¸!¹¿	º	r1   )Úkeyr   )
rf   ÚTextIOWrapperrg   ÚcsvÚwriterÚsortedÚwriterowÚto_rowre   Údetach)rn   ro   r`   rƒ   ÚschemeÚrecords         r0   r   r   Ì   s€   € ô ×ÒÜ
�
Š
‹˜w°dÀBñ€Fô �ZŠZ˜¨#¸ÈTÑR€FÜ  Ñ.AÔB‰ˆØ�‰˜Ÿ™Ñ&7¸Ó&?Ó@ÖAñ Cà
‡K�K�„NØ�=‰=‹?Ðr1   Útextr   c           
   #   ó  #   • [        SS9n[        Ul        UR                  U 5        UR	                  5        HÎ  nUS;  a  M  UR                  U5       H®  u  p4[        U[        5      (       d   e[        R                  U5      nU(       d   eUR                  S5      n[        U[        5      (       d   eUR                  S5      nUc   e[        U[        5      (       d   e[        SUS[        S5      *  5      nX6Xx4v •  M°     MÐ     g7f)	z°Parse ``entry_points.txt``-style files.

:param text: entire contents of the file
:return:
    name of the script, module to use, attribute to call, kind of script (cli / gui)
rE   )Ú
delimiters)Úconsole_scriptsÚgui_scriptsÚmoduleÚattrsNr   Ú_scripts)r   ÚstrÚoptionxformÚread_stringÚsectionsÚitemsÚ
isinstanceÚ_ENTRYPOINT_REGEXr<   Úgroupr   rL   )	rŠ   ÚconfigÚsectionr2   Úvaluer<   r�   r�   Úscript_sections	            r0   r   r   ã   s÷   é € ô  SÑ)€FÜ€FÔØ
×Ñ�tÔà—?‘?Ö$ˆØÐ<Ó<Ùà!Ÿ<™<¨Ö0‰KˆDÜ˜d¤C×(Ñ(Ð(Ð(Ü%×+Ñ+¨EÓ2ˆEÞˆL�5à—[‘[ Ó*ˆFÜ˜f¤c×*Ñ*Ð*Ð*à—K‘K Ó(ˆEàÑ$Ð$Ð$Ü˜e¤S×)Ñ)Ð)Ð)ä! /°7Ð;M¼cÀ*»oÐ=MÐ3NÓOˆNà Ð5Ô5ó 1ò	 %ùs   ‚D	Dc                  ó^   • [         R                  " S5      n [         R                  " U 5        U $ )zBGet the current umask which involves having to set it temporarily.r   )r[   Úumask)Úmasks    r0   Ú_current_umaskr¡     s   € ä�8Š8�A‹;€DÜ‡H‚HˆT„NØ€Kr1   r}   c                 óD   • U R                  S[        5       ) -  S-  5        g)z.Make the file at the provided path executable.iÿ  éI   N)Úchmodr¡   r|   s    r0   r   r     s   € à‡J�JˆuœÓ(Ð(Ñ(¨5Ñ0Õ1r1   )r*   r   )?Ú__doc__rM   Ú
contextlibr‚   rF   rf   r[   r5   r\   Úcollectionsr   Úcollections.abcr   r   r   Úconfigparserr   Úemail.messager   Úemail.parserr	   Úemail.policyr
   Úpathlibr   Útypingr   r   r   r   Úinstaller.recordsr   Úinstaller.scriptsr   r   r’   r   Útupler#   Ú__all__r2   Ú_WINDOWSrI   ÚcompileÚVERBOSEÚUNICODEr;   r   r˜   r   r   r8   r   Úintr   rV   r   Úcontextmanagerr   r   r   r¡   r   r_   r1   r0   Ú<module>r¹      s=  ðÙ Cã Û Û 
Û Û 	Û 	Û 	Û 
Ý "ß 8Ñ 8Ý %Ý !Ý #Ý !Ý ÷ó ö Ý-ß=á	�˜3Ó	€Ø�6˜3�;Ñ€
ò€ð �7‰7�d‰?€Þ'‘¨Y€ð Ÿ
š
ðð ‡J�J�—‘ÑóÐ ñ ØÒDó€ð
 —J’Jðð
 ‡J�J�—‘ÑóÐ ñ �LÐ"VÓW€ð
 #ð 
¨'ô 
ð0˜Cð 0 Cô 0ð/ 3ð /¨=ô /ðWØðWà
ðWð ðWð ˆ3�ˆ8�_ô	Wð:˜hð ¨3ô ô Hð" ×Ñð˜ð ¨sð °xÀÑ7Ió ó ðñ> 9GñØ�e˜F MÐ1Ñ2Ñ3ðà  ¨#°©*Ð 4Ñ5ðð õð.6˜Cð 6 H¨U°3¸¸SÀ/Ð3QÑ-RÑ$Sô 6ðD˜ô ð2˜tð 2¨õ 2r1   