0fSnXddlmZddlZddlZddlZddlZddlmZmZddl m Z ddl m Z m Z ddlmZmZddlmZmZddlmZdd lmZdd lmZdd lmZmZdd lmZmZm Z m!Z!dd l"m#Z#m$Z$ddl%m&Z&ee'Z(d*dZ)d+dZ*e*d,dZ+d-d Z,d-d!Z-d.d#Z.Gd$d%Z/Gd&d'Z0Gd(d)Z1dS)/) annotationsN) GeneratorIterable)cache_from_source)AnyCallable)LegacyDistutilsInstallUninstallMissingRecord)get_bin_prefix get_bin_user)BaseDistribution)WINDOWS)egg_link_path_from_location) getLogger indent_log)asknormalize_pathrenamesrmtree)AdjacentTempDirectory TempDirectory)running_under_virtualenvbin_dirstr script_nameis_guiboolreturnGenerator[str, None, None]c#Ktj||}|VtsdS|dV|dV|r |dVdS|dVdS)zCreate the fully qualified name of the files created by {console,gui}_scripts for the given ``dist``. Returns the list of file names Nz.exez .exe.manifestz -script.pywz -script.py)ospathjoinr)rrrexe_names q/builddir/build/BUILD/cloudlinux-venv-1.0.10/venv/lib/python3.11/site-packages/pip/_internal/req/req_uninstall.py _script_namesr&sw||G[11H NNN       $ $ $$$$ &&&&&&&&&%%%%%%%%fn)Callable[..., Generator[Any, None, None]]cHtjdfd }|S)NargsrkwrGenerator[Any, None, None]c?xKt}|i|D]}||vr|||V dSN)setadd)r+r,seenitemr(s r%uniquez_unique..unique.sYBOOO  D4   r')r+rr,rrr-) functoolswraps)r(r4s` r%_uniquer7+s?_R Mr'distr c#K|j}| Jd|}|t||D]}tj||}|V|drztj|\}}|dd}tj||dz}|Vtj||dz}|VdS)a Yield all the uninstallation paths for dist based on RECORD-without-.py[co] Yield paths to all the files in RECORD. For each .py file in RECORD, add the .pyc and .pyo in the same directory. UninstallPathSet.add() takes care of the __pycache__ .py[co]. If RECORD is not found, raises an error, with possible information from the INSTALLER file. https://packaging.python.org/specifications/recording-installed-packages/ Nz not installed distribution.py.pyc.pyo)locationiter_declared_entriesr r!r"r#endswithsplit)r8r@entriesentryr"dnr(bases r%uninstallation_pathsrH9s}H      ((**G$$7777  w||He,, ==   W]]4((FBcrc7D7<<D6M22DJJJ7<<D6M22DJJJ  r'paths Iterable[str]set[str]ctjjt}t |t D]5t fd|D}|s|6|S)zCompact a path set to contain the minimal number of paths necessary to contain all paths in the set. If /a/path/ and /a/path/to/a/file.txt are both in the set, leave only the shorter path.keyc3K|]k}|do>t|dkVldS)*N) startswithrstriplen).0 shortpathr"seps r% zcompact..ds   OOI,,S11 2 2 DS))#..55c::;;<C      r')r!r"rVr0sortedrSanyr1)rI short_paths should_skipr"rVs @@r%compactr\[s '+CEEKu#&&&""     )      " OOD ! ! ! r'c d|D}t|}td|Dt}t}d d |D]׊ t fd|Drt}t}t j D]L\ }}| fd |D| fd |DM||z s7||| t j ztt|j ||zS) zReturns a set containing the paths that need to be renamed. This set may include directories when the original sequence of paths included every file on disk. cNi|]"}tj||#S)r!r"normcaserTps r% z'compress_for_rename..ts*6661  ##Q666r'cXh|]'}tj|d(S)r)r!r"rCras r% z&compress_for_rename..vs+GGG a((+GGGr'rMarrcbtjtjj|Sr/)r!r"r`r#)rfs r% norm_joinz&compress_for_rename..norm_joinys!w a 0111r'c3|K|]6}tj|V7dSr/)r!r"r`rQ)rTwroots r%rWz&compress_for_rename..}sAGGrw%%0033GGGGGGr'c32K|]}|VdSr/r_)rTddirnamerhrks r%rWz&compress_for_rename..s1LLqyyw::LLLLLLr'c32K|]}|VdSr/r_)rTfrnrhrks r%rWz&compress_for_rename..s1HHQYYtWa88HHHHHHr')rfrrr) r0rXvaluesrSrYr!walkupdatedifference_updater1rVmap __getitem__) rIcase_map remaining unchecked wildcards all_files all_subdirssubdirsfilesrnrhrks @@@r%compress_for_renamerns 76666HH IGGX__5F5FGGGSQQQI%%I2222)) GGGGYGGG G G  !ee # ')wt}} I I #GWe   LLLLLLGLLL L L L   HHHHHH%HHH H H H HI% )  ' ' 2 2 2 MM$- ( ( ( s8'33 4 4y @@r'tuple[set[str], set[str]]cft|}t}t}t}|D]x}|dr|dsd|vr2|tj|||ytt tjj|}t|}|D]}tj |D]\}} } | D]} | drtj || } tj | r6tj| |vr|| |d|Dz}||fS)asReturns a tuple of 2 sets of which paths to display to user The first set contains paths that would be deleted. Files of a package are not added and the top-level directory of the package has a '*' added at the end - to signify that all it's contents are removed. The second set contains files that would have been skipped in the above folders. r>z __init__.pyz .dist-infocNh|]"}tj|d#S)rP)r!r"r#)rTfolders r%rez.compress_for_output_listing..s(KKK27<<44KKKr') r0rBr1r!r"rnrur`r\rrr#isfile) rI will_remove will_skipfoldersr~r"_normcased_filesrdirpath_dirfilesfnamefile_s r%compress_for_output_listingrse**KIeeG EEE ==    == ' ' /<4+?+? KK-- . . . $3rw/7788gG ) )$&GFOO ) ) GQ! ) )>>&)) We44GNN5)))((//7GGGMM%((( ) )KK7KKKKK  !!r'cZeZdZdZddZddZddZdd Zdd Zdd Z e dd Z dS)StashedUninstallPathSetzWA set of file rename operations to stash files while tentatively uninstalling them.rNonec"i|_g|_dSr/) _save_dirs_movesselfs r%__init__z StashedUninstallPathSet.__init__s57.0 r'r"rc t|}n #t$rtd}YnwxYw||jtj|<|jS)zStashes a directory. Directories are stashed adjacent to their original location if possible, or else moved/copied into the user's temp dir. uninstallkind)rOSErrorrrr!r"r`)rr"save_dirs r%_get_directory_stashz,StashedUninstallPathSet._get_directory_stashsi  7&;D&A&AHH 7 7 7$+666HHH 72:((../}s //cVtj|}tj|d}}d}||krF |j|}np#t $rYnwxYwtj||}}||kFtj|}t d}||j|<tj||}|r:|tjjkr%tj |j|S|jS)zStashes a file. If no root has been provided, one will be created for the directory in the user's temp directory.Nrr) r!r"r`rnrKeyErrorrrelpathcurdirr#)rr"headold_headrrs r%_get_file_stashz'StashedUninstallPathSet._get_file_stashs w%%..hh ?40    W__T22D(D h7??4((D$+666H$,DOD !'//$--  8w"'.007<< w77 7}s A A%$A%ctj|otj| }|r||}n||}|j||f|r3tj|rtj|t|||S)zStashes the directory or file and returns its new location. Handle symlinks as files to avoid modifying the symlink targets. ) r!r"isdirislinkrrrappendrmdirr)rr" path_is_dirnew_paths r%stashzStashedUninstallPathSet.stashsgmmD))F"'..2F2F.F  20066HH++D11H D(+,,,  27==22  HX   hr'c|jD]}|g|_i|_dS)z0Commits the uninstall by removing stashed files.N)rrqcleanupr)rrs r%commitzStashedUninstallPathSet.commit sF..00  H        r'cx|jD]}tjdg|R|jD]\}} td||tj|stj|rt j|n.tj |rt|t||#t$r@}t d|td|Yd}~d}~wwxYw|dS)z2Undoes the uninstall by moving stashed files back.zMoving to %s from %szReplacing %s from %szFailed to restore %sz Exception: %sN)rloggerinfodebugr!r"rrunlinkrrrrerrorr)rrbrr"exs r%rollbackz StashedUninstallPathSet.rollbacks? 6 6A K0 51 5 5 5 5 5"k 2 2NHd 2 3XtDDD7>>(++%rw~~h/G/G%Ih''''W]]8,,%8$$$h'''' 2 2 2 3X>>> _b11111111 2 sB-C D##6DD#rc*t|jSr/)rrrs r% can_rollbackz$StashedUninstallPathSet.can_rollback%sDK   r'Nrr)r"rrrrr) __name__ __module__ __qualname____doc__rrrrrrpropertyrr_r'r%rrs&&0000    6*&!!!X!!!r'rcleZdZdZddZdd Zdd ZddZdddZddZ ddZ ddZ e d dZ dS)!UninstallPathSetzMA set of file paths to be removed in the uninstallation of a requirement.r8r rrct|_t|_i|_||_t |_tjt|_ dSr/) r0_paths_refuse_pth_distr _moved_pathsr5 lru_cacher_normalize_path_cached)rr8s r%rzUninstallPathSet.__init__.sO # !$ 46  355'0&9.&I&I###r'r"rrctsdS||tjS)zs Return True if the given path is one we are permitted to remove/modify, False otherwise. T)rrQrsysprefix)rr"s r% _permittedzUninstallPathSet._permitted9s9()) 4t::3:FFGGGr'cZtj|\}}tj||tj|}tj|sdS||r|j |n|j |tj |ddkr$| t|dSdS)Nr<) r!r"rCr#rr`existsrrr1rsplitextr)rr"rtails r%r1zUninstallPathSet.addDsW]]4(( dw||D77==rw?O?OPT?U?UVVw~~d##  F ??4  # KOOD ! ! ! ! L  T " " " 7  D ! !! $ - - HH&t,, - - - - - . -r'pth_filerEc||}||rB||jvrt||j|<|j||dS|j|dSr/)rrrUninstallPthEntriesr1r)rrrEs r%add_pthzUninstallPathSet.add_pthWs..x88 ??8 $ $ 'ty((&9(&C&C (# Ih  # #E * * * * * L  X & & & & &r'F auto_confirmverbosec|js'td|jjdS|jjd|jj}td|t 5|s||r|j}t|j}tt|D]2}| |t d|3|jD]}|td|ddddS#1swxYwYdS)z\Remove paths in ``self._paths`` with confirmation (unless ``auto_confirm`` is True).z7Can't uninstall '%s'. No files were found to uninstall.N-zUninstalling %s:zRemoving file or directory %szSuccessfully uninstalled %s)rrrrraw_name raw_versionr_allowed_to_proceedrrrXr\rrrrqremove)rrrdist_name_versionmoved for_renamer"pths r%rzUninstallPathSet.remove`s{  KKI #    F#z2MMTZ5KMM &(9::: \\ N N Nt77@@ N)0== "7:#6#677JJDKK%%%NN#BDIIII9++--!!CJJLLLL 9;LMMM N N N N N N N N N N N N N N N N N Ns3C E  EEc<dd}|st|j\}}n"t|j}t}|d||d ||d |j|r|d t |jt d d dkS)z@Display which files would be deleted and prompt for confirmationmsgrrIrJrrc|sdSt|t5tt |D]}t| ddddS#1swxYwYdSr/)rrrrXr\)rrIr"s r%_displayz6UninstallPathSet._allowed_to_proceed.._displays  KK    & &"75>>22&&DKK%%%%& & & & & & & & & & & & & & & & & & &s:A55A9<A9z Would remove:z+Would not remove (might be manually added):z%Would not remove (outside of prefix):zWill actually move:zProceed (Y/n)? )ynr)rrrIrJrr)rrr0rrr)rrrrrs r%rz$UninstallPathSet._allowed_to_proceed}s & & & & %@%M%M "Kdk**KI+...> JJJ8$,GGG  N H*,? ,L,L M M M$n55<.s.( ( ( ( ( ( ( r'stdlib platstdlibzz.UninstallPathSet.from_dist..s8&&&&j00000r'r<r>r?r:rzeasy-install.pthz./z Egg-link z (to z') does not match installed location of z (at )z)Not sure how to uninstall: %s - Check: %sz.batr8r rrrrc3K|D]Q}|jdkrt||jdEd{V*|jdkrt||jdEd{VRdS)Nconsole_scriptsF gui_scriptsT)iter_entry_pointsgroupr&name)r8r entry_points r%iter_scripts_to_removez:UninstallPathSet.from_dist..iter_scripts_to_remove8s $5577 N N $(999,Wk6FNNNNNNNNNN &-77,Wk6FMMMMMMMMM  N Nr')r8r rrrr)/r@ info_locationrrcanonical_namerlocalrr sysconfigget_pathrr"installed_with_setuptools_egg_infor!r"rrBsetuptools_filenamer1rAr#is_file read_text splitlinesFileNotFoundErrorinstalled_by_distutilsr installed_as_eggrCrnrinstalled_with_dist_inforHopenr`readlinestriprsamefiler in_usersiter r iter_distutils_script_namesrNotADirectoryError)clsr8 dist_locationrnormalized_dist_locationpaths_to_removedevelop_egg_linksetuptools_flat_installationinstalled_filesinstalled_filenamespace_packages top_level_pkgr"easy_install_eggeasy_install_pthfh link_pointernormalized_link_pointerrscriptrsrs @r% from_distzUninstallPathSet.from_dists *  KK?#   3t99 #1-#@#@ z  KKC#(     3t99  #( ( (22I4F|4T4TU( ( (   KKN#(    3t99 #d))6t}EE  3 ST) S}-- S "**d.F+Q+Q+QRRR % (K (##M222"88::O*&5UUN#'' ]N(S(STTTTU o.. 7O)-8P)Q)Q&"4!>!>!>!N!NJJ)$$$!#JJJ$&&&&!^^O<<GGII&&& 7 7M 7<< }EED#''---#''4 555#''4 666#''4 6666  (/ (d;;; ;  ",     8 9 9 9!w}}-EFFqI !w|| 899"     # #$4d=M6M N N N N  * ,T22 * *##D)))) * &'' 2!w// 0C0C0E0EFF *9*P*P ++'                7##')A  N,NN<NN)-NN=JNNN      0 1 1 1!w|| 0113E     # #$4m D D D D LL;      '"nnGG$&&G ::<< P P##BGLL&$A$ABBBP#'' Wooo(N(NOOO P"#56    D  N N N N('g66 # #A    " " " "s8G== H  H 6APP"P BVV('V(N)r8r rr)r"rrr)r"rrr)rrrErrr)FF)rrrrrr)rrrrr)r8r rr)rrrrrrr1rrrrr classmethodr%r_r'r%rr*s J J J J H H H H....&''''NNNNN:====8    ####ZZZ[ZZZr'rc.eZdZd dZd dZddZdd Zd S)rrrrrcH||_t|_d|_dSr/)filer0rD _saved_lines)rrs r%rzUninstallPthEntries.__init__Is" !$ 04r'rEctj|}tr;tj|ds|dd}|j|dS)Nr\/)r!r"r`r splitdrivereplacerDr1)rrEs r%r1zUninstallPthEntries.addNsl  ''  -27--e44Q7 -MM$,,E r'ctd|jtj|js"td|jdSt|jd5}|}||_ dddn #1swxYwYtd|Drd}nd}|rO|d | ds!|d| dz|d<|j D]Y} td ||||z dJ#t$rYVwxYwt|jd 5}||ddddS#1swxYwYdS) NzRemoving pth entries from %s:z.Cannot remove entries from nonexistent file %srbc3K|]}d|vV dS)s Nr_)rTlines r%rWz-UninstallPthEntries.remove..hs&114w$111111r'z  zutf-8zRemoving entry: %swb)rrr)r!r"rwarningr  readlinesr*rYrBencoderDr ValueError writelines)rr linesendlinerEs r%rzUninstallPthEntries.remove]s76 BBBw~~di((  NNKTY W W W F $)T " " &bLLNNE %D  & & & & & & & & & & & & & & & 115111 1 1 GGG  <r++GNN7,C,CDD <b GNN7$;$;;E"I\  E 3U;;; ego55g>>????     $)T " " !b MM%  ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! !s7<B$$B(+B((AE// E<;E<F77F;>F;rc&|j"td|jdStd|jt |jd5}||jdddn #1swxYwYdS)Nz.Cannot roll back changes to %s, none were madeFz!Rolling %s back to previous stater6T)r*rrr)rr r;)rr s r%rzUninstallPthEntries.rollbackxs   $ LLI49 U U U5 8$)DDD $)T " " -b MM$+ , , , - - - - - - - - - - - - - - -tsBB  B N)rrrr)rErrrrr)rrrrr1rrr_r'r%rrHsd5555     !!!!6r'r)rrrrrrrr)r(r)rr))r8r rr)rIrJrrK)rIrJrr)2 __future__rr5r!rrcollections.abcrrimportlib.utilrtypingrrpip._internal.exceptionsr r pip._internal.locationsr r pip._internal.metadatar pip._internal.utils.compatrpip._internal.utils.egg_linkrpip._internal.utils.loggingrrpip._internal.utils.miscrrrrpip._internal.utils.temp_dirrrpip._internal.utils.virtualenvrrrr&r7rHr\rrrrrr_r'r%rLs}"""""" ////////,,,,,, SSSSSSSS@@@@@@@@333333......DDDDDD========IIIIIIIIIIIIMMMMMMMMCCCCCC 8  &&&&&      B&AAAAD."."."."bf!f!f!f!f!f!f!f!R[[[[[[[[|7777777777r'