a
Re\ @ s d dl Z d dlZd dlZd dlZd dlZd dlmZ d dlmZm Z m
Z
mZmZm
Z
mZmZmZ d dlmZ d dlmZ d dlmZ d dlmZmZ d dlmZ d d lmZ d d
lmZm Z d dl!m"Z"m#Z#m$Z$m%Z%m&Z&m'Z'm(Z( d dl)m*Z*m+Z+ ee,Z-ee.e/e
e. d
ddZ0e dee f e dee f dddZ1e1eee. dddZ2ee. ee. dddZ3ee. ee. dddZ4ee. eee. ee. f dddZ5G dd dZ6G d d! d!Z7G d"d# d#Z8dS )$ N)cache_from_source) AnyCallableDictIterableIteratorListOptionalSetTuple)
pkg_resources)Distribution)UninstallationError)get_bin_prefixget_bin_user)WINDOWS)egg_link_path_from_location) getLogger
indent_log)askdist_in_usersite
dist_is_localis_localnormalize_pathrenamesrmtree)AdjacentTempDirectory
TempDirectory)distscript_nameis_guireturnc C sp t | rt }nt }tj||}|g}trl||d ||d |r^||d n||d |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)r r r ospathjoinr append)r r r bin_direxe_namepaths_to_remove r) /builddir/build/BUILDROOT/alt-python39-pip-21.3.1-2.el8.x86_64/opt/alt/python39/lib/python3.9/site-packages/pip/_internal/req/req_uninstall.py
_script_names s r+ .)fnr! c s( t tttt d fdd}|S )N)argskwr! c ? s6 t } | i |D ]}||vr|| |V qd S N)setadd)r- r. seenitemr, r) r* unique5 s
z_unique..unique) functoolswrapsr r )r, r5 r) r4 r* _unique4 s r8 r r! c
c s8 zt | d}W n ty } zdj| d}z$t| d}|rL|dkrRt W n6 tttfy d| j | j
}|d|7 }Y n0 |d|7 }t||W Y d }~n
d }~0 0 |D ]t}tj
| j|d
}|V |drtj
|\}} | d d }
tj
||
d
}|V tj
||
d }|V qd 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{}=={}zZ You might be able to recover from this via: 'pip install --force-reinstall --no-deps {}'.z' Hint: The package was installed by {}.Nr .py.pyc.pyo)csvreaderget_metadata_linesFileNotFoundErrorformatnext
ValueErrorOSError
StopIterationproject_nameversionr r" r# r$ locationendswithsplit)r rmissing_record_exceptionmsg installerdeprowr# dnr, baser) r) r* uninstallation_paths@ s6
rW )pathsr! c sJ t jjt }t| tdD ]* t fdd|D }|s| q|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.keyc 3 s: | ]2} |d o0 t|d kV qdS )*N)
startswithrstriplen).0 shortpathr# sepr) r* u s zcompact..)r" r# rb r0 sortedr^ anyr1 )rX short_pathsshould_skipr) ra r* compactl s rh c s dd | D }t |}tdd | D td}t }ttddd|D ]tfd d
|D rfqJt }t }tD ]B\ }}| fdd
|D | fdd
|D q||| sJ| | |
tj qJt t|j
||B S )
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.
c S s i | ]}t j||qS r) )r" r# normcaser_ pr) r) r*