kghndZddlZddlZddlZddlmZddlmZddlm Z m Z m Z m Z ddl mZddlmZddlmZdd lmZmZmZmZmZmZmZdd lmZdd lmZmZdd l m!Z!dd l"m#Z#ddl$m%Z%ddl&m'Z'm(Z(ddl)m*Z*m+Z+ddl,m-Z-ddl.m/Z/ddl0m1Z1ddl2m3Z3ddl4m5Z5m6Z6ddl7m8Z8m9Z9ddl:m;Z;ddlZ>m?Z?m@Z@ddlAmBZBddlCmDZDddlEmFZFe3eGZHde1de/dedeId eId!ef d"ZJd#e#d$eKd%eLd!dfd&ZMeGd'd(ZN d4d#e#d)e(d*e eKd+e e8d!eNf d,ZO d4d#e#d*e eKd+e e8d!eNfd-ZP d4d#e#d$eKd)e(d%eLd*e eKd+e e8d!e eNfd.ZQ d5d#e#d*eKd+e e8d0eId!e eKf d1ZRGd2d3ZSdS)6z(Prepares a distribution for installationN) dataclass)Path)DictIterableListOptional)canonicalize_name))make_distribution_for_install_requirement)InstalledDistribution)DirectoryUrlHashUnsupported HashMismatch HashUnpinnedInstallationErrorMetadataInconsistentNetworkConnectionErrorVcsHashUnsupported) PackageFinder)BaseDistributionget_metadata_distribution) ArchiveInfo)Link)Wheel)BatchDownloader Downloader)HTTPRangeRequestUnsupporteddist_from_wheel_url) PipSession) BuildTracker)InstallRequirement) getLogger)direct_url_for_editabledirect_url_from_link)Hashes MissingHashes) indent_log) display_path hash_filehide_urlredact_auth_from_requirement) TempDirectory) unpack_file)vcsreq build_trackerfinderbuild_isolationcheck_build_depsreturnct|}|j}|E|||5||||dddn #1swxYwY|S)z(Prepare a distribution for installation.N)r build_tracker_idtrackprepare_distribution_metadatar)r-r.r/r0r1 abstract_dist tracker_ids /builddir/build/BUILD/imunify360-venv-2.6.0/opt/imunify360/venv/lib/python3.11/site-packages/pip/_internal/operations/prepare.py_get_prepared_distributionr:;s>cBBM/J  j 1 1    7 7)9                    2 2 4 44sAAAlinklocation verbosityctj|j}|J||t |j|dS)N)urlr=)r,get_backend_for_schemeschemeunpackr(r?)r;r<r= vcs_backends r9unpack_vcs_linkrDMsK,T[99K  " " "xXdh%7%79MMMMMc<eZdZUeed<dZeeed<ddZdS)FilepathN content_typer2c|j8 tj|jd|_dS#t$rYdSwxYwdS)Nr)rI mimetypes guess_typerHOSError)selfs r9 __post_init__zFile.__post_init__XsZ   $ $-$8$C$CA$F!!!     % $s $/ ==)r2N)__name__ __module__ __qualname__str__annotations__rIrrOrEr9rGrGSsG III"&L(3-&&&rErGdownload download_dirhashesctdd}d}|rt|||}|r|}d}n+|||j\}}|r||t ||S)NrBTkindglobally_managed)r*_check_download_dirrHcheck_against_pathrG)r;rVrWrXtemp_diralready_downloaded_path from_pathrIs r9 get_http_urlrbbs (TBBBH"R"5dL&"Q"Q1+  #+(4"?"? <  1  % %i 0 0 0  < ( ((rEcd}|rt|||}|r|}n|j}|r||t|dS)z'Get file and optionally check its hash.N)r] file_pathr^rG)r;rWrXr`ras r9 get_file_urlrezsi #R"5dL&"Q"Q#+ N -!!),,,  4  rEc|jrt|||dS|rJ|jrt |||}nt ||||}|jst|j||j |S)a_Unpack link into location, downloading if required. :param hashes: A Hashes object, one of whose embedded hashes must match, or HashMismatch will be raised. If the Hashes is empty, no matches are required, and unhashable types of requirements (like VCS ones, which would ordinarily raise HashUnsupported) are allowed. )r=NrX) is_vcsrDis_existing_diris_filererbis_wheelr+rHrI)r;r<rVr=rWrXfiles r9 unpack_urlrms  {h)<<<<t##%%%% % |  D,v>>>        =<DIx):;;; KrETwarn_on_hash_mismatchc~tj||j}tj|sdSt d||rY ||nB#t$r5|rt d|tj |YdSwxYw|S)zCheck download_dir for previously downloaded file with correct hash If a correct file is found return its path else None NzFile was already downloaded %sz;Previously-downloaded file %s has bad hash. Re-downloading.) osrHjoinfilenameexistsloggerinfor^r warningunlink)r;rWrXrn download_paths r9r]r]sGLLt}==M 7>>- ( (t KK0-@@@    % %m 4 4 4 4   $ Q! Im $ $ $44  s%A;;;B:9B:c eZdZdZdedeedededededed ed e d ed ed ede dede ddf fd Z de ddfdZ de deddfdZde defdZde deefdZde deefdZdedeefdZ d(dee deddfdZ d(de dedefd Z d(d!ee deddfd"Zde dedefd#Zde ddfd$Zde defd%Zde d&edefd'ZxZS))RequirementPreparerzPrepares a Requirement build_dirrWsrc_dirr0r1r.session progress_barr/require_hashes use_user_site lazy_wheelr=legacy_resolverresume_retriesr2Ncrt||_||_||_||_t ||||_t||||_ | |_ ||_ ||_ ||_ | |_| |_| |_| |_||_i|_d|_dS)N)r)super__init__r|r{r._sessionr _downloadr_batch_downloadr/rWr0r1rruse_lazy_wheelr=r _downloaded_previous_requirement_header)rNr{rWr|r0r1r.r}r~r/rrrr=rr __class__s r9rzRequirementPreparer.__init__s$  "* #G\>JJ.w nUU ) /!1-+)# /,.-5)))rEr-c|jjr0|js)d}tt |jj}n,d}|jrt|jnt|}|jrM|jrFt|jtr|j}n|j }|r |d|dz }||f|j kr$||f|_ t |||jrNt5t d|jjddddS#1swxYwYdSdS)z3Provide context for the requirement being prepared.z Processing %sz Collecting %sz (from )zUsing cached %sN)r;rjis_wheel_from_cacherSr&rdr-r) comes_from isinstancerarrtrur%rr)rNr-message informationrs r9_log_preparing_linkz'RequirementPreparer._log_preparing_links 8  YC$; Y%Gl38+=>>??KK%GCF7X6sw???PSTWPXPXK 7 7s~ 7#.#.. 8,/N  ^5577  766666 [ !T%F F F18+0FD - KK - - -  " B B B -sx/@AAA B B B B B B B B B B B B B B B B B B B Bs&D66D:=D:parallel_buildsc|jjrdS|jJ|jr|jj|_dS||jd||dS)z1Ensure source_dir of a linked InstallRequirement.NT) autodeleter)r;rk source_dirrirdensure_has_source_dirr{ensure_pristine_source_checkout)rNr-rs r9_ensure_link_req_src_dirz,RequirementPreparer._ensure_link_req_src_dir4s 8   F~%%% 8 # # % %  X/CN F !! N+ "   ++-----rEc>|js|dS|jjrt |jrt |js|jst|dp tS)NT)trust_internetF) rrXr;rhrrir is_direct is_pinnedrr$rNr-s r9_get_linked_req_hashesz*RequirementPreparer._get_linked_req_hashesKs " 3::T:22 2 8? '$&& & 8 # # % % 0-// /} !S] !.. zzz//B=??BrEc|jrtddS|jrtddS||p||jS)Nz9Metadata-only fetching is not used in the legacy resolverz?Metadata-only fetching is not used as hash checking is required)rrtdebugr$_fetch_metadata_using_link_data_attr _fetch_metadata_using_lazy_wheelr;rs r9_fetch_metadata_onlyz(RequirementPreparer._fetch_metadata_onlyks    LLK   4    LLQ   488   =  2 238 < < =rEcR|j}|dS|jJtd|j|t ||j|}t|j d5}| }dddn #1swxYwYt||jj |jj }t|jt|jj kr!t!|d|jj |j|S)zGFetch metadata from the data-dist-info-metadata attribute, if possible.Nz/Obtaining dependency information for %s from %srgrbName)r; metadata_linkr-rtverboserbr as_hashesopenrHreadrrrnamer raw_namer)rNr-r metadata_filefmetadata_contents metadata_dists r9rz8RequirementPreparer._fetch_metadata_using_link_data_attr~se ..00  4w""" = G    %  N **,,   -$d + + )q !  ) ) ) ) ) ) ) ) ) ) ) ) ) ) )2  H  GL   ]3 4 48I#',8W8W W W&VSW\=+A sB''B+.B+r;c|jsdS|js|jstd|dSt |j}t|j}t d||j |j ddd} t|||jS#t$rtd|YdSwxYw)z-Fetch metadata using lazy wheel, if possible.Nz=Lazy wheel is not used as %r does not point to a remote wheelz+Obtaining dependency information from %s %s#rz"%s does not support range requests)rrjrkrtrrrrr rruversionr?splitrrr)rNr;wheelrr?s r9rz4RequirementPreparer._fetch_metadata_using_lazy_wheels " 4 < t}  LLO   4dm$$ ,, 9  M   hnnS!$$Q' &tS$-@@ @*    LL=s C C C44 s B66%CCFpartially_downloaded_reqsctddj}i}|D]}|jsJ|||j<|||}|D]p\}\}} t d||||}||_||j|jj <|j s"| t|q|D]}| ||dS)z>Download any requirements which were only fetched by metadata.rBTrZzDownloading link %s to %sN)r*rHr;rkeysrtrlocal_file_pathrr?rkneeds_unpacked_archiver_prepare_linked_requirement) rNrrr_links_to_fully_downloadr-batch_downloadr;filepath_s r9_complete_partial_requirementsz2RequirementPreparer._complete_partial_requirementss+!hFFFK CE, 4 4C8OO803 #CH - --- # ( ( * *   $2 ; ; D-8Q LL4dH E E E)$/C#+C .6D SX\ * < ;**4>>:::- C CC  , ,S/ B B B B C CrEc|jsJ||t5d}|jD|jjr8||}t |j|j||j }|||j|jj <n,| |}|d|_ |cdddS| ||cdddS#1swxYwYdS)z3Prepare a requirement to be obtained from req.link.N)rnT) r;rr%rWrkrr]rrr?rneeds_more_preparationr)rNr-rrdrXrs r9prepare_linked_requirementz.RequirementPreparer.prepare_linked_requirementsxx   %%% \\ J JI ,1B,44S99/H%/2.E*E    $1: ..!% 9 9# > >  ,15C.(7 J J J J J J J J<33CII= J J J J J J J J J J J J J J J J J JsBC >C  C$'C$reqscd|D}|D]b}|jY|jjrM||}t |j|j|}|||j|jj<d|_cg}|D]5}|jr||| ||6| ||dS)z,Prepare linked requirements more, if needed.c g|] }|j | SrU)r).0r-s r9 zHRequirementPreparer.prepare_linked_requirements_more..s BBBs'ABBBBrENF)r) rWr;rkrr]rr?rappendrr)rNrrr-rXrdrs r9 prepare_linked_requirements_morez4RequirementPreparer.prepare_linked_requirements_moresCBtBBB 7 7C ,1B,44S99/$:KVTT (5>D$SX\216C.?A! G GC) G)00555500oFFFF ++ %+ ,     rEc |jsJ|j}||}|r|jr|jJ|jsJ|jsJt |jjtr8|jjj r'| |jjj rd}n-t d|j |_|j}||||rd}n|j|jvrT t%||j|j|j|j|}nd#t.$r}t1d|d|d|d}~wwxYw|j|j}|r||t5|d}|j|jrJt9||j|_t |jjtrS|jjj sB|r@t;|jd}d||jj_ |r |j|_!tE||j#|j$|j%|j&} | S)NzyThe hashes of the source archive found in cache entry don't match, ignoring cached built wheel and re-downloading source.zCould not install requirement z because of HTTP error z for URL )rIrzsha256=)'r;rr download_inforkrjrrurrX has_one_ofrtrvcached_wheel_source_linkrrir?rrmrrr=rWrrr^rGeditabler"r'rH hexdigesthashrr:r.r/r0r1) rNr-rr;rX local_fileexcrdrdists r9rz/RequirementPreparer._prepare_linked_requirement4sxxx,,S11  c- $000= =<  <3,1;?? %*1 %%c&7&<&CDD 1 7x %%c?;;;    ! ! <JJ XT- - - 'NNN%  *   '2S22 22+/22  (2I 5)))444id;;;J   $| # ## 4T3> J JC  3,1;?? ?).5 ? ? !11!4>>@@/?.>.>!&+  2",/C )    K   !    s (D33 E=EEcF|jJ|jJ|j}|js|r#|jr||jdS|rt d|dS|jdStj |j|j }tj |sFtj|j|t!|}t d|dSdS)NzENot copying link to destination directory since it is a directory: %szSaved %s)rWr;rhrirarchivertrrrprHrqrrrsshutilcopyr&ru)rNr-r;download_locationrxs r9save_linked_requirementz+RequirementPreparer.save_linked_requirements' ,,,x###x ; 4//11 cl  KK) * * * F    ! !  LL.    F   & FGLL):DMJJw~~/00 3 K+-> ? ? ?():;;M KK M 2 2 2 2 2 3 3rEc|js Jdtd|t5|jrt d|d||j||j sJt|j |_ t||j|j|j|j}||jdddn #1swxYwY|S)z Prepare an editable requirement.z-cannot prepare a non-editable req as editablez Obtaining %szThe editable requirement zT cannot be installed when requiring hashes, because there is no single file to hash.N)rrtrur%rrrr|update_editablerr!unpacked_source_directoryrr:r.r/r0r1check_if_existsr)rNr-rs r9prepare_editable_requirementz0RequirementPreparer.prepare_editable_requirementsS |LLLLL| NC((( \\ 4 4" '  % %dl 3 3 3    ! ! !> ! !> 78U V VC -" $% D    2 3 3 3) 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4, sB,C33C7:C7 skip_reasoncn|js Jd|Jd|jtd|||jjt 5|jrtdt|cdddS#1swxYwYdS)z)Prepare an already-installed requirement.z(req should have been satisfied but isn'tNz?did not get skip reason skipped but req.satisfied_by is set to zRequirement %s: %s (%s)zSince it is already installed, we are trusting this package without checking its hash. To ensure a completely repeatable environment, install into an empty virtualenv.) satisfied_byrtrurr%rrr r)rNr-rs r9prepare_installed_requirementz1RequirementPreparer.prepare_installed_requirements/ KK!KKK&& ,) , ,'&&  %{C9I9Q   \\ J J"  ( )--GGII J J J J J J J J J J J J J J J J J JsAB**B.1B.)F)rPrQrR__doc__rSrboolrrrintrrrrr#rrrrrrrrrrrrrr __classcell__)rs@r9rzrzsl  9595sm95 95  95  95$959595959595959595 !95" #959595959595vB'9BdBBBB6.%.8<. .....C*<CCCCC@= = " #====&' ' " #''''R " #@!&*C*C#+,>#?*C*C  *C*C*C*CZ@E$J$J%$J8<$J $J$J$J$JNKP  /0 CG     rs+..  !!!!!!111111111111999999QQQQQQGGGGGG=<<<<<NNNNNNNN777777******,,,,,,FFFFFFFF544444EEEEEE<<<<<<......=<<<<<<<222222 766666555555!!!!!! 8  5 55 5 5  5  5555$N$N#N#N$NNNN           "#'# )) ))3-) V  )  ))))2PT!! !&sm!