
    -j5                       S r SSKJ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  SSKJr  SSKJrJrJrJr  SSKJr  \R,                  " \5      r\\-   r SSKr\\-  r SSKr\\-  rSS jrSS jrSS jr SS jr!SS jr"SS jr#SS jr$SSS jjr%SS jr&S S jr'          S!S jr( S"       S#S jjr)g! \ a    \R9                  S	5         Nvf = f! \ a    \R9                  S
5         Nf = f)$zUtilities related archives.    )annotationsN)Iterable)ZipInfo)InstallationError)BZ2_EXTENSIONSTAR_EXTENSIONSXZ_EXTENSIONSZIP_EXTENSIONS)
ensure_dirzbz2 module is not availablezlzma module is not availablec                 ^    [         R                  " S5      n [         R                  " U 5        U $ )zBGet the current umask which involves having to set it temporarily.r   )osumask)masks    U/mnt/data/Frawley/.venv/lib/python3.13/site-packages/pip/_internal/utils/unpacking.pycurrent_umaskr   -   s    88A;DHHTNK    c                
   U R                  S5      R                  S5      n SU ;   aB  SU ;   a$  U R                  S5      U R                  S5      :  d  SU ;  a  U R                  SS5      $ SU ;   a  U R                  SS5      $ U S/$ )N/\    )lstripfindsplitpaths    r   split_leading_dirr   4   sz    ;;s""4(D
d{	$))C.499T?:t4?Ozz#q!!	zz$""bzr   c                b    SnU  H'  n[        U5      u  p4U(       d    gUc  UnM   X1:w  d  M'    g   g)zuReturns true if all the paths have the same leading path name
(i.e., everything is in one subdirectory in an archive)NFT)r   )pathscommon_prefixr   prefixrests        r   has_leading_dirr#   @   s>     M(.""M$  r   c                    [         R                  R                  U 5      n[         R                  R                  U5      nX2:H  =(       d"    UR                  U[         R                  -   5      $ )zw
Return true if the absolute path of target is within the directory
(including when target is equal to the directory).
)r   r   abspath
startswithsep)	directorytargetabs_directory
abs_targets       r   is_within_directoryr,   O   sM    
 GGOOI.M(J&W**?*?PRPVPV@V*WWr   c                 $    S[        5       ) -  S-  $ )Ni  I   )r    r   r   !_get_default_mode_plus_executabler0   Z   s    MO##e++r   c                B    [         R                  " U [        5       5        g)zl
Make file present at path have execute for user/group/world
(chmod +x) is no-op on windows per python docs
N)r   chmodr0   r   s    r   2set_extracted_file_to_default_mode_plus_executabler3   ^   s    
 HHT467r   c                    U R                   S-	  n[        U=(       a"    [        R                  " U5      =(       a    US-  5      $ )N   r.   )external_attrboolstatS_ISREG)infomodes     r   zip_item_is_executabler<   f   s6    #D <d+<u==r   c                   [        U5        [        U S5      n [        R                  " USS9n[	        UR                  5       5      =(       a    UnUR                  5        GH+  nUR                  nUnU(       a  [        U5      S   n[        R                  R                  X5      n[        R                  R                  U5      n	[        X5      (       d  Sn
[        U
R                  XU5      5      eUR!                  S5      (       a  [        U5        M  [        U	5        UR                  U5      n [        US5       n["        R$                  " X5        SSS5        UR'                  5         [)        U5      (       a  [+        U5        GM+  GM.     UR'                  5         g! , (       d  f       NR= f! UR'                  5         [)        U5      (       a  [+        U5        f f = f! UR'                  5         f = f)	a  
Unzip the file (with path `filename`) to the destination `location`.  All
files are written based on system defaults and umask (i.e. permissions are
not preserved), except that regular file members with any execute
permissions (user, group, or world) have "chmod +x" applied after being
written. Note that for windows, any execute changes using os.chmod are
no-ops per the python docs.
rbT)
allowZip64r   zQThe zip file ({}) has a file ({}) trying to install outside target directory ({}))r   r   wbN)r   openzipfileZipFiler#   namelistinfolistfilenamer   r   r   joindirnamer,   r   formatendswithshutilcopyfileobjcloser<   r3   )rF   locationflattenzipfpzipleadingr:   namefndirmessagefpdestfps                r   
unzip_filerY   m   sy    x4 E ooe5!#,,.1=gLLND==DB&t,Q/h+B''//"%C&x444  (xX(NOO{{;''23 XXd^Ob$6**26 ( HHJ-d33J2N 45 #: 	 ( HHJ-d33J2N 4 	s<   DG# 2F2>F!F23G# !
F/	+F22.G  G# #G5c                \  ^ ^^^ [        T5        T R                  5       R                  S5      (       d$  T R                  5       R                  S5      (       a  SnOT R                  5       R                  [        5      (       a  SnOjT R                  5       R                  [        5      (       a  SnO?T R                  5       R                  S5      (       a  SnO[
        R                  ST 5        S	n[        R                  " T US
S9n [        UR                  5        Vs/ s H  oDR                  PM     sn5      n [        R                  m[        5       mU(       ao  UR                  5        H[  n[        UR                  5      u  pgXtl        UR                  5       (       d  M7  [        UR                   5      u  pX:X  d  MU  Xl        M]     SUUU U4S jjn
UR#                  TU
S9  UR)                  5         gs  snf ! [$         a    ['        T TX55         N/f = f! UR)                  5         f = f)a  
Untar the file (with path `filename`) to the destination `location`.
All files are written based on system defaults and umask (i.e. permissions
are not preserved), except that regular file members with any execute
permissions (user, group, or world) have "chmod +x" applied on top of the
default.  Note that for windows, any execute changes using os.chmod are
no-ops per the python docs.
z.gzz.tgzzr:gzzr:bz2zr:xzz.tarrz-Cannot determine compression type for file %szr:*zutf-8)encodingc                  > U R                   n  T" U T5      n U R                  5       (       a  US-  (       a	  TU l         U $ S U l         U $ ! [        R                   a2    [        R                  S S S;   a  [        R
                  " U T5      n  Nue f = f! [        R                   a"  nSn[        UR                  TU5      5      eS nAff = f)N   >   r^   	      r^   
      r^         z%Invalid member in the tar file {}: {}r.   )
r;   tarfileLinkOutsideDestinationErrorsysversion_info
tar_filterTarErrorr   rI   isfile)	memberr   	orig_modeexcrV   data_filterdefault_mode_plus_executablerF   rN   s	        r   
pip_filteruntar_file.<locals>.pip_filter   s    "KK	"!,VX!>2 ==??y5'8">FK  #'FKA #>> "++BQ/ 4  &-%7%7%IF!" '' 	EG ,$ 		s0   	A
 
ABB BB C	'CC	)filterN)ro   tarfile.TarInfor   strreturnrw   )r   lowerrJ   r   r	   loggerwarningrh   rA   r#   
getmembersrS   rr   r0   r   islnklinkname
extractallAttributeError_untar_without_filterrM   )rF   rN   r;   tarro   rR   	name_lead	name_restlnk_leadlnk_restrt   rr   rs   s   ``         @@r   
untar_filer      s    x~~  ''8>>+;+D+DV+L+L			"	">	2	2			"	"=	1	1			"	"6	*	*;	
 
,,x
8CC!S^^=M"N=M6;;=M"NO
:	8!--K ,M+N( "nn.F+<V[[+I(I"+K||~~->v-O*#0.6O /% %N NN8JN7 			E #O  	D!(HcC	Dv 			sO   H G73H ;G< AH #H %H 7H <HH HH H+c                L   [         R                  R                  [         R                  R                  UR                  5      UR
                  5      n[         R                  R                  U5      nUR                  SS5      n U R                  U5        g! [         a     gf = f)zGCheck if the file pointed to by the symbolic link is in the tar archiver   r   TF)
r   r   rG   rH   rS   r   normpathreplace	getmemberKeyError)r   tarinfor   s      r   is_symlink_target_in_tarr      sy    ww||BGGOOGLL97;K;KLHww)Hc*Hh s   B 
B#"B#c                   UR                  5        GH  nUR                  nU(       a  [        U5      S   n[        R                  R                  X5      n[        X5      (       d  Sn[        UR                  XU5      5      eUR                  5       (       a  [        U5        M  UR                  5       (       aU  [        X$5      (       d1  Sn[        UR                  XR                  UR                  5      5      e UR                  XF5        M   UR%                  U5      n	[        [        R                  R+                  U5      5        U	c   e[-        US5       n
[.        R0                  " X5        SSS5        U	R3                  5         UR5                  XF5        UR6                  S-  (       d  GM  [9        U5        GM     g! [         a.  n[         R#                  SU UR                  U5         SnAGM  SnAff = f! [&        [(        4 a.  n[         R#                  SU UR                  U5         SnAGM$  SnAff = f! , (       d  f       N= f)z/Fallback for Python without tarfile.data_filterr   zQThe tar file ({}) has a file ({}) trying to install outside target directory ({})z/In the tar file %s the member %s is invalid: %sNr@   r.   )r}   rS   r   r   r   rG   r,   r   rI   isdirr   issymr   r   _extract_member	Exceptionr{   r|   extractfiler   r   rH   rA   rK   rL   rM   utimer;   r3   )rF   rN   r   rR   ro   rT   r   rV   rq   rW   rX   s              r   r   r   	  s    .."[["2&q)Bww||H)"8220  $GNN88$LMM<<>>t\\^^+C884  (NN8[[&//J ##F1__V, rwwt,->!>dD!V""2. "HHJIIf#{{U""B4Hq #0  	 EKK	 	 n- 	 EKK	 	 "!s<   ;GG<H=
G9"G44G9<H:"H55H:=
I	c                  ^ ^^ [         R                  R                  T 5      m T R                  S5      (       + mS	U UU4S jjnS	U U4S jjnUS:X  a  U" 5       $ US:X  a  U" 5       $ T R	                  5       R                  [
        5      (       a  U" 5       $ T R	                  5       R                  [        [        -   [        -   5      (       a  U" 5       $ [        R                  " T 5      n[        R                  " T 5      nU(       a  U(       d  U" 5       $ U(       a  U(       d  U" 5       $ U(       a  U(       a  [        R                  ST 5        [        R                  ST TU5        [!        ST 35      e)
zUnpack ``filename`` into ``location``.

Archive format is chosen in order of decreasing reliability:
``content_type``, then filename extension, then magic signature
(unambiguous matches only).
z.whlc                    > [        T TTS9  g )N)rO   )rY   )rF   rN   zip_flattens   r   _unzipunpack_file.<locals>._unzip\  s    8X{;r   c                    > [        T T5        g N)r   )rF   rN   s   r   _untarunpack_file.<locals>._untar_  s    8X&r   zapplication/zipzapplication/x-gzipzAmbiguous file signature in %s.zZCannot unpack file %s (downloaded from %s, content-type: %s); cannot detect archive formatz#Cannot determine archive format of )ry   None)r   r   realpathrJ   rz   r
   r   r   r	   rB   
is_zipfilerh   
is_tarfiler{   errorcriticalr   )rF   rN   content_typer   r   r   r   r   s   ``     @r   unpack_filer   N  s'    ww)H''//K< <' ' ((x++x~~  00x~~  .!@=!PQQx ##H-J##H-J*x*xj6A
OO	' A(L
MMr   )ry   int)r   rx   ry   z	list[str])r   zIterable[str]ry   r7   )r(   rx   r)   rx   ry   r7   )r   rx   ry   r   )r:   r   ry   r7   )T)rF   rx   rN   rx   rO   r7   ry   r   )rF   rx   rN   rx   ry   r   )r   tarfile.TarFiler   rw   ry   r7   )
rF   rx   rN   rx   r   r   rR   r7   ry   r   r   )rF   rx   rN   rx   r   z
str | Nonery   r   )*__doc__
__future__r   loggingr   rK   r8   rj   rh   rB   collections.abcr   r   pip._internal.exceptionsr   pip._internal.utils.filetypesr   r   r	   r
   pip._internal.utils.miscr   	getLogger__name__r{   SUPPORTED_EXTENSIONSbz2ImportErrordebuglzmar   r   r#   r,   r0   r3   r<   rY   r   r   r   r   r/   r   r   <module>r      s`   ! "  	   
   $  6  0			8	$ &6 0N*1M)
	X,8>+\]@BIBIBI 
BI 	BI
 
BIP  $/N/N/N /N 
	/N[	  0
LL./0  1
LL/01s$   !	C +	C$ C! C!$C>=C>