\h_ ddlZddlZddlZddlZddlmZddlmZmZm Z m Z m Z m Z m Z mZmZddlmZddlmZmZddlmZddlmZddlmZdd lmZmZdd lmZm Z m!Z!m"Z"dd l#m$Z$m%Z%dd l&m'Z'ee(Z)d e*de*de+de e*ddffdZ,dede eddffdede eddfffdZ-e-dede e*ddffdZ.de e*dee*fdZ/de e*dee*fdZ0de e*deee*ee*ffdZ1GddZ2GddZ3Gdd Z4y)!N)cache_from_source) AnyCallableDict GeneratorIterableListOptionalSetTuple)UninstallationError)get_bin_prefix get_bin_user)BaseDistribution)WINDOWS)egg_link_path_from_location) getLogger indent_log)asknormalize_pathrenamesrmtree)AdjacentTempDirectory TempDirectory)running_under_virtualenvbin_dir script_nameis_guireturnc#Ktjj||}|tsy|d|d|r|dy|dyw)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 b/root/niggaflix-v3/playground/venv/lib/python3.12/site-packages/pip/_internal/req/req_uninstall.py _script_namesr&s^ww||G[1H N  Jd  Jm $$  +&& *%%sA Afn.c |tjdtdtdttddfffd }|S)Nargskwrc?pKt}|i|D]}||vs|j||ywN)setadd)r)r*seenitemr's r%uniquez_unique..unique+s=OO D4  s66) functoolswrapsrr)r'r1s` r%_uniquer4(sG__Rc3d?)C Mdistc#vK|j}|Jd|j}|\d|d}|j}|r|dk(r/|jd|j}|d|dz }t ||d |d z }t ||D]}t jj||}||jd s9t jj|\}} | dd } t jj|| d z}|t jj|| dz}|yw)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/ Nz not installedzCannot uninstall z, RECORD file not found.pipz==zV You might be able to recover from this via: 'pip install --force-reinstall --no-deps z'.z$ Hint: The package was installed by ..py.pyc.pyo) locationiter_declared_entries installerraw_nameversionr r!r"r#endswithsplit) r6r>entriesmsgr@depentryr"dnr'bases r%uninstallation_pathsrK6sH}}H  00 ((*G!$'?@NN I.]]O2dll^4C <D9A8D9pathsctjjt}t |t D]+t fd|D}|r|j-|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|]U}j|jdxr/t|jdjk(Wyw)*N) startswithrstriplen).0 shortpathr"seps r% zcompact..ksc  OOI,,S1 2 DS))#.55c:;<C D sAA)r!r"rWr-sortedrTanyr.)rL short_paths should_skipr"rWs @@r%compactr]bsa ''++CEKu#&" )   OOD !" r5c |Dcic]"}tjj||$}}t|}t |j Dchc]$}tjj |d&c}t}t}dtdtfd |D] t fd|Drt}t}tj D]>\ }} |j fd|D|j fd| D@||z r|j||j tjztt|j ||zScc}wcc}w) 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. rrNarcttjjtjj|Sr,)r!r"normcaser#)r_s r% norm_joinz&compress_for_rename..norm_joins$ww a 011r5c3zK|]2}tjjj|4ywr,)r!r"rarR)rUwroots r%rXz&compress_for_rename..s+Grww%003Gs8;c32K|]}|ywr,)rUddirnamerbres r%rXz&compress_for_rename..sLqyw:Lc32K|]}|ywr,rg)rUfrirbres r%rXz&compress_for_rename..sHQYtWa8Hrj)r!r"rar-rYvaluesrDrTstrrZwalkupdatedifference_updater.rWmap __getitem__) rLpcase_map remaining unchecked wildcards all_files all_subdirssubdirsfilesrirbres @@@r%compress_for_renamer}usJ 1661  #Q&6H6H IX__5FG a(+GSQI%I2c2c2) GYG G !e # ')wwt} I #GWe   LGL L   H%H H I I%  ' ' 2 MM$- ()" s8''3 4y @@37Gs 'F)F ctt|}t}t}t}|D]h}|jdr|jdsd|vr.|jtjj ||j|jtt tjj|}t|}|D]}tj|D]\}} } | D]} | jdrtjj|| } tjj| sUtjj| |vsw|j| ||Dchc]"}tjj|d$c}z}||fScc}w)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-inforQ) r-rCr.r!r"rirrrar]ror#isfile) rL will_remove will_skipfoldersr|r"_normcased_filesfolderdirpath_dirfilesfnamefile_s r%compress_for_output_listingrsoe*KIeG EE ==  == '<4+? KK- . $ 3rww//78gG )$&GGFO ) GQ! )>>&) We4GGNN5)((/7GGMM%( ) ) )7K277<<4KKK  !!Ls'F5cneZdZdZd dZdedefdZdedefdZdedefdZd d Z d d Z e de fd Z y) StashedUninstallPathSetzWA set of file rename operations to stash files while tentatively uninstalling them.rNc i|_g|_yr,) _save_dirs_movesselfs r%__init__z StashedUninstallPathSet.__init__s57.0 r5r"c t|}||jtj j |<|j S#t$rtd}YOwxYw)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"ra)rr"save_dirs r%_get_directory_stashz,StashedUninstallPathSet._get_directory_stashsU  7&;D&AH3;((./}}  7$+6H 7s AAAc~tjj|}tjj|d}}d}||k7r |j|}n:tjj|}t d}||j|<tjj||}|rG|tjjk7r*tjj|j|S|jS#t $rYnwxYwtjj||}}||k7r)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"rarirKeyErrorrrelpathcurdirr#)rr"headold_headrrs r%_get_file_stashz'StashedUninstallPathSet._get_file_stashs ww%.hh ??40 77??4(D$+6H$,DOOD !''//$- w"''..077<< w7 7}}  WW__T2D(D hs D DDctjj|xr tjj| }|r|j |}n|j |}|j j||f|r4tjj|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.stashsggmmD)F"''..2F.F 006H++D1H D(+, 277==2 HHX hr5c~|jjD]}|jg|_i|_y)z0Commits the uninstall by removing stashed files.N)rrmcleanupr)rrs r%commitzStashedUninstallPathSet.commits8..0 H      r5cb|jD]}tjdg||jD]\}} tjd||tj j |stj j|rt j|n*tj j|r t|t|||jy#t$r6}tjd|tjd|Yd}~d}~wwxYw)z2Undoes the uninstall by moving stashed files back.zMoving to %s from %szReplacing %s from %szFailed to restore %sz Exception: %sN)rloggerinfodebugr!r"rrunlinkrrrrerrorr)rrtrr"exs r%rollbackz StashedUninstallPathSet.rollbacks 6A KK0 51 5 6#kk 2NHd 2 3XtD77>>(+rww~~h/GIIh'WW]]8,8$h' 2  2 3X> _b11 2sB!C// D.8,D))D.c,t|jSr,)boolrrs r% can_rollbackz$StashedUninstallPathSet.can_rollback,sDKK  r5rN)__name__ __module__ __qualname____doc__rrnrrrrrpropertyrrrgr5r%rrsj&0   CC6##*&!d!!r5rceZdZdZdeddfdZdedefdZdeddfdZ d ed eddfd Z dd ed eddfdZ d edefdZ ddZ ddZededdfdZy)UninstallPathSetzMA set of file paths to be removed in the uninstallation of a requirement.r6rNct|_t|_i|_||_t |_tjt|_ yr,) r-_paths_refuse_pth_distr _moved_pathsr2 lru_cacher_normalize_path_cached)rr6s r%rzUninstallPathSet.__init__5sG # !$ 46  35'._displaysR KK  &"75>2&DKK%& & & &s /AA%z Would remove:z+Would not remove (might be manually added):z%Would not remove (outside of prefix):zWill actually move:zProceed (Y/n)? )ynr)rnrrrr-rr}r)rrrrrs r%rz$UninstallPathSet._allowed_to_proceeds &# &hsm & &%@%M "Kdkk*KI+.> J8$,,G  *,? ,L M$n5<.iter_scripts_to_removeBsv $557 N $$(99,Wk6F6FNNN &&-7,Wk6F6FMMM  NNMs(=A;A7A;A;/A90A;9A;)3r> info_locationrrcanonical_namerlocalrr sysconfigget_pathrrA"installed_with_setuptools_egg_infor!r"rrCsetuptools_filenamer.r?r#is_file read_text splitlinesFileNotFoundErrorinstalled_by_distutilsr formatinstalled_as_eggrDririnstalled_with_dist_inforKopenrareadlinestriprsamefiler in_usersiterriter_distutils_script_namesrNotADirectoryErrorrrnr)clsr6 dist_locationrnormalized_dist_locationrtpaths_to_removedevelop_egg_linksetuptools_flat_installationinstalled_filesinstalled_filenamespace_packages namespaces top_level_pkgr"easy_install_eggeasy_install_pthfh link_pointernormalized_link_pointerrscriptrss r% from_distzUninstallPathSet.from_dists **  KK?## t9 #1-#@ zz KKC##(   t9  #((2I4F4F|4TU(  (  KKN##(  t9 d)6t}}E  3 3 ST) S}- S "**d.F.F-Gy+QRR % ((##M2"88:O*&5UN#'' ]N(STU o.O)-8P)Q&"4!>!>!>!NJ"^^O<GGI&Qj0& 7M 77<< }ED#''-#''4& 5#''4& 6#''4& 6 7 ( (%FFLfMMG  " "    .!ww}}];A> !ww|| ."    # #$4d=M6M N  * *,T2 *##D) *&' 2!ww// 0C0C0EF *9*P*P +'  77##')A ,-U<.A))-u]O1N     0 1!ww|| 013E    # #$4m D LL;    "nG$&G ::< P##BGGLL&$AB#'' Wo(NO P N" N NsD$ ' N(g6 #A    " #S( T)$!#J$&N  F"#56   sD? VVV'$A V,AV94V9 V$#V$,V69W  W )FFr)rrrrrrrnrrr.rrrrr classmethodrrgr5r%rr1s L- L$ L Hs Ht H...&''C'D'N4N$N4N:=4=D=8 #]-]2D]]r5rc@eZdZdeddfdZdeddfdZd dZdefdZy) rrrNc>||_t|_d|_yr,)filer-rE _saved_lines)rrs r%rzUninstallPthEntries.__init__Ss !$ 37r5rHctjj|}tr4tjj |ds|j dd}|j j|y)Nr\/)r!r"rar splitdrivereplacerEr.)rrHs r%r.zUninstallPthEntries.addXsS  ' 277--e4Q7MM$,E r5c4tjd|jtjj |js!tj d|jyt|jd5}|j}||_ dddtdDrd}nd}|r=|dj|jds|d|jdz|d<|jD]<} tjd ||j||zjd>t|jd 5}|j!|dddy#1swYxYw#t$rYwxYw#1swYyxYw) NzRemoving pth entries from %s:z.Cannot remove entries from nonexistent file %srbc3$K|]}d|v yw)s Nrg)rUlines r%rXz-UninstallPthEntries.remove..rs14w$1sz  zutf-8zRemoving entry: %swb)rrrr!r"rwarningr readlinesr rZrCencoderEr ValueError writelines)rrlinesendlinerHs r%rzUninstallPthEntries.removegsX6 Bww~~dii( NNKTYY W  $))T " &bLLNE %D  & 151 1GG r++GNN7,CDb GNN7$;;E"I\\ E 3U; ego55g>?  $))T " !b MM%  ! !# & &   ! !s*E39E?F3E<? F  F Fc*|j!tjd|jytj d|jt |jd5}|j |jdddy#1swYyxYw)Nz.Cannot roll back changes to %s, none were madeFz!Rolling %s back to previous stater,T)r rrrrrr1)rrs r%rzUninstallPthEntries.rollbackso    $ LLI499 U 8$))D $))T " -b MM$++ , - -s $B  Br) rrrrnrr.rrrrgr5r%rrRs9888      !6$r5r)5r2r!rrimportlib.utilrtypingrrrrrr r r r pip._internal.exceptionsr pip._internal.locationsrrpip._internal.metadatarpip._internal.utils.compatrpip._internal.utils.egg_linkrpip._internal.utils.loggingrrpip._internal.utils.miscrrrrpip._internal.utils.temp_dirrrpip._internal.utils.virtualenvrrrrnrr&r4rKr]r}rrrrrgr5r%r@sk ,WWW8@3.D=IIMC 8 & &"&,0&sD$&& iT4001  c9S$_--.  (/(Ic4o4N( (V8C=SX&Ax}ASAD."x}."s3xS?Q9R."bf!f!R^^B 77r5