a Re"@sdZddlZddlZddlZddlZddlZddlZddlmZm Z m Z ddlm Z ddl m Z ddlmZmZmZmZddlmZeeZeeZzddlZee7ZWneyedYn0zddlZee7ZWneyed Yn0ed d d Zee ed ddZ eee!dddZ"eee!dddZ#edd ddZ$e e!dddZ%d%eee!ddddZ&eeddd d!Z'd&eee edd"d#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 available)returncCstd}t||S)zBGet the current umask which involves having to set it temporarily.r)osumask)maskr/builddir/build/BUILDROOT/alt-python39-pip-21.3.1-2.el8.x86_64/opt/alt/python39/lib/python3.9/site-packages/pip/_internal/utils/unpacking.py current_umask+s  r)pathr cCsh|dd}d|vrHd|vr4|d|dkss r!) directorytargetr cCs0tj|}tj|}tj||g}||kS)zL Return true if the absolute path of target is within the directory )r rabspath commonprefix)r"r# abs_directory abs_targetrrrris_within_directoryMs  r(cCst|dt@dBdS)zx Make file present at path have execute for user/group/world (chmod +x) is no-op on windows per python docs iIN)r chmodrrrrr2set_extracted_file_to_default_mode_plus_executableXsr+)infor cCs$|jd?}t|o t|o |d@S)Nr)) external_attrboolstatS_ISREG)r,moderrrzip_item_is_executable`s r3T)filenamelocationflattenr c CsRt|t|d}z.tj|dd}t|o2|}|D]}|j}|}|rZt|d}t j ||}t j |} t ||sd} t| ||||ds|drt|qd}n8|trRd}n$|drfd}ntd|d }tj||d d }zt d d | D}| D]}|j }|rt |d}t j||}t||sd}t|||||rt|q|rhz|||WnDtyd} z*td||j | WYd} ~ qWYd} ~ n d} ~ 00qz||} WnHttfy} z*td||j | WYd} ~ qWYd} ~ n d} ~ 00tt j|| dusJt|d} t| | Wdn1s 0Y| ||||jd@rt |qW|n |0dS)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)encodingcSsg|] }|jqSr)rI).0memberrrr zuntar_file..rzQThe tar file ({}) has a file ({}) trying to install outside target directory ({})z/In the tar file %s the member %s is invalid: %sNr9r))!r lowerrBrr loggerwarningtarfiler:r! getmembersrIrr rr?r(rrAisdirissym_extract_member Exception extractfileKeyErrorAttributeErrorr@rCrDrEutimer2r+) r4r5r2tarrHrSrJrrLexcrMrNrrr untar_filest      $" ,   re)r4r5 content_typer cCstj|}|dks,|ts,t|rDt|||d dnR|dkslt |sl|t t t rxt||ntd|||td|dS)Nzapplication/zipz.whl)r6zapplication/x-gzipzZCannot unpack file %s (downloaded from %s, content-type: %s); cannot detect archive formatz#Cannot determine archive format of )r rrealpathrVrBr r; is_zipfilerOrY is_tarfilerrr rerWcriticalr)r4r5rfrrr unpack_files,   rk)T)N))__doc__loggingr rCr0rYr;typingrrrrpip._internal.exceptionsrpip._internal.utils.filetypesrrr r pip._internal.utils.miscr getLogger__name__rWSUPPORTED_EXTENSIONSbz2 ImportErrordebuglzmaintrstrrr/r!r(r+r3rOrerkrrrrsL          .T