\bgmdZddlZddlZddlZddlmZddlmZddlm 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 installation N) 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 q/builddir/build/BUILD/cloudlinux-venv-1.0.7/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_linkrDNsK,T[99K  " " "xXdh%7%79MMMMMc<eZdZUeed<dZeeed<ddZdS)FilepathN content_typer2c`|j&tj|jd|_dSdS)Nr)rI mimetypes guess_typerH)selfs r9 __post_init__zFile.__post_init__Ys3   $ ) 4TY ? ? BD    % $rE)r2N)__name__ __module__ __qualname__str__annotations__rIrrNrEr9rGrGTsM III"&L(3-&&&CCCCCCrErGdownload download_dirhashesctdd}d}|rt|||}|r|}d}n+|||j\}}|r||t ||S)NrBTkindglobally_managed)r*_check_download_dirrHcheck_against_pathrG)r;rUrVrWtemp_diralready_downloaded_path from_pathrIs r9 get_http_urlra^s (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;rVrWr_r`s r9 get_file_urlrdvsi #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=NrW) is_vcsrDis_existing_diris_filerdrais_wheelr+rHrI)r;r<rUr=rVrWfiles r9 unpack_urlrls  {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;rVrWrm download_paths r9r\r\sGLLt}==M 7>>- ( (t KK0-@@@    % %m 4 4 4 4   $ Q! Im $ $ $44  s%A;;;B:9B:ceZdZdZdedeedededededed ed e d ed ed ede deddffd Z de ddfdZ de deddfdZde defdZde deefdZde deefdZdedeefdZ d'dee deddfdZ d'de dedefdZ d'd ee deddfd!Zde dedefd"Zde ddfd#Zde defd$Zde d%edefd&ZxZS)(RequirementPreparerzPrepares a Requirement build_dirrVsrc_dirr0r1r.session progress_barr/require_hashes use_user_site lazy_wheelr=legacy_resolverr2Ncnt||_||_||_||_t |||_t|||_ | |_ ||_ ||_ ||_ | |_| |_| |_| |_||_i|_d|_dS)N)r)super__init__r{rzr._sessionr _downloadr_batch_downloadr/rVr0r1r~ruse_lazy_wheelr=r _downloaded_previous_requirement_header)rMrzrVr{r0r1r.r|r}r/r~rrr=r __class__s r9rzRequirementPreparer.__init__s"  "* #G\::.w EE ) /!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;riis_wheel_from_cacherRr&rcr-r) comes_from isinstancer`rrsrtr%rq)rMr-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;rj source_dirrhrcensure_has_source_dirrzensure_pristine_source_checkout)rMr-rs r9_ensure_link_req_src_dirz,RequirementPreparer._ensure_link_req_src_dir/s 8   F~%%% 8 # # % %  X/CN F !! N+ "   ++-----rEc>|js|dS|jjrt |jrt |js|jst|dp tS)NT)trust_internetF) r~rWr;rgrrhr is_direct is_pinnedrr$rMr-s r9_get_linked_req_hashesz*RequirementPreparer._get_linked_req_hashesFs " 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)rrsdebugr~$_fetch_metadata_using_link_data_attr _fetch_metadata_using_lazy_wheelr;rs r9_fetch_metadata_onlyz(RequirementPreparer._fetch_metadata_onlyfs    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 %srfrbName)r; metadata_linkr-rsverboserar as_hashesopenrHreadrrqnamer raw_namer)rMr-r metadata_filefmetadata_contents metadata_dists r9rz8RequirementPreparer._fetch_metadata_using_link_data_attryse ..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)rrirjrsrrrqr rrtversionr?splitrrr)rMr;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.rBTrYzDownloading link %s to %sN)r*rHr;rkeysrsrlocal_file_pathrr?rjneeds_unpacked_archiver_prepare_linked_requirement) rMrrr^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)rmT) r;rr%rVrjrr\rrr?rneeds_more_preparationr)rMr-rrcrWrs 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 | SrT)r).0r-s r9 zHRequirementPreparer.prepare_linked_requirements_more..s BBBs'ABBBBrENF)r) rVr;rjrr\rr?rappendrr)rMrrr-rWrcrs 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_inforjrirrtrrW has_one_ofrsrucached_wheel_source_linkrrhr?rrlrrr=rVrrr]rGeditabler"r'rH hexdigesthashrr:r.r/r0r1) rMr-rr;rW local_fileexcrcrdists r9rz/RequirementPreparer._prepare_linked_requirement/sxxx,,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)rVr;rgrhrarchiversrrrorHrprqrrshutilcopyr&rt)rMr-r;download_locationrws 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)rrsrtr%r~rrr{update_editablerr!unpacked_source_directoryrr:r.r/r0r1check_if_existsr)rMr-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_byrsrtrr%r~rr r)rMr-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)rOrPrQ__doc__rRrboolrrrintrrrrr#rrrrrrrrrrrrrr __classcell__)rs@r9ryrysb  8585sm85 85  85  85$858585858585858585 !858585858585tB'9BdBBBB6.%.8<. .....C*<CCCCC@= = " #====&' ' " #''''R " #@!&*C*C#+,>#?*C*C  *C*C*C*CZ@E$J$J%$J8<$J $J$J$J$JNKP  /0 CG     rs7  !!!!!!111111111111999999QQQQQQGGGGGG=<<<<<NNNNNNNN777777******,,,,,,FFFFFFFF544444EEEEEE<<<<<<......=<<<<<<<222222 766666555555!!!!!! 8  5 55 5 5  5  5555$N$N#N#N$NNNN  CCCCCCC C#'# )) ))3-) V  )  ))))2PT!! !&sm!