o
ai" @ s d Z ddlZddlZddlZddlZddlZddlZddlmZm Z m
Z
ddlmZ ddlm
Z
ddlmZmZmZmZ ddlmZ eeZee Zz
ddlZee7 ZW n eyc ed Y nw z
ddlZee7 ZW n ey| ed Y nw d
efddZd
ed
e e fddZ dee d
e!fddZ"deded
e!fddZ#d
ed
dfddZ$ded
e!fddZ%d'dedede!d
dfd d!Z&deded
dfd"d#Z' d(deded$e
e d
dfd%d&Z(dS ))zUtilities related archives.
N)IterableListOptional)ZipInfo)InstallationError)BZ2_EXTENSIONSTAR_EXTENSIONS
XZ_EXTENSIONSZIP_EXTENSIONS)
ensure_dirzbz2 module is not availablezlzma module is not availablereturnc C s t d} t | | S )zBGet the current umask which involves having to set it temporarily.r )osumask)mask r /builddir/build/BUILDROOT/alt-python310-pip-21.3.1-5.el8.x86_64/opt/alt/python310/lib/python3.10/site-packages/pip/_internal/utils/unpacking.py
current_umask+ s
r pathc C sd | d d} d| v r$d| v r| d| dk sd| vr$| ddS d| v r.| ddS | dgS )N/\ )lstripfindsplitr r r r split_leading_dir2 s $r pathsc C sD d}| D ]}t |\}}|s dS |du r|}q||kr dS qdS )zyReturns true if all the paths have the same leading path name
(i.e., everything is in one subdirectory in an archive)NFT)r )r
common_prefixr prefixrestr r r has_leading_dir> s r! directorytargetc C s0 t j| }t j|}t j||g}||kS )zL
Return true if the absolute path of target is within the directory
)r
r abspathcommonprefix)r" r#
abs_directory
abs_targetr r r r is_within_directoryM s r( c C s t | dt @ dB dS )zx
Make file present at path have execute for user/group/world
(chmod +x) is no-op on windows per python docs
i I N)r
chmodr r r r r 2set_extracted_file_to_default_mode_plus_executableX s r+ infoc C s$ | j d? }t|ot|o|d@ S )N r) )
external_attrboolstatS_ISREG)r, moder r r zip_item_is_executable` s
r3 Tfilenamelocationflattenc
C sJ t | t| d}ztj|dd}t| o|}| D ]{}|j}|}|r,t|d }t j
||}t j
|} t
||sId}
t|
| |||dsS|drXt | qt | ||}z)t|d}t|| W d n1 sxw Y W | t|rt| q| t|rt| w w W | d S | w )
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 openzipfileZipFiler! namelistinfolistr4 r r
r joindirnamer( r formatendswithshutilcopyfileobjcloser3 r+ )
r4 r5 r6 zipfpzipleadingr, namefndirmessagefpdestfpr r r
unzip_fileg sF
rO c C s. t | | ds| drd}n&| trd}n| tr)d}n| dr3d}ntd| d }tj| |d
d}zt dd
|
D }|
D ]}|j}|r`t|d }t
j||}t||swd}t|| ||| rt | qS| rz||| W qS ty } ztd| |j| W Y d} ~ qSd} ~ ww z||}
W n ttfy } ztd| |j| W Y d} ~ qSd} ~ ww t t
j| |
dusJ t|d}t|
| W d n1 sw Y |
||| |jd@ r
t | qSW | dS | w )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 after being
written. Note that for windows, any execute changes using os.chmod are
no-ops per the python docs.
z.gzz.tgzzr:gzzr:bz2zr:xzz.tarrz-Cannot determine compression type for file %szr:*zutf-8)encodingc S s g | ]}|j qS r )rI ).0memberr r r