zmc
2023-08-08 e792e9a60d958b93aef96050644f369feb25d61b
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
U
H=®dš\ã@s|ddlmZddlZddlZddlZddlZddlZddlZddlm    Z    ddl
m Z ddl m Z mZddlmZmZmZddlmZddlmZmZmZmZmZmZmZmZmZdd    lm Z m!Z!dd
l"m#Z#e#r
dd l$m%Z%m&Z&m'Z'm(Z(m)Z)m*Z*m+Z+m,Z,m-Z-dd l.m/Z/e 0e1¡Z2d d„Z3dd„Z4e4dd„ƒZ5dd„Z6dd„Z7dd„Z8Gdd„de9ƒZ:Gdd„de9ƒZ;Gdd„de9ƒZ<dS)é)Úabsolute_importN)Ú pkg_resources)ÚUninstallationError)Úbin_pyÚbin_user)ÚWINDOWSÚcache_from_sourceÚ uses_pycache)Ú
indent_log)    ÚFakeFileÚaskÚdist_in_usersiteÚ dist_is_localÚ egg_link_pathÚis_localÚnormalize_pathÚrenamesÚrmtree)ÚAdjacentTempDirectoryÚ TempDirectory)ÚMYPY_CHECK_RUNNING)    ÚAnyÚCallableÚDictÚIterableÚIteratorÚListÚOptionalÚSetÚTuple)Ú DistributioncCslt|ƒrt}nt}tj ||¡}|g}trh| |d¡| |d¡|rZ| |d¡n| |d¡|S)z‘Create 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)r rrÚosÚpathÚjoinrÚappend)ÚdistÚ script_nameÚis_guiÚbin_dirÚexe_nameÚpaths_to_remove©r+úVD:\z\workplace\VsCode\pyvenv\venv\Lib\site-packages\pip/_internal/req/req_uninstall.pyÚ _script_names'sr-cst ˆ¡‡fdd„ƒ}|S)Nc?s2tƒ}ˆ||ŽD]}||kr| |¡|VqdS©N)ÚsetÚadd)ÚargsÚkwÚseenÚitem©Úfnr+r,Úunique?s
 
z_unique.<locals>.unique)Ú    functoolsÚwraps)r6r7r+r5r,Ú_unique=sr:ccs’t t| d¡ƒ¡}|D]t}tj |j|d¡}|V| d¡rtj     |¡\}}|dd…}tj ||d¡}|Vtj ||d¡}|VqdS)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].
    ÚRECORDrú.pyNéýÿÿÿú.pycú.pyo)
ÚcsvÚreaderr Úget_metadata_linesr!r"r#ÚlocationÚendswithÚsplit)r%ÚrÚrowr"Údnr6Úbaser+r+r,Úuninstallation_pathsJs 
 rJcsJtjj‰tƒ}t|tdD]*‰t‡‡fdd„|Dƒƒ}|s| ˆ¡q|S)zÈCompact 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.©Úkeyc3s:|]2}ˆ | d¡¡o0ˆt| d¡ ˆ¡ƒˆkVqdS)Ú*N)Ú
startswithÚrstripÚlen)Ú.0Ú    shortpath©r"Úsepr+r,Ú    <genexpr>lsþzcompact.<locals>.<genexpr>)r!r"rTr/ÚsortedrPÚanyr0)ÚpathsÚ short_pathsÚ should_skipr+rSr,Úcompactbsý r[c    søtdd„|Dƒƒ}t|ƒ}ttdd„| ¡Dƒƒtd}tƒ}dd„‰|D]˜‰t‡fdd„|DƒƒrfqJtƒ}tƒ}t ˆ¡D]B\‰}}| ‡‡‡fdd„|Dƒ¡| ‡‡‡fd    d„|Dƒ¡q|||sJ|     |¡| 
ˆtj ¡qJtt |j |ƒƒ|BS)
z«Returns 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.
    css|]}tj |¡|fVqdSr.)r!r"Únormcase©rQÚpr+r+r,rU}sz&compress_for_rename.<locals>.<genexpr>css|]}tj |¡dVqdS)rN)r!r"rEr]r+r+r,rUsÿrKcWstj tjj|Ž¡Sr.)r!r"r\r#)Úar+r+r,Ú    norm_joinƒsz&compress_for_rename.<locals>.norm_joinc3s |]}tj ˆ¡ |¡VqdSr.)r!r"r\rN)rQÚw)Úrootr+r,rUˆsÿc3s|]}ˆˆˆ|ƒVqdSr.r+)rQÚd©Údirnamer`rbr+r,rUsÿc3s|]}ˆˆˆ|ƒVqdSr.r+)rQÚfrdr+r,rU’sÿ)Údictr/rVÚvaluesrPrWr!ÚwalkÚupdateÚdifference_updater0rTÚmapÚ __getitem__)    rXÚcase_mapÚ    remainingÚ    uncheckedÚ    wildcardsÚ    all_filesÚ all_subdirsÚsubdirsÚfilesr+rdr,Úcompress_for_renamevs6
ÿÿ ÿÿÿ
 
rvc Csüt|ƒ}tƒ}tƒ}tƒ}|D]>}| d¡r.q| d¡s@d|krR| tj |¡¡| |¡qtttjj|ƒƒ}t|ƒ}|D]d}t     |¡D]T\}}    }
|
D]D} |  d¡r¨q˜tj 
|| ¡} tj  | ¡r˜tj | ¡|kr˜| | ¡q˜qŠq||dd„|DƒB}||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__.pyú
.dist-infocSsh|]}tj |d¡’qS)rM)r!r"r#)rQÚfolderr+r+r,Ú    <setcomp>Êsz.compress_for_output_listing.<locals>.<setcomp>) r/rDr0r!r"rerlr\r[rir#Úisfile) rXÚ will_removeÚ    will_skipÚfoldersrur"Ú_normcased_filesrxÚdirpathÚ_ÚdirfilesÚfnameÚfile_r+r+r,Úcompress_for_output_listingžs4 
 
 ÿÿr„c@sLeZdZdZdd„Zdd„Zdd„Zdd    „Zd
d „Zd d „Z    e
dd„ƒZ dS)ÚStashedUninstallPathSetzWA set of file rename operations to stash files while
    tentatively uninstalling them.cCsi|_g|_dSr.)Ú
_save_dirsÚ_moves©Úselfr+r+r,Ú__init__Ôsz StashedUninstallPathSet.__init__cCsDz t|ƒ}Wntk
r*tdd}YnX||jtj |¡<|jS)zStashes a directory.
 
        Directories are stashed adjacent to their original location if
        possible, or else moved/copied into the user's temp dir.Ú    uninstall©Úkind)rÚOSErrorrr†r!r"r\)r‰r"Úsave_dirr+r+r,Ú_get_directory_stashÝs  z,StashedUninstallPathSet._get_directory_stashcCsºtj |¡}tj |¡d}}d}||krfz|j|}Wq†Wntk
rPYnXtj |¡|}}q"tj |¡}tdd}||j|<tj ||¡}|r´|tjjkr´tj     |j|¡S|jS)z‚Stashes a file.
 
        If no root has been provided, one will be created for the directory
        in the user's temp directory.Nr‹rŒ)
r!r"r\rer†ÚKeyErrorrÚrelpathÚcurdirr#)r‰r"ÚheadÚold_headrr’r+r+r,Ú_get_file_stashìs" 
 
 
z'StashedUninstallPathSet._get_file_stashcCsltj |¡otj |¡ }|r*| |¡}n
| |¡}|j ||f¡|r^tj |¡r^t |¡t    ||ƒ|S)zStashes the directory or file and returns its new location.
        Handle symlinks as files to avoid modifying the symlink targets.
        )
r!r"ÚisdirÚislinkrr–r‡r$Úrmdirr)r‰r"Ú path_is_dirÚnew_pathr+r+r,Ústashs 
 
 
zStashedUninstallPathSet.stashcCs,|j ¡D]\}}| ¡q
g|_i|_dS)z0Commits the uninstall by removing stashed files.N)r†ÚitemsÚcleanupr‡)r‰r€rr+r+r,Úcommits
zStashedUninstallPathSet.commitc CsÆ|jD]}tjd|žŽq|jD]˜\}}zTt d||¡tj |¡sPtj |¡r\t |¡ntj     |¡rpt
|ƒt ||ƒWq t k
r¶}zt  d|¡t d|¡W5d}~XYq Xq | ¡dS)z2Undoes the uninstall by moving stashed files back.úMoving to %s
 from %szReplacing %s from %szFailed to restore %sz Exception: %sN)r )r‡ÚloggerÚinfoÚdebugr!r"rzr˜Úunlinkr—rrrŽÚerrorrŸ)r‰r^r›r"Úexr+r+r,Úrollback&s
    z StashedUninstallPathSet.rollbackcCs
t|jƒSr.)Úboolr‡rˆr+r+r,Ú can_rollback:sz$StashedUninstallPathSet.can_rollbackN) Ú__name__Ú
__module__Ú __qualname__Ú__doc__rŠrr–rœrŸr§Úpropertyr©r+r+r+r,r…Ñs    r…c@s^eZdZdZdd„Zdd„Zdd„Zdd    „Zdd d „Zd d„Z    dd„Z
dd„Z e dd„ƒZ dS)ÚUninstallPathSetzMA set of file paths to be removed in the uninstallation of a
    requirement.cCs(tƒ|_tƒ|_i|_||_tƒ|_dSr.)r/rXÚ_refuseÚpthr%r…Ú _moved_paths)r‰r%r+r+r,rŠCs
zUninstallPathSet.__init__cCst|ƒS)zs
        Return True if the given path is one we are permitted to
        remove/modify, False otherwise.
 
        )r)r‰r"r+r+r,Ú
_permittedKszUninstallPathSet._permittedcCsˆtj |¡\}}tj t|ƒtj |¡¡}tj |¡s:dS| |¡rR|j     |¡n |j
     |¡tj  |¡ddkr„t r„|     t |ƒ¡dS)Nér<)r!r"rEr#rr\Úexistsr³rXr0r°Úsplitextr    r)r‰r"r”Útailr+r+r,r0Ts 
 zUninstallPathSet.addcCsLt|ƒ}| |¡r<||jkr*t|ƒ|j|<|j| |¡n |j |¡dSr.)rr³r±ÚUninstallPthEntriesr0r°)r‰Úpth_fileÚentryr+r+r,Úadd_pthhs 
 
zUninstallPathSet.add_pthFc    Csº|jst d|jj¡dS|jjd|jj}t d|¡tƒp|sP| |¡r¬|j}t    |jƒ}t
t |ƒƒD]}|  |¡t  d|¡ql|j ¡D] }| ¡q’t d|¡W5QRXdS)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)rXr¡r¢r%Ú project_nameÚversionr
Ú_allowed_to_proceedr²rvrVr[rœr£r±rhÚremove)r‰Ú auto_confirmÚverboseÚdist_name_versionÚmovedÚ
for_renamer"r±r+r+r,rÀrs&þÿ 
 
 
zUninstallPathSet.removecCsndd„}|st|jƒ\}}nt|jƒ}tƒ}|d|ƒ|d|ƒ|d|jƒ|r`|dt|jƒƒtddƒd    kS)
zIDisplay which files would be deleted and prompt for confirmation
        c    SsD|sdSt |¡tƒ"tt|ƒƒD]}t |¡q&W5QRXdSr.)r¡r¢r
rVr[)ÚmsgrXr"r+r+r,Ú_display—s 
z6UninstallPathSet._allowed_to_proceed.<locals>._displayz Would remove:z+Would not remove (might be manually added):z%Would not remove (outside of prefix):zWill actually move:zProceed (y/n)? )ÚyÚnrÈ)r„rXr/r°rvr )r‰rÂrÇr{r|r+r+r,r¿’s
 
 
 
 z$UninstallPathSet._allowed_to_proceedcCsR|jjst d|jj¡dSt d|jj¡|j ¡|j     ¡D] }| ¡q@dS)z1Rollback the changes previously made by remove().z'Can't roll back %s; was not uninstalledNzRolling back uninstall of %s)
r²r©r¡r¥r%r½r¢r§r±rh)r‰r±r+r+r,r§±sþ
zUninstallPathSet.rollbackcCs|j ¡dS)z?Remove temporary save dir: rollback will no longer be possible.N)r²rŸrˆr+r+r,rŸ¿szUninstallPathSet.commitc    sÎt|jƒ}t|ƒs.t d|j|tj¡||ƒS|dd„t     d¡t     d¡hDƒkrht d|j|¡||ƒS||ƒ}t
|ƒ}d  t   |j¡¡}|joœtj |j¡}t|jddƒ}|r²|j d    ¡r²|j |¡s²| |j¡| d
¡r| d
¡ ¡D]&}tj tj |j|¡¡}    | |    ¡qôn| d ¡rä| d ¡rB| d ¡‰ng‰‡fd d„| d ¡ ¡DƒD]J}
tj |j|
¡}    | |    ¡| |    d¡| |    d¡| |    d¡qbn2|rÌtd  |j¡ƒ‚n|j d¡r"| |j¡tj |j¡d} tj tj |j¡d¡} | | d| ¡nÂ|rR|j d¡rRt |ƒD]}    | |    ¡q>n’|rÔt!|dƒ} tj "|  #¡ $¡¡}W5QRX||jks¤t%d  ||j|j¡ƒ‚| |¡tj tj |¡d¡} | | |j¡nt &d||j¡| d¡rT| 'd¡rT| (d¡D]L}t)|ƒrt*}nt+}| tj ||¡¡t,r| tj ||¡d¡qg}|j-dd}| .¡D]}| /t0||dƒ¡ql|j-d d}| .¡D]}| /t0||d!ƒ¡qš|D]}| |¡q¸|S)"Nz1Not uninstalling %s at %s, outside environment %scSsh|] }|r|’qSr+r+r]r+r+r,ryÑsþz-UninstallPathSet.from_dist.<locals>.<setcomp>ÚstdlibÚ
platstdlibz<Not uninstalling %s at %s, as it is in the standard library.z {}.egg-infor"z    .egg-infozinstalled-files.txtz top_level.txtznamespace_packages.txtcsg|]}|r|ˆkr|‘qSr+r+r]©Ú
namespacesr+r,Ú
<listcomp>ùsþz.UninstallPathSet.from_dist.<locals>.<listcomp>r<r>r?z©Cannot 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.eggr´zeasy-install.pthz./rwrFz;Egg-link {} does not match installed location of {} (at {})z)Not sure how to uninstall: %s - Check: %sÚscriptsz.batÚconsole_scripts)ÚgroupFÚ gui_scriptsT)1rrCrr¡r¢rLÚsysÚprefixÚ    sysconfigÚget_pathrÚformatrÚ to_filenamer½Úegg_infor!r"rµÚgetattrÚ    _providerrDr0Ú has_metadataÚ get_metadataÚ
splitlinesÚnormpathr#rrErer»rJÚopenr\ÚreadlineÚstripÚAssertionErrorr£Úmetadata_isdirÚmetadata_listdirr rrrÚ get_entry_mapÚkeysÚextendr-)Úclsr%Ú    dist_pathr*Údevelop_egg_linkÚdevelop_egg_link_egg_infoÚegg_info_existsÚdistutils_egg_infoÚinstalled_filer"Ú top_level_pkgÚeasy_install_eggÚeasy_install_pthÚfhÚ link_pointerÚscriptr(Ú_scripts_to_removerÐÚnamerÒÚsr+rÌr,Ú    from_distÄsÎ
üÿ
ý
ÿ
ÿ  ÿ ÿ   
 þ
 
ýÿ ÿ  þÿ
ÿþ
    zUninstallPathSet.from_distN)FF)rªr«r¬r­rŠr³r0r»rÀr¿r§rŸÚ classmethodrùr+r+r+r,r¯@s    
 
 r¯c@s,eZdZdd„Zdd„Zdd„Zdd„Zd    S)
r¸cCs||_tƒ|_d|_dSr.)Úfiler/ÚentriesÚ _saved_lines)r‰r¹r+r+r,rŠJszUninstallPthEntries.__init__cCs<tj |¡}tr,tj |¡ds,| dd¡}|j |¡dS)Nrú\ú/)r!r"r\rÚ
splitdriveÚreplacerür0)r‰rºr+r+r,r0Ps
 zUninstallPthEntries.addc    Cs
t d|j¡tj |j¡s.t d|j¡dSt|jdƒ}| ¡}||_    W5QRXt
dd„|Dƒƒrld}nd}|rž|d  |  d    ¡¡sž|d|  d    ¡|d<|j D]>}z$t d
|¡| ||  d    ¡¡Wq¤tk
ràYq¤Xq¤t|jd ƒ}| |¡W5QRXdS) NzRemoving pth entries from %s:z.Cannot remove entries from nonexistent file %sÚrbcss|]}d|kVqdS)s
Nr+)rQÚliner+r+r,rUnsz-UninstallPthEntries.remove.<locals>.<genexpr>z
Ú
éÿÿÿÿzutf-8zRemoving entry: %sÚwb)r¡r£rûr!r"rzÚwarningràÚ    readlinesrýrWrDÚencoderürÀÚ
ValueErrorÚ
writelines)r‰róÚlinesÚendlinerºr+r+r,rÀ`s.ÿ
 zUninstallPthEntries.removec    CsR|jdkrt d|j¡dSt d|j¡t|jdƒ}| |j¡W5QRXdS)Nz.Cannot roll back changes to %s, none were madeFz!Rolling %s back to previous staterT)rýr¡r¥rûr£ràr )r‰rór+r+r,r§~s
ÿzUninstallPthEntries.rollbackN)rªr«r¬rŠr0rÀr§r+r+r+r,r¸Isr¸)=Ú
__future__rr@r8Úloggingr!rÓrÕÚ pip._vendorrÚpip._internal.exceptionsrÚpip._internal.locationsrrÚpip._internal.utils.compatrrr    Úpip._internal.utils.loggingr
Úpip._internal.utils.miscr r r rrrrrrÚpip._internal.utils.temp_dirrrÚpip._internal.utils.typingrÚtypingrrrrrrrrrZpip._vendor.pkg_resourcesr Ú    getLoggerrªr¡r-r:rJr[rvr„Úobjectr…r¯r¸r+r+r+r,Ú<module>s<    ,  , 
 
(3o