+
    WGj74                    l  a  0 t $ R t^ RIHt ^ RIt^ RIt^ RIt^ RIt^ RIt^ RI	t	^ RI
t
^ RIt^ RIt^ RIHt ^ RIHtHtHt ^ RIt^ RIHtHt ^ RIHt ^ RIHt ^ RIHtHtHtHtH t H!t!H"t" ^ R	I#H$t$ ]PJ                  3t&R
]'R&    ^ RI(H%t% ]&]%3,          t&]'       d   ^ RIH*t*  ! R R]*4      t+ ! R R]*4      t,R R lt-R R lt.Rt/]P`                  ! ]14      t2R R lt3R R lt4R R lt5R R lt6R R  lt7 ! R! R"4      t8R# R$ lt9].3R% R& llt:R' R( lt;R) R* lt<R^ ]-].3R+ R, llt=R#   ]) d     Li ; i)-z0Unpack the link to an installed wheel or source.)annotationsN)Path)TYPE_CHECKINGIterablecast)HashMismatchErrorUnpackError)Fetcher)Link)BZ2_EXTENSIONSTAR_EXTENSIONSXZ_EXTENSIONSZIP_EXTENSIONSdisplay_pathformat_sizeiter_with_callback)vcs_supportztuple[type[Exception], ...]
HTTPErrors)	HTTPError)Protocolc                  "    ] tR t^,tR R ltRtR# )DownloadReporterc               (    V ^8  d   QhRRRRRRRR/# 	   linkr
   	completedinttotal
int | NonereturnNone )formats   "0lib/python3.14/site-packages/unearth/preparer.py__annotate__DownloadReporter.__annotate__-   s    VVV#VjVTV    c                	    R # Nr"   )selfr   r   r   s   &&&&r$   __call__DownloadReporter.__call__-   s    SVr'   r"   N__name__
__module____qualname____firstlineno__r+   __static_attributes__r"   r'   r$   r   r   ,   s    VVr'   r   c                  "    ] tR t^/tR R ltRtR# )UnpackReporterc               (    V ^8  d   QhRRRRRRRR/# 	r   filenamer   r   r   r   r   r    r!   r"   )r#   s   "r$   r%   UnpackReporter.__annotate__0   s,     	 	 	-0	9C		r'   c                	    R # r)   r"   )r*   r7   r   r   s   &&&&r$   r+   UnpackReporter.__call__0   s    r'   r"   Nr-   r"   r'   r$   r4   r4   /   s    	 	r'   r4   c               (    V ^8  d   QhRRRRRRRR/# r   r"   )r#   s   "r$   r%   r%   5   s(     	 	 	# 	j 	T 	r'   c                    R # r)   r"   )r   r   r   s   &&&r$   noop_download_reporterr=   5       r'   c               (    V ^8  d   QhRRRRRRRR/# r6   r"   )r#   s   "r$   r%   r%   9   s(     	 	4 	C 	
 	t 	r'   c                    R # r)   r"   )r7   r   r   s   &&&r$   noop_unpack_reporterrA   9   r>   r'   i    c                    V ^8  d   QhRRRR/# )r   pathstrr    r!   r"   )r#   s   "r$   r%   r%   A   s     3 3S 3T 3r'   c                z    \         P                  ! V R\         P                  ! ^ 4      ( ,          ^I,          4       R# )zl
Make file present at path have execute for user/group/world
(chmod +x) is no-op on windows per python docs
i  N)oschmodumaskrC   s   &r$   2set_extracted_file_to_default_mode_plus_executablerJ   A   s&    
 HHTERXXa[L(502r'   c                    V ^8  d   QhRRRR/# )r   infozzipfile.ZipInfor    boolr"   )r#   s   "r$   r%   r%   I   s     > > >T >r'   c                    V P                   ^,	          p\        T;'       d(    \        P                  ! V4      ;'       d
    V^I,          4      # )   )external_attrrM   statS_ISREG)rL   modes   & r$   zip_item_is_executablerT   I   s<    #D <<d+<<u==r'   c               $    V ^8  d   QhRRRRRR/# )r   	directoryz
str | PathrC   r    rM   r"   )r#   s   "r$   r%   r%   P   s!      : Z D r'   c                `     \        V4      P                  V 4       R#   \         d     R # i ; i)FT)r   relative_to
ValueError)rV   rC   s   &&r$   is_within_directoryrZ   P   s2    T
y)   s    --c                    V ^8  d   QhRRRR/# )r   rC   rD   r    z	list[str]r"   )r#   s   "r$   r%   r%   X   s     	 	C 	I 	r'   c                   V P                  R 4      P                  R4      p R V 9   dF   RV 9   d&   V P                  R 4      V P                  R4      8  g   RV 9  d   V P                  R ^4      # RV 9   d   V P                  R^4      # V R.# )/\ )lstripfindsplitrI   s   &r$   split_leading_dirrc   X   sz    ;;s""4(D
d{	$))C.499T?:t4?Ozz#q!!	zz$""bzr'   c                    V ^8  d   QhRRRR/# )r   pathszIterable[str]r    rM   r"   )r#   s   "r$   r%   r%   d   s      = T r'   c                n    RpV  F,  p\        V4      w  r4V'       g    R# Vf   TpK#  W18w  g   K+   R# 	  R# )zuReturns true if all the paths have the same leading path name
(i.e., everything is in one subdirectory in an archive)NFT)rc   )re   common_prefixrC   prefix_s   &    r$   has_leading_dirrj   d   s>     M%d+	""M$  r'   c                  J    ] tR t^stRtR R ltR R ltR R ltR R	 ltR
t	R# )HashValidatorzValidate the hashes of a file.c               $    V ^8  d   QhRRRRRR/# )r   package_linkr
   hashesdict[str, list[str]] | Noner    r!   r"   )r#   s   "r$   r%   HashValidator.__annotate__v   s(     P PT P3N PSW Pr'   c                	J   Ve.   VP                  4        UUu/ uF  w  r4V\        V4      bK  	  pppW n        Wn        / V n        Ve0   V F'  p \
        P                  ! V4      V P                  V&   K)  	  R # R # u uppi   \        \        3 d    \        RT: 24      R hi ; i)NzUnknown hash name: )
itemssortedallowedrn   gothashlibnew	TypeErrorrY   r   )r*   rn   ro   kvaluenames   &&&   r$   __init__HashValidator.__init__v   s    7=||~F~81a&~FF(P%,[[%6DHHTN  	 G ":. P%(;D8&DE4OPs   A:#B  "B"c                    V ^8  d   QhRRRR/# )r   chunkbytesr    r!   r"   )r#   s   "r$   r%   rq      s     ! !E !d !r'   c                	j    V P                   P                  4        F  pVP                  V4       K  	  R # r)   )rv   valuesupdate)r*   r   hashers   && r$   r   HashValidator.update   s#    hhoo'FMM%  (r'   c                   V ^8  d   QhRR/# )r   r    r!   r"   )r#   s   "r$   r%   rq      s     	G 	G$ 	Gr'   c                	   V P                   '       g   R # / pV P                   P                  4        F3  w  r#V P                  V,          P                  4       pWC9   d    R # WAV&   K5  	  \	        V P
                  V P                   V4      hr)   )ru   rs   rv   	hexdigestr   rn   )r*   gotsr|   	hash_listrv   s   &    r$   validateHashValidator.validate   sm    |||!#||113OD((4.**,CJ	  4
   1 14<<FFr'   c                    V ^8  d   QhRRRR/# )r   rC   r   r    r!   r"   )r#   s   "r$   r%   rq      s      $ 4 r'   c                	   a VP                  R 4      ;_uu_ 4       o\        V3R lR4       F  pV P                  V4       K  	  RRR4       V P                  4        R#   + '       g   i     L"; i)rbc                 .   < S P                  \        4      # r)   )readREAD_CHUNK_SIZE)fs   r$   <lambda>-HashValidator.validate_path.<locals>.<lambda>   s    aff_&=r'   r'   N)openiterr   r   )r*   rC   r   r   s   && @r$   validate_pathHashValidator.validate_path   sI    YYt__=sCE" D  	 _s   )AA.	)ru   rv   rn   N)
r.   r/   r0   r1   __doc__r}   r   r   r   r2   r"   r'   r$   rl   rl   s   s     (P!	G r'   rl   c               $    V ^8  d   QhRRRRRR/# )r   rC   r   ro   rp   r    rM   r"   )r#   s   "r$   r%   r%      s"      D *E $ r'   c                2   V P                  4       '       g   R#  \        \        P                  ! V 4      V4      P	                  V 4       \        P                  RT 4       R#   \
         d+    \        P                  RT 4       T P                  4         R# i ; i)z&Check if the file has been downloaded.Fz-File exists at %s, but the hashes don't matchz"The file is already downloaded: %sT)	is_filerl   r
   	from_pathr   r   loggerdebugunlink)rC   ro   s   &&r$   _check_downloadedr      ss    <<>>dnnT*F3AA$G
 LL5t<  DdKs   /A! !1BBc               (    V ^8  d   QhRRRRRRRR/# )r   archiver   destreporterr4   r    r!   r"   )r#   s   "r$   r%   r%      s2     C CCC)7C	Cr'   c                   \         P                  ! \        V 4      4      ^ ,          pVR8X  g@   \        P                  ! V 4      '       g$   V P
                  P                  4       \        9   d   \        WVR7       R# VR8X  gV   \        P                  ! V 4      '       g:   V P
                  P                  4       \        \        ,           \        ,           9   d   \        WVR7       R# \        RV P                    24      h)    zapplication/zipr   zapplication/x-gzipzUnknown archive type: N)	mimetypes
guess_typerD   zipfile
is_zipfilesuffixlowerr   _unzip_archivetarfile
is_tarfiler   r   r   _untar_archiver   r|   )r   r   r   content_types   &&& r$   unpack_archiver      s     ''G5a8L))g&&>>!^3wx8,,g&&>>!n}&D~&UVwx827<<.ABBr'   c               (    V ^8  d   QhRRRRRRRR/# r   r7   r   locationr   r4   r    r!   r"   )r#   s   "r$   r%   r%      s/     K KT KT K^ KPT Kr'   c                   \         P                  ! VR R7       \        V R4      p\        P                  ! VR R7      ;_uu_ 4       p\        VP                  4       4      p\        P                  ! W \        VP                  4       4      R7      p\        VP                  4       V4       EFf  pVP                  pTp	V'       d   \        V4      ^,          p	\         P                  P                  W4      p	\         P                  P!                  V	4      p
\#        W4      '       g   RV  RV	 RV R2p\%        V4      hV	P'                  R	4      '       g   V	P'                  R
4      '       d   \         P                  ! V	R R7       K  \         P                  ! V
R R7       VP                  V4      ;_uu_ 4       p\        V	R4      ;_uu_ 4       p\(        P*                  ! W4       RRR4       RRR4       \-        V4      '       g   EK[  \/        V	4       EKi  	  RRR4       R#   + '       g   i     LF; i  + '       g   i     LQ; i  + '       g   i     R# ; i)Texist_okr   )
allowZip64r   zThe zip file () has a file (.) trying to install outside target directory ()r]   r^   wbN)rF   makedirsr   r   ZipFilerj   namelist	functoolspartialleninfolistr   r7   rc   rC   joindirnamerZ   r   endswithshutilcopyfileobjrT   rJ   )r7   r   r   zipfpzipleadingcallbackrL   r|   fndirmessagefpdestfps   &&&           r$   r   r      s   KK4(4 E	4	0	0C!#,,.1$$Xs3<<>?RS&s||~x@D==DB&t,Q/h+B''//"%C&x44$XJnRD A119
!=  "'**{{32;;t#4#4B.C$/ XXd^^r4D>>V&&r2 ,:^ *$//FrJ1 A 
1	0. ,:>^^/ 
1	0	0sP   DII(AI3H0HH0'IIH-(H00I ;II	c               (    V ^8  d   QhRRRRRRRR/# r   r"   )r#   s   "r$   r%   r%      s5     EM EMT EMT EM^ EMPT EMr'   c           
     r   \         P                  ! VRR7       \        V 4      P                  4       pVP	                  R4      '       g   VP	                  R4      '       d   RpMnVP	                  \
        4      '       d   RpMPVP	                  \        4      '       d   RpM2VP	                  R4      '       d   R	pM\        P                  R
V 4       Rp\        P                  ! WRR7      ;_uu_ 4       p\        VP                  4        Uu. uF  qfP                  NK  	  up4      p\        P                  ! W \!        VP                  4       4      R7      p\#        VP                  4       V4       EF  pVP                  p	V'       d   \%        V	4      ^,          p	\         P&                  P)                  W4      p
\+        W4      '       g   RV  RV
 RV R2p\-        V4      hVP/                  4       '       d   \         P                  ! V
RR7       K  VP1                  4       '       d    VP3                  Wj4       K   VP7                  V4      p\         P                  ! \         P&                  P=                  T
4      RR7       Tf   Q h\        T
R4      ;_uu_ 4       p\>        P@                  ! Y4       RRR4       TPC                  4        TPE                  Yj4       TPF                  ^I,          '       g   EK  \I        T
4       EK  	  RRR4       R# u upi   \4         d/   p\        P                  RT TP                  T4        Rp?EK  Rp?ii ; i  \8        \:        3 d/   p\        P                  RT TP                  T4        Rp?EK  Rp?ii ; i  + '       g   i     L; i  + '       g   i     R# ; i)zDUntar the file (with path `filename`) to the destination `location`.Tr   z.gzz.tgzzr:gzzr:bz2zr:xzz.tarrz-Cannot determine compression type for file %szr:*zutf-8)encodingr   zThe tar file (r   r   r   z/In the tar file %s the member %s is invalid: %sNr   )%rF   r   rD   r   r   r   r   r   warningr   r   rj   
getmembersr|   r   r   r   r   rc   rC   r   rZ   r   isdirissym_extract_member	ExceptionextractfileKeyErrorAttributeErrorr   r   r   closeutimerS   rJ   )r7   r   r   lower_fnrS   tarmemberr   r   r   rC   r   excr   r   s   &&&            r$   r   r      s   KK4(8}""$H8#4#4V#<#<			>	*	*			=	)	)			6	"	";	
 	hw	7	73!S^^=M"N=M6;;=M"NO$$Xs3>>CS?TU()98DFB&r*1-77<<-D&x66$XJnTF C119
!=  "'**||~~D40''50B BGGOOD1DA~%~$%%&&r2 &
		&';;&&FtLa E 
8	7"N$ ! 	 NNI 	 	 !.1 	 NNI 	 	 &%Y 
8	7	7s   1N%	LCN%4/N%%L6N%9M
AN%N0?N%5N%N%M	"M	N%M	N%N	!"N
	N%
N	N%N"N%%N6	c               <    V ^8  d   QhRRRRRRRRRR	R
RRRRRRR/	# )r   sessionr	   r   r
   download_dirr   r   ro   rp   	verbosityr   download_reporterr   unpack_reporterr4   r    r"   )r#   s   "r$   r%   r%   %  sm     S SS
S S 	S
 (S S (S $S 
Sr'   c           
        VP                   P                  RRR7       VP                  '       dX   \        P                  ! \        \        VP                  4      VR7      pV! V^ ^4       VP                  W4       V! V^^4       V# \        W4      p	VP                  '       du   VP                  P                  4       '       d6   \        P                  R\        VP                  4      4       VP                  # VP                  p
V	P!                  V
4       EMW!P"                  ,          p
\%        W4      '       Egc   V P'                  VP(                  4      ;_uu_ 4       p VP+                  4         \1        TP2                  R,          4      p\;        TRR	4      '       d   \        P                  R
T4       M;\=        TP2                  P?                  RR4      4      p\        P                  RY4       T
PA                  R4      ;_uu_ 4       p\B        PD                  ! YaTR7      p\G        TPI                  \J        R7      T\L        R7       F/  pT'       g   K  T	PO                  T4       TPQ                  T4       K1  	  RRR4       RRR4       T	PS                  4        VPT                  '       dG   VP                  '       d   V
# W1P"                  ,          pVV
8w  d   \V        PX                  ! V
V4       V# \[        WVR7       V#   \,         d   p\/        RT 24      RhRp?ii ; i  \4        \6        \8        3 d    Rp ELi ; i  + '       g   i     L; i  + '       g   i     L; i)a  Unpack link into location.

The link can be a VCS link or a file link.

Args:
    session (Fetcher): the requests session
    link (Link): the link to unpack
    download_dir (Path): the directory to download the file to
    location (Path): the destination directory
    hashes (dict[str, list[str]]|None): Optional hash dict for validation
    progress_bar (bool): whether to show the progress bar

Returns:
    Path: the path to the unpacked file or directory
T)parentsr   )r   z1The file %s is a local directory, use it directlyzDownload failed: NzContent-Length
from_cacheFzUsing cached %sr_   zDownloading %s (%s)r   r   )
chunk_size)stepperr   ).parentmkdiris_vcsr   get_backendr   rD   vcsfetchrl   r   	file_pathis_dirr   rL   r   r   r7   r   
get_stream
normalizedraise_for_statusr   r   r   headersr   rY   ry   getattrr   getr   r   r   r   
iter_bytesr   r   r   writer   is_wheelrF   replacer   )r   r   r   r   ro   r   r   r   backend	validatorartifactresper   sizer   r   r   target_files   &&&&&&&&           r$   unpack_linkr  %  s   2 OO$6{{{))$sDHH*=S$1%d%$1%d+I|||>>  ""KKCT^^, >>!>>)  --/ 22##DOO44I))+!-= >?E 4u55KK 148&t||'7'78H"'MNDKK 5tB]]4((A(001BPUVH!3?C  #"
 !5%,,U3GGEN" ) 50  }}}<<<O.("JJx-8@OC " I%(9!&=>DHI !*i8 ! E! )( 54sn   M!L2L'A>MAM	&M	>ML$LL$$M'M?MMMMMM)	)>__conditional_annotations__r   
__future__r   r   rw   loggingr   rF   r   rQ   r   r   pathlibr   typingr   r   r   httpxunearth.errorsr   r   unearth.fetchersr	   unearth.linkr
   unearth.utilsr   r   r   r   r   r   r   unearth.vcsr   r   r   __annotations__requestsModuleNotFoundErrorr   r   r4   r=   rA   r   	getLoggerr.   r   rJ   rT   rZ   rc   rj   rl   r   r   r   r   r  )r  s   @r$   <module>r     s,   6 "     	      0 0  9 $    $+0??*<
' <	"9,J W8 W 		 			8	$3>	$ $N ;OC(KBEMZ +/*@&:S S  		s   D) )D32D3