Current File : //proc/self/root/proc/2/cwd/opt/alt/python35/lib/python3.5/site-packages/pip/util.pyo
�
�wMVc@s?ddlZddlZddlZddlZddlZddlZddlZddlZddlZddl Z ddl
Z
ddlmZm
Z
mZddlmZmZmZmZmZmZddlmZmZmZddlmZddlmZddlmZdd d
ddd
ddddddddddddddddddd gZ d!�Z!e"d"�Z#d#�Z$d$�Z%d%d&�Z&ddd'�Z(dd(�Z)d)�Z*d*�Z+d+e,fd,��YZ-e-�Z.[-ej/d-ej0�Z1d.�Z2d/�Z3d0�Z4d1�Z5d2�Z6d3�Z7d4�Z8d5�Z9d6�Z:d7�Z;d8�Z<d9�Z=d:�Z>d;�Z?d<�Z@d=�ZAeBdPeBe"dB�ZCdC�ZDdD�ZEdE�ZFdF�ZGeBdG�ZHdH�ZIdI�ZJdJ�ZKdK�ZLeBddeBejMdddL�ZNdM�ZOdNe,fdO��YZPdS(Qi����N(tInstallationErrort
BadCommandtPipError(tWindowsErrortstring_typest raw_inputtconsole_to_strt user_sitetPermissionError(t
site_packagestrunning_under_virtualenvtvirtualenv_no_global(tlogger(t
pkg_resources(tversiontrmtreetdisplay_patht
backup_dirtfind_commandtasktInftnormalize_nametsplitexttformat_sizetis_installable_dirtis_svn_paget
file_contentstsplit_leading_dirthas_leading_dirtmake_path_relativetnormalize_pathtrenamestget_terminal_sizetget_progt
unzip_filet
untar_filetcreate_download_cache_foldertcache_downloadtunpack_filetcall_subprocesscCsOy.tjjtjd�dkr-dtjSWntttfk
rJnXdS(Nis__main__.pys-cs %s -m piptpip(s__main__.pys-c( tostpathtbasenametsystargvt
executabletAttributeErrort TypeErrort
IndexError(((s9/opt/alt/python35/lib/python3.5/site-packages/pip/util.pyR!!scCstj|d|dt�dS(Nt
ignore_errorstonerror(tshutilRtrmtree_errorhandler(tdirR2((s9/opt/alt/python35/lib/python3.5/site-packages/pip/util.pyR*scCs�|d \}}|tkr/|jddkpj|tkrN|jddkpj|tkoj|jddkss�ntj|�jtj@tjkr��ntj|tj �||�dS(s�On Windows, the files in .svn are read-only, so when rmtree() tries to
remove them, an exception is thrown. We catch that here, remove the
read-only attribute, and hopefully continue without problems.iiii
iN(
RtargstOSErrorRR)tstattst_modetS_IREADtchmodtS_IWRITE(tfuncR*texc_infotexctypetvalue((s9/opt/alt/python35/lib/python3.5/site-packages/pip/util.pyR5/s"cCs^tjjtjj|��}|jtj�tjj�rZd|ttj��}n|S(sTGives the display value for a given path, making it relative to cwd
if possible.t.(R)R*tnormcasetabspatht
startswithtgetcwdtseptlen(R*((s9/opt/alt/python35/lib/python3.5/site-packages/pip/util.pyRBss.bakcCsKd}|}x4tjj||�rB|d7}|t|�}qW||S(s\Figure out the name of a directory to back up the given dir to
(adding .bak, .bak2, etc)i(R)R*texistststr(R6texttnt extension((s9/opt/alt/python35/lib/python3.5/site-packages/pip/util.pyRKs
cCsI|dkr0tjjdd�jtj�}nt|t�rK|g}n|dkrct�}ng|j �jtj�D]}t
|�r||^q|}tjj|�dj �|kr�dg}nxj|D]b}tjj
||�}x.|D]&}||}tjj|�r�|Sq�Wtjj|�r�|Sq�Wtd|��dS(s<Searches the PATH for the given command and returns its pathtPATHtisCannot find command %rN(tNoneR)tenvirontgettsplittpathsept
isinstanceRtget_pathexttlowerRHR*RtjointisfileR(tcmdtpathstpathextRKR*tcmd_pathtcmd_path_ext((s9/opt/alt/python35/lib/python3.5/site-packages/pip/util.pyRVs$$7"
cCsF|dkr-tjjddddg�}ntjjd|�}|S(s9Returns the path extensions from environment or a defaults.COMs.EXEs.BATs.CMDtPATHEXTN(RPR)RTRXRQRR(tdefault_pathextR\((s9/opt/alt/python35/lib/python3.5/site-packages/pip/util.pyRVqs!cCsCx3tjjdd�j�D]}||kr|SqWt||�S(NtPIP_EXISTS_ACTIONRO(R)RQRRRSR(tmessagetoptionstaction((s9/opt/alt/python35/lib/python3.5/site-packages/pip/util.pytask_path_existsys"cCsxxqtjjd�r(td|��nt|�}|j�j�}||krmd|dj|�fGHq|SqdS(s@Ask the message interactively, with the given possible responsestPIP_NO_INPUTs7No input was expected ($PIP_NO_INPUT set); question: %ss<Your response (%r) was not one of the expected responses: %ss, N(R)RQRRt ExceptionRtstripRWRX(RbRctresponse((s9/opt/alt/python35/lib/python3.5/site-packages/pip/util.pyR�st_InfcBsMeZdZd�Zd�Zd�Zd�Zd�Zd�Zd�Z RS(sI am bigger than everything!cCs||krtStSdS(N(tTruetFalse(tselftother((s9/opt/alt/python35/lib/python3.5/site-packages/pip/util.pyt__eq__�scCs|j|�S(N(Ro(RmRn((s9/opt/alt/python35/lib/python3.5/site-packages/pip/util.pyt__ne__�scCstS(N(Rl(RmRn((s9/opt/alt/python35/lib/python3.5/site-packages/pip/util.pyt__lt__�scCstS(N(Rl(RmRn((s9/opt/alt/python35/lib/python3.5/site-packages/pip/util.pyt__le__�scCstS(N(Rk(RmRn((s9/opt/alt/python35/lib/python3.5/site-packages/pip/util.pyt__gt__�scCstS(N(Rk(RmRn((s9/opt/alt/python35/lib/python3.5/site-packages/pip/util.pyt__ge__�scCsdS(NR((Rm((s9/opt/alt/python35/lib/python3.5/site-packages/pip/util.pyt__repr__�s(
t__name__t
__module__t__doc__RoRpRqRrRsRtRu(((s9/opt/alt/python35/lib/python3.5/site-packages/pip/util.pyRj�s s[^a-z]cCstjd|j��S(Nt-(t
_normalize_retsubRW(tname((s9/opt/alt/python35/lib/python3.5/site-packages/pip/util.pyR�scCsX|dkrd|ddS|d kr4d|dS|dkrLd|dSd|SdS(
Ni�s%.1fMBg@�@i
s%ikBs%.1fkBs%ibytesi@Bi'((tbytes((s9/opt/alt/python35/lib/python3.5/site-packages/pip/util.pyR�scCsEtjj|�stStjj|d�}tjj|�rAtStS(s@Return True if `path` is a directory containing a setup.py file.ssetup.py(R)R*tisdirRlRXRYRk(R*tsetup_py((s9/opt/alt/python35/lib/python3.5/site-packages/pip/util.pyR�scCs(tjd|�o'tjd|tj�S(sJReturns true if the page appears to be the index page of an svn repositorys<title>[^<]*Revision \d+:s#Powered by (?:<a[^>]*?>)?Subversion(tretsearchtI(thtml((s9/opt/alt/python35/lib/python3.5/site-packages/pip/util.pyR�scCs8t|d�}z|j�jd�SWd|j�XdS(Ntrbsutf-8(topentreadtdecodetclose(tfilenametfp((s9/opt/alt/python35/lib/python3.5/site-packages/pip/util.pyR�scCs�t|�}|jd�jd�}d|krvd|krZ|jd�|jd�ksfd|krv|jdd�Sd|kr�|jdd�S|dfSdS(Nt/s\iRO(RJtlstriptfindRS(R*((s9/opt/alt/python35/lib/python3.5/site-packages/pip/util.pyR�s6cCs\d}xO|D]G}t|�\}}|s/tS|dkrD|}q
||kr
tSq
WtS(syReturns true if all the paths have the same leading path name
(i.e., everything is in one subdirectory in an archive)N(RPRRlRk(R[t
common_prefixR*tprefixtrest((s9/opt/alt/python35/lib/python3.5/site-packages/pip/util.pyR�s
cCs7tjj|�}tjj|�}tjjtjj|��}tjjtjj|��}|jtjj�jtjj�}|jtjj�jtjj�}x>|r�|r�|d|dkr�|j d�|j d�q�Wdgt
|�||g}|dgkr$dtjjStjjj|�S(s
Make a filename relative, where the filename path, and it is
relative to rel_to
>>> make_relative_path('/usr/share/something/a-file.pth',
... '/usr/share/another-place/src/Directory')
'../../../something/a-file.pth'
>>> make_relative_path('/usr/share/something/a-file.pth',
... '/home/user/src/Directory')
'../../../usr/share/something/a-file.pth'
>>> make_relative_path('/usr/share/a-file.pth', '/usr/share/')
'a-file.pth'
is..RORB(R)R*R+tdirnametnormpathRDRhRGRStpopRHRX(R*trel_tot
path_filenamet
path_partstrel_to_partst
full_parts((s9/opt/alt/python35/lib/python3.5/site-packages/pip/util.pyR�s$$#
cCs(tjjtjjtjj|���S(sN
Convert a path to its canonical, case-normalized, absolute version.
(R)R*RCtrealpatht
expanduser(R*((s9/opt/alt/python35/lib/python3.5/site-packages/pip/util.pyRscCsOtj|�\}}|j�jd�rE|d|}|d }n||fS(s,Like os.path.splitext, but take off .tar toos.tari����(t posixpathRRWtendswith(R*tbaseRK((s9/opt/alt/python35/lib/python3.5/site-packages/pip/util.pyRs
cCs�tjj|�\}}|rG|rGtjj|�rGtj|�ntj||�tjj|�\}}|r�|r�ytj|�Wq�tk
r�q�XndS(s7Like os.renames(), but handles renaming across devices.N( R)R*RSRItmakedirsR4tmovet
removedirsR8(toldtnewtheadttail((s9/opt/alt/python35/lib/python3.5/site-packages/pip/util.pyR!s
cCs)t�s
tSt|�jttj��S(s�
Return True if path is within sys.prefix, if we're running in a virtualenv.
If we're not in a virtualenv, all paths are considered "local."
(R
RkRRER,R�(R*((s9/opt/alt/python35/lib/python3.5/site-packages/pip/util.pytis_local2s cCstt|��S(s�
Return True if given Distribution object is installed locally
(i.e. within current virtualenv).
Always True if we're not in a virtualenv.
(R�t
dist_location(tdist((s9/opt/alt/python35/lib/python3.5/site-packages/pip/util.pyt
dist_is_local>scCs-tr%tt|��jtt��StSdS(sF
Return True if given Distribution is installed in user site.
N(RRR�RERl(R�((s9/opt/alt/python35/lib/python3.5/site-packages/pip/util.pytdist_in_usersiteIscCstt|��jtt��S(sa
Return True if given Distribution is installed in distutils.sysconfig.get_python_lib().
(RR�RER (R�((s9/opt/alt/python35/lib/python3.5/site-packages/pip/util.pytdist_in_site_packagesRscCs)ddlm}|j|g�}|jS(s$Is distribution an editable install?i����(tFrozenRequirement(R(R�t from_distteditable(R�R�treq((s9/opt/alt/python35/lib/python3.5/site-packages/pip/util.pytdist_is_editableYst
setuptoolsR(tpythont
distributecCs�|rt}n d�}|r*d�}n d�}|rEd�}n d�}gtjD]?}||�rX|j|krX||�rX||�rX|^qXS(s�
Return a list of installed Distribution objects.
If ``local_only`` is True (default), only return installations
local to the current virtualenv, if in a virtualenv.
``skip`` argument is an iterable of lower-case project names to
ignore; defaults to ('setuptools', 'pip', 'python'). [FIXME also
skip virtualenv?]
If ``editables`` is False, don't report editables.
If ``editables_only`` is True , only report editables.
cSstS(N(Rk(td((s9/opt/alt/python35/lib/python3.5/site-packages/pip/util.pyt<lambda>vscSstS(N(Rk(R�((s9/opt/alt/python35/lib/python3.5/site-packages/pip/util.pyR�yscSst|�S(N(R�(R�((s9/opt/alt/python35/lib/python3.5/site-packages/pip/util.pyR�{scSs
t|�S(N(R�(R�((s9/opt/alt/python35/lib/python3.5/site-packages/pip/util.pyR�~scSstS(N(Rk(R�((s9/opt/alt/python35/lib/python3.5/site-packages/pip/util.pyR��s(R�R
tworking_settkey(t
local_onlytskiptinclude_editablesteditables_onlyt
local_testt
editable_testteditables_only_testR�((s9/opt/alt/python35/lib/python3.5/site-packages/pip/util.pytget_installed_distributions`s cCs�g}t�rNt�r(|jt�qq|jt�trq|jt�qqn#trd|jt�n|jt�x@|D]8}tjj||j�d}tjj |�rx|SqxWdS(s
Return the path for the .egg-link file if it exists, otherwise, None.
There's 3 scenarios:
1) not in a virtualenv
try to find in site.USER_SITE, then site_packages
2) in a no-global virtualenv
try to find in site_packages
3) in a yes-global virtualenv
try to find in site_packages, then site.USER_SITE (don't look in global location)
For #1 and #3, there could be odd cases, where there's an egg-link in 2 locations.
This method will just return the first one found.
s .egg-linkN(
R
RtappendR RR)R*RXtproject_nameRY(R�tsitestsitetegglink((s9/opt/alt/python35/lib/python3.5/site-packages/pip/util.pyt
egg_link_path�s
cCst|�}|r|S|jS(s�
Get the site-packages location of this distribution. Generally
this is dist.location, except in the case of develop-installed
packages, where dist.location is the source code location, and we
want to know where the egg-link file is.
(R�tlocation(R�tegg_link((s9/opt/alt/python35/lib/python3.5/site-packages/pip/util.pyR��scCs�d�}|d�p*|d�p*|d�}|sxy8tjtj�tj�}||�}tj|�WqxqxXn|s�tjjdd�tjjdd�f}nt|d�t|d�fS( slReturns a tuple (x, y) representing the width(x) and the height(x)
in characters of the terminal window.cSs{yLddl}ddl}ddl}|jd|j||jd��}WndSX|dkrgdS|dkrwdS|S(Ni����thht1234i(ii(ii(tfcntlttermioststructtunpacktioctlt
TIOCGWINSZRP(tfdR�R�R�tcr((s9/opt/alt/python35/lib/python3.5/site-packages/pip/util.pytioctl_GWINSZ�siiitLINESitCOLUMNSiP(R)R�tctermidtO_RDONLYR�RQRRtint(R�R�R�((s9/opt/alt/python35/lib/python3.5/site-packages/pip/util.pyR �s $-cCs tjd�}tj|�|S(sBGet the current umask which involves having to set it temporarily.i(R)tumask(tmask((s9/opt/alt/python35/lib/python3.5/site-packages/pip/util.pyt
current_umask�s
c
Cs�tjj|�s"tj|�nt|d�}z}tj|�}t|j��oX|}xO|j �D]A}|j
}|j|�}|} |r�t|�d} ntjj
|| �} tjj| �}
tjj|
�s�tj|
�n| jd�s| jd�r1tjj| �s�tj| �q�qht| d�}z|j|�Wd|j�|jd?}|r�tj|�r�|d@r�tj| d t�dB�nXqhWWd|j�XdS(
s�
Unzip the file (with path `filename`) to the destination `location`. All
files are written based on system defaults and umask (i.e. permissions are
not preserved), except that regular file members with any execute
permissions (user, group, or world) have "chmod +x" applied after being
written. Note that for windows, any execute changes using os.chmod are
no-ops per the python docs.
R�iR�s\twbNiiIi�(R)R*RIR�R�tzipfiletZipFileRtnamelisttinfolistR�R�RRXR�R�twriteR�t
external_attrR9tS_ISREGR<R�(
R�R�tflattentzipfptziptleadingtinfoR|tdatatfnR6R�tmode((s9/opt/alt/python35/lib/python3.5/site-packages/pip/util.pyR"�s6
'c Cstjj|�s"tj|�n|j�jd�sL|j�jd�rUd}nh|j�jd�s|j�jd�r�d}n5|j�jd�r�d}ntjd |�d
}tj ||�}z&t
g|j�D]}|jdkr�|j^q��}x�|j�D]�}|j}|dkr7qn|rPt
|�d}ntjj||�}|j�r�tjj|�s�tj|�q�q|j�r�y|j||�Wq�tj�d}tjd
||j|f�qq�Xqy|j|�} WnGttfk
rOtj�d}tjd
||j|f�qnXtjjtjj|��s�tjtjj|��nt |d�}
ztj| |
�Wd|
j�X| j�|jd@rtj|dt�dB�qqWWd|j�XdS(s�
Untar the file (with path `filename`) to the destination `location`.
All files are written based on system defaults and umask (i.e. permissions
are not preserved), except that regular file members with any execute
permissions (user, group, or world) have "chmod +x" applied after being
written. Note that for windows, any execute changes using os.chmod are
no-ops per the python docs.
s.gzs.tgzsr:gzs.bz2s.tbzsr:bz2s.tartrs-Cannot determine compression type for file %ssr:*tpax_global_headeris/In the tar file %s the member %s is invalid: %sR�NiIi�(R)R*RIR�RWR�RtwarnttarfileR�Rt
getmembersR|RRXR~tissymt_extract_memberR,R?textractfiletKeyErrorR/R�R4tcopyfileobjR�R�R<R�(R�R�R�ttartmemberR�R�R*teR�tdestfp((s9/opt/alt/python35/lib/python3.5/site-packages/pip/util.pyR#sh * * !
&cCs@tjd8_tjd|�tjd7_tj|�dS(Nis&Creating supposed download cache at %s(RtindenttnotifyR)R�(tfolder((s9/opt/alt/python35/lib/python3.5/site-packages/pip/util.pyR$XscCsUtjdt|��tj||�t|dd�}|j|�|j�dS(NsStoring download in cache at %ss
.content-typetw(RR�RR4tcopyfileR�R�R�(ttarget_filet
temp_locationtcontent_typeR�((s9/opt/alt/python35/lib/python3.5/site-packages/pip/util.pyR%_s
c
CsCtjj|�}|dksZ|jd�sZ|jd�sZ|jd�sZtj|�rzt||d|jd��n�|dks�tj|�s�t |�dj
�dkr�t||�n~|r|jd
�rt
t|��rddlm}|d|j�j|�n*tjd|||f�td|��dS(Nsapplication/zips.zips .pybundles.whlR�sapplication/x-gzipis.tars.tar.gzs.tar.bz2s.tgzs.tbzs text/htmli����(t
Subversionssvn+sZCannot unpack file %s (downloaded from %s, content-type: %s); cannot detect archive formats%Cannot determine archive format of %s(s .pybundles.whl(s.tars.tar.gzs.tar.bz2s.tgzs.tbz(R)R*R�R�R�t
is_zipfileR"R�t
is_tarfileRRWR#RERRtpip.vcs.subversionRturlR�RtfatalR(R�R�R�tlinkR((s9/opt/alt/python35/lib/python3.5/site-packages/pip/util.pyR&gs$ cCs�|dkr�g}xd|D]\} d| ksOd| ksOd| ksOd| krhd| jdd�} n|j| �qWdj|�}n|r�d}
n tj}
tj|d|�tj j
�}|r�|j|�ny4tj|dtj
d dd
|
d|d|�}Wn;tk
rMtj�d
}
tjd|
|f��nXg}|
dk r|j}
x�t|
j��}|s�Pn|j�}|j|d�|r||�}t|t�r�|\}}ntj||�tj|�stj�qqltj|�qln!|j�\}}|p2dg}|j�|jr�|r�|r�tjd|�tjdj|�d�ntd||j|f��q�tj d||j|f�n|
dk r�dj|�SdS(Nt s
t"t's"%s"s\"sRunning command %ststderrtstdintstdouttcwdtenvis#Error %s while executing command %sROs Complete output from command %s:s)
----------------------------------------s*Command %s failed with error code %s in %ss"Command %s had error code %s in %s(!RPtreplaceR�RXt
subprocesstPIPERtlogR)RQtcopytupdatetPopentSTDOUTRgR,R?RRRtreadlinetrstripRUttupletstdout_level_matchest
show_progressR�tcommunicatetwaitt
returncodeR�RR�(RZtshow_stdoutt
filter_stdoutR
traise_on_returncodet
command_leveltcommand_desct
extra_environt cmd_partstpartRRtprocR�t
all_outputtlinetleveltreturned_stdouttreturned_stderr((s9/opt/alt/python35/lib/python3.5/site-packages/pip/util.pyR'�sp
0
c
Cstj|�}|dkrtStj|�}tg|D]@}tg|D]'}|tdddddg�k^qH�^q8�S(s�
Attempt to determine if this is a pre-release using PEP386/PEP426 rules.
Will return True if it is a pre-release and False if not. Versions are
assumed to be a pre-release if they cannot be parsed.
tatbtctrctdevN(Rt_suggest_normalized_versionRPRkt_normalized_keytanytset(tverst
normalizedtparsedtxty((s9/opt/alt/python35/lib/python3.5/site-packages/pip/util.pyt
is_prerelease�s
tBuildDirectorycBs;eZddd�Zd�Zd�Zd�Zd�ZRS(cCsm|dkr!|dkr!t}n|dkrWtjdd�}|dkrWt}qWn||_||_dS(NR�s
pip-build-(RPRkttempfiletmkdtempR|tdelete(RmR|R?((s9/opt/alt/python35/lib/python3.5/site-packages/pip/util.pyt__init__�s cCsdj|jj|j�S(Ns <{} {!r}>(tformatt __class__RvR|(Rm((s9/opt/alt/python35/lib/python3.5/site-packages/pip/util.pyRu�scCs|jS(N(R|(Rm((s9/opt/alt/python35/lib/python3.5/site-packages/pip/util.pyt __enter__�scCs|j�dS(N(tcleanup(RmtexcRAttb((s9/opt/alt/python35/lib/python3.5/site-packages/pip/util.pyt__exit__�scCs|jrt|j�ndS(N(R?RR|(Rm((s9/opt/alt/python35/lib/python3.5/site-packages/pip/util.pyRD�s N(RvRwRPR@RuRCRGRD(((s9/opt/alt/python35/lib/python3.5/site-packages/pip/util.pyR<�s
(R�spipspythonR�(QR,R4R)R9R�R�R�R�RttextwrapR=tpip.exceptionsRRRtpip.backwardcompatRRRRRRt
pip.locationsR R
Rtpip.logRtpip._vendorR
tpip._vendor.distlibRt__all__R!RlRR5RRRPRRVReRtobjectRjRtcompileR�RzRRRRRRRRRRRR�R�R�R�R�RkR�R�R�R R�R"R#R$R%R&tDEBUGR'R;R<(((s9/opt/alt/python35/lib/python3.5/site-packages/pip/util.pyt<module>s�.
' " - L ?