Re\ ddlZddlZddlZddlZddlZddlmZddlmZm Z m Z m Z m Z m Z mZmZmZddlmZddlmZddlmZddlmZmZddlmZdd lmZdd lmZm Z dd l!m"Z"m#Z#m$Z$m%Z%m&Z&m'Z'm(Z(dd l)m*Z*m+Z+ee,Z-d ede.de/de e.fdZ0de de efde de effdZ1e1d ede e.fdZ2de e.dee.fdZ3de e.dee.fdZ4de e.deee.ee.ffdZ5GddZ6GddZ7GddZ8dS) N)cache_from_source) AnyCallableDictIterableIteratorListOptionalSetTuple) pkg_resources) Distribution)UninstallationError)get_bin_prefix get_bin_user)WINDOWS)egg_link_path_from_location) getLogger indent_log)askdist_in_usersite dist_is_localis_localnormalize_pathrenamesrmtree)AdjacentTempDirectory TempDirectorydist script_nameis_guireturncxt|rt}nt}tj||}|g}t rc||dz||dz|r||dzn||dz|S)zCreate the fully qualified name of the files created by {console,gui}_scripts for the given ``dist``. Returns the list of file names z.exez .exe.manifestz -script.pywz -script.py)rrrospathjoinrappend)rr r!bin_direxe_namepaths_to_removes /builddir/build/BUILDROOT/alt-python311-pip-21.3.1-3.el8.x86_64/opt/alt/python311/lib/python3.11/site-packages/pip/_internal/req/req_uninstall.py _script_namesr,s #.. ""w||G[11HjO<x&0111x/9:::  <  " "8m#; < < < <  " "8l#: ; ; ; fn.ctjdtdtdttffd }|S)Nargskwr"c?xKt}|i|D]}||vr|||V dSN)setadd)r0r1seenitemr.s r+uniquez_unique..unique5sYBOOO  D4   r-) functoolswrapsrr)r.r8s` r+_uniquer;4sV_Rc# Mr-c#K tj|d}n#t$r}d|} t |d}|r|dkrt  |d|z }nU#ttt f$r;d|j |j }|d|z }YnwxYwt||d }~wwxYw|D]}tj |j|d }|V|d rztj |\}} | d d } tj || d z}|Vtj || dz}|Vd S)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 UninstallationError, with possible information from the INSTALLER file. https://packaging.python.org/specifications/recording-installed-packages/ RECORDz/Cannot uninstall {dist}, RECORD file not found.)r INSTALLERpipz' Hint: The package was installed by {}.z{}=={}zZ You might be able to recover from this via: 'pip install --force-reinstall --no-deps {}'.Nr.py.pyc.pyo)csvreaderget_metadata_linesFileNotFoundErrorformatnext ValueErrorOSError StopIteration project_nameversionrr$r%r&locationendswithsplit) rrmissing_record_exceptionmsg installerdeprowr%dnr.bases r+uninstallation_pathsrZ@sE Jt..x88 9 9 EEE?FFDFQQ OT44[AABBI # U 2 2 ll"!3 <CCINN NCC 3   //$"3T\BBC @@Fs  CCC "#&&,DDE  w||DM3q622 ==   W]]4((FBcrc7D7<<D6M22DJJJ7<<D6M22DJJJ  s9', D D 8BDAC1.D0C11DD pathsctjjt}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..us   OOI,,S11 2 2 DS))#..55c::;;<C      r-)r$r%rfr4sortedrcanyr5)r[ short_paths should_skipr%rfs @@r+compactrlls '+CEEKu#&&&""     )      " OOD ! ! ! r-c d|D}t|}td|Dt}t}dtdtfd |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%normcaserdps r+ z'compress_for_rename..s*6661  ##Q666r-cXh|]'}tj|d(S)r)r$r%rQrqs r+ z&compress_for_rename..s+GGG a((+GGGr-r]ar"cbtjtjj|Sr3)r$r%rpr&)rvs r+ norm_joinz&compress_for_rename..norm_joins!w a 0111r-c3|K|]6}tj|V7dSr3)r$r%rpra)rdwroots r+rgz&compress_for_rename..sAGGrw%%0033GGGGGGr-c32K|]}|VdSr3ro)rdddirnamerxr{s r+rgz&compress_for_rename..s1LLqyyw::LLLLLLr-c32K|]}|VdSr3ro)rdfr~rxr{s r+rgz&compress_for_rename..s1HHQYYtWa88HHHHHHr-)r4rhvaluesrcstrrir$walkupdatedifference_updater5rfmap __getitem__) r[case_map remaining unchecked wildcards all_files all_subdirssubdirsfilesr~rxr{s @@@r+compress_for_renamers 76666HH IGGX__5F5FGGGSQQQI%%I2c2c2222)) 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-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. rBz __init__.py .dist-infocNh|]"}tj|d#S)r`)r$r%r&)rdfolders r+ruz.compress_for_output_listing..s(KKK27<<44KKKr-) r4rPr5r$r%r~rrprlrr&isfile) r[ will_remove will_skipfoldersrr%_normcased_filesrdirpath_dirfilesfnamefile_s r+compress_for_output_listingrse**KIeeG EEE ==    == ' ' /<4+?+? KK-- . . . $3rw/7788gG ) )$&GFOO ) ) GQ! ) )>>&)) We44GNN5)))((//7GGGMM%((( ) )KK7KKKKK  !!r-cveZdZdZd dZdedefdZdedefdZdedefdZd d Z d d Z e de fd Z dS) StashedUninstallPathSetzWA set of file rename operations to stash files while tentatively uninstalling them.r"Nc"i|_g|_dSr3) _save_dirs_movesselfs r+__init__z StashedUninstallPathSet.__init__s57.0 r-r%c 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)rrKrrr$r%rp)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%rpr~rKeyErrorrrelpathcurdirr&)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%isdirislinkrrrr'rmdirr)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)ritemscleanupr)rrrs r+commitzStashedUninstallPathSet.commitsJ?0022  KAx        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%rrunlinkrrrrKerrorr)rrrrr%exs r+rollbackz StashedUninstallPathSet.rollback$s? 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#c*t|jSr3)boolrrs r+ can_rollbackz$StashedUninstallPathSet.can_rollback7sDK   r-r"N)__name__ __module__ __qualname____doc__rrrrrrrpropertyrrror-r+rrs&&0000      CC6##*&!d!!!X!!!r-rceZdZdZdeddfdZdedefdZdeddfdZ d ed eddfd Z dd ededdfdZ dedefdZ ddZ ddZededdfdZdS)UninstallPathSetzMA set of file paths to be removed in the uninstallation of a requirement.rr"Nct|_t|_i|_||_t |_dSr3)r4r[_refusepthrr _moved_paths)rrs r+rzUninstallPathSet.__init__@s:"uu !$ 35 355r-r%c t|S)zs Return True if the given path is one we are permitted to remove/modify, False otherwise. )r)rr%s r+ _permittedzUninstallPathSet._permittedGs ~~r-cNtj|\}}tjt |tj|}tj|sdS||r|j |n|j |tj |ddkr$| t|dSdS)Nr@) r$r%rQr&rrpexistsrr[r5rsplitextr)rr%rtails r+r5zUninstallPathSet.addOsW]]4(( dw||N400"'2B2B42H2HIIw~~d##  F ??4  # JNN4 L  T " " " 7  D ! !! $ - - HH&t,, - - - - - . -r-pth_fileentryct|}||rB||jvrt||j|<|j||dS|j|dSr3)rrrUninstallPthEntriesr5r)rrrs r+add_pthzUninstallPathSet.add_pthbs!(++ ??8 $ $ 'tx''%8%B%B" HX  " "5 ) ) ) ) ) L  X & & & & &r-F auto_confirmverbosec|js'td|jjdS|jjdz|jjz}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)r[rrrrMrNr_allowed_to_proceedrrrhrlrrrrremove)rrrdist_name_versionmoved for_renamer%rs r+rzUninstallPathSet.removeksz  KKI &    F I2S849;LL &(9::: \\ N N Nt77@@ N)0<< "7:#6#677JJDKK%%%NN#BDIIII8??,,!!CJJLLLL 9;LMMM N N N N N N N N N N N N N N N N N Ns4C EEEcrdtdttddfd}|st|j\}}n"t |j}t }|d||d||d|j|r|d t |jtd d d kS) z@Display which files would be deleted and prompt for confirmationrTr[r"Nc|sdSt|t5tt |D]}t| ddddS#1swxYwYdSr3)rrrrhrl)rTr[r%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)rrrr[r4rrr)rrrrrs r+rz$UninstallPathSet._allowed_to_proceeds &# &hsm & & & & & %@%L%L "Kdj//KI+...> JJJ8$,GGG  M H*,? ,K,K L L L$n55<.s.       r-stdlib platstdlibzz.UninstallPathSet.from_dist..s8&&&&j00000r-r@rBrCzCannot uninstall {!r}. It is a distutils installed project and thus we cannot accurately determine which files belong to it which would lead to only a partial uninstall.z.eggrzeasy-install.pthz./rz;Egg-link {} does not match installed location of {} (at {})z)Not sure how to uninstall: %s - Check: %sscriptsz.batconsole_scripts)groupF gui_scriptsT)0rrOrrrr^sysprefix sysconfigget_pathrrMrHr to_filenameegg_infor$r%rgetattr _providerrPr5 has_metadata get_metadata splitlinesnormpathr&rrQr~rrZopenrpreadlinestriprmetadata_isdirmetadata_listdirrrrr get_entry_mapkeysextendr,)clsr dist_pathr*develop_egg_linkdevelop_egg_link_egg_infoegg_info_existsdistutils_egg_infoinstalled_filer% top_level_pkgeasy_install_eggeasy_install_pthfh link_pointerscriptr(_scripts_to_removernamersrs @r+ from_distzUninstallPathSet.from_distsg"4=11 T""  KKC     3t99    (22I4F|4T4TU     KKN    3t99 #d))6t7HII$1$8$8  %d&7 8 8% % !-IBGNN4=,I,I$T^VTBB M  &&{33M M**+DEEM     . . .  !677 7&*&7&7)''*,,..N7++BGLL,W,WXXD#''---- .""?33 7$$%=>>$!%!2!23K!L!LJJ!#J&&&&!..??JJLL&&& 7 7M 7<< }EED#''---#''u 555#''v 666#''v 6666 , %FFLf%GG ] # #F + +#     . . .!w}}T];;A> !w|| ..0B     # #$4d=M6M N N N N  !7!7 !E!E ,T22 * *##D)))) * &'' G2!w// 0C0C0E0EFF  G G G G G G G G G G G G G G G ---LSSd/.--    0 1 1 1!w|| 0113E     # #$4dm D D D D LL;       Y ' ' PD,?,? ,J,J P// :: P P#D))/*nnGG,..G##BGLL&$A$ABBBP#'' Wf(E(E(NOOO ,,3D,EE#((** H HD  % %mD$&F&F G G G G((}(== $$&& G GD  % %mD$&E&E F F F F# # #A    " " " "s*AR::R>R>)FFr)rrrrrrrrrr5rrrrr classmethodr#ror-r+rr<sd6\6d6666st......&''C'D''''NN4N$N4NNNN:=4=D====8    ####I\I.@III[IIIr-rcBeZdZdeddfdZdeddfdZd dZdefdZdS) rrr"NcH||_t|_d|_dSr3)filer4entries _saved_lines)rrs r+rzUninstallPthEntries.__init__Cs" !$ 37r-rctj|}tr;tj|ds|dd}|j|dS)Nr\/)r$r%rpr splitdrivereplacer(r5)rrs r+r5zUninstallPthEntries.addHsl  ''  -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 Nro)rdlines r+rgz-UninstallPthEntries.remove..bs&114w$111111r-z  zutf-8zRemoving entry: %swb)rrr'r$r%rwarningr  readlinesr)rirPencoder(rrJ writelines)rrlinesendliners r+rzUninstallPthEntries.removeWs76 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;c&|j"td|jdStd|jt |jd5}||jdddn #1swxYwYdS)Nz.Cannot roll back changes to %s, none were madeFz!Rolling %s back to previous stater5T)r)rrr'rr r9)rrs r+rzUninstallPthEntries.rollbackrs   $ LLI49 U U U5 8$)DDD $)T " " -b MM$+ , , , - - - - - - - - - - - - - - -tsBB  B r) rrrrrr5rrrror-r+rrBs888888         !!!!6$r-r)9rDr9r$rrimportlib.utilrtypingrrrrrr r r r pip._vendorr pip._vendor.pkg_resourcesrpip._internal.exceptionsrpip._internal.locationsrrpip._internal.utils.compatrpip._internal.utils.egg_linkrpip._internal.utils.loggingrrpip._internal.utils.miscrrrrrrrpip._internal.utils.temp_dirrrrrrrr,r;rZrlrrrrrror-r+rHsg  ,,,,,,VVVVVVVVVVVVVVVVVVVVVV%%%%%%222222888888@@@@@@@@......DDDDDD========NMMMMMMM 8   3c* hsm+, #x}:L1M     (|( ((( (V8C=SX&Ax}ASAAAAD/"x}/"s3xS?Q9R/"/"/"/"df!f!f!f!f!f!f!f!RCCCCCCCCL7777777777r-