� ��abc@s�ddlmZddlZddlZddlZddlZddlZddlmZm Z m Z ddl m Z ddl mZmZmZmZmZeje�Zdj�Zejd�Zd Zd �Zd efd ��YZdS( i����(tBytesIONi(t sysconfigtdetect_encodingtZipFile(tfinder(t FileOperatortget_export_entryt convert_pathtget_executabletin_venvs� s^#!.*pythonw?[0-9.]*([ ].*)?$s|# -*- coding: utf-8 -*- if __name__ == '__main__': import sys, re def _resolve(module, func): __import__(module) mod = sys.modules[module] parts = func.split('.') result = getattr(mod, parts.pop(0)) for p in parts: result = getattr(result, p) return result try: sys.argv[0] = re.sub(r'(-script\.pyw?|\.exe)?$', '', sys.argv[0]) func = _resolve('%(module)s', '%(func)s') rc = func() # None interpreted as 0 except Exception as e: # only supporting Python >= 2.6 sys.stderr.write('%%s\n' %% e) rc = 1 sys.exit(rc) cCs�d|kr�|jd�re|jdd�\}}d|kr�|jd� r�d||f}q�q�|jd�s�d|}q�n|S(Nt s /usr/bin/env it"s%s "%s"s"%s"(t startswithtsplit(t executabletenvt _executable((s?/usr/lib/python2.7/site-packages/pip/_vendor/distlib/scripts.pyt_enquote_executableBs t ScriptMakercBseZdZeZdZeedd�Z d�Z e j j d�rZd�Zd�Znddd�Zd�ZeZd �Zd �Zdd �Zd �Zed ��Zejd��Zejdks�ejdkr�ejdkr�d�Zndd�Zdd�Z RS(s_ A class to copy or create scripts from source scripts or callable specifications. cCs�||_||_||_t|_t|_tjdkpWtjdkoWtjdk|_ t d�|_ |p{t |�|_ tjdkp�tjdko�tjdk|_dS(NtposixtjavatsX.Ytnt(RsX.Y(t source_dirt target_dirt add_launcherstFalsetforcetclobbertostnamet_nametset_modetsettvariantsRt_fileopt_is_nt(tselfRRRtdry_runtfileop((s?/usr/lib/python2.7/site-packages/pip/_vendor/distlib/scripts.pyt__init__[s     cCsa|jdt�r]|jr]tjj|�\}}|jdd�}tjj||�}n|S(Ntguitpythontpythonw(tgetRR$RtpathR treplacetjoin(R%Rtoptionstdntfn((s?/usr/lib/python2.7/site-packages/pip/_vendor/distlib/scripts.pyt_get_alternate_executableks RcCs[y,t|��}|jd�dkSWdQXWn(ttfk rVtjd|�tSXdS(sl Determine if the specified executable is a script (contains a #! line) is#!NsFailed to open %s(topentreadtOSErrortIOErrortloggertwarningR(R%Rtfp((s?/usr/lib/python2.7/site-packages/pip/_vendor/distlib/scripts.pyt _is_shellss cCs^|j|�r=ddl}|jjjd�dkrV|Sn|j�jd�rV|Sd|S(Ni����sos.nametLinuxs jython.exes/usr/bin/env %s(R;RtlangtSystemt getPropertytlowertendswith(R%RR((s?/usr/lib/python2.7/site-packages/pip/_vendor/distlib/scripts.pyt_fix_jython_executables RcCs�t}|jr!|j}t}n�tj�s9t�}nqt�rptjj tj d�dtj d��}n:tjj tj d�dtj d�tj d�f�}|r�|j ||�}nt jjd�r�|j|�}ntjj|�}|rt|�}n|jd�}t jd krSd |krSd |krS|d 7}nd ||d}y|jd�Wn!tk r�td|��nX|dkr�y|j|�Wq�tk r�td||f��q�Xn|S(Ntscriptsspython%stEXEtBINDIRs python%s%stVERSIONRsutf-8tclis -X:Framess -X:FullFramess -X:Framess#!s s,The shebang (%r) is not decodable from utf-8s?The shebang (%r) is not decodable from the script encoding (%r)(tTrueRRRtis_python_buildRR RR-R/tget_pathtget_config_varR3tsystplatformR RBtnormcaseRtencodetdecodetUnicodeDecodeErrort ValueError(R%tencodingt post_interpR0tenquoteRtshebang((s?/usr/lib/python2.7/site-packages/pip/_vendor/distlib/scripts.pyt _get_shebang�sL             cCs |jtd|jd|j�S(Ntmoduletfunc(tscript_templatetdicttprefixtsuffix(R%tentry((s?/usr/lib/python2.7/site-packages/pip/_vendor/distlib/scripts.pyt_get_script_text�scCstjj|�}|j|S(N(RR-tbasenametmanifest(R%texenametbase((s?/usr/lib/python2.7/site-packages/pip/_vendor/distlib/scripts.pyt get_manifest�scCs�|jo|j}tjjd�}|s;|||}n||dkrY|jd�}n|jd�}t�} t| d��} | jd|�WdQX| j �} |||| }x�|D]�} tj j |j | �} |r�tj j | �\}}|jd�r|} nd| } y|jj| |�Wqltk r�tjd�d | }tj j|�r|tj|�ntj| |�|jj| |�tjd �ytj|�Wq�tk r�q�XqlXn�|jr| jd |� rd | |f} ntj j| �r:|j r:tjd | �q�n|jj| |�|jrl|jj| g�n|j| �q�WdS(Nsutf-8tpytttws __main__.pys.pys%s.exes:Failed to write executable - trying to use .deleteme logics %s.deletemes0Able to replace executable using .deleteme logict.s%s.%ssSkipping existing file %s(RR$RtlinesepROt _get_launcherRRtwritestrtgetvalueR-R/RtsplitextR R#twrite_binary_filet ExceptionR8R9texiststremovetrenametdebugRARR tset_executable_modetappend(R%tnamesRVt script_bytest filenamestextt use_launcherRitlaunchertstreamtzftzip_dataRtoutnametntetdfname((s?/usr/lib/python2.7/site-packages/pip/_vendor/distlib/scripts.pyt _write_script�sT             c CsQd}|rL|jdg�}|rLddj|�}|jd�}qLn|jd|d|�}|j|�jd�}|j}t�} d|jkr�| j|�nd|jkr�| jd|t j d f�nd |jkr | jd |t j d f�n|r.|jd t �r.d} nd} |j | |||| �dS(NRtinterpreter_argss %sR sutf-8R0tXs%s%sisX.Ys%s-%siR)tpywRe( R,R/RORWR_RR!R"taddRLtversionRR�( R%R^RxR0RTtargsRVtscriptRt scriptnamesRy((s?/usr/lib/python2.7/site-packages/pip/_vendor/distlib/scripts.pyt _make_script�s(  !! cCs@t}tjj|jt|��}tjj|jtjj|��}|j r||j j ||� r|t j d|�dSyt |d�}Wn&tk r�|js��nd}noX|j�}|s�t jd|j�|�dStj|jdd��}|r&t}|jd�p d}n|s�|r?|j�n|j j||�|jrq|j j|g�n|j|�n�t jd||j�|j js)t|j�\} } |j d �|j!| |�} d |kr�d } nd } tjj|�} |j"| g| |j#�|| �n|r<|j�ndS( Nsnot copying %s (up-to-date)trbs"%s: %s is an empty file (skipping)s s iRscopying and adjusting %s -> %siR+R�Re($RRR-R/RRRR`RR#tnewerR8RsR4R7R&tNonetreadlineR9tget_command_namet FIRST_LINE_REtmatchR.RHtgrouptcloset copy_fileR RtRutinfoRtseekRWR�R5(R%R�RxtadjustRtft first_lineR�RTRStlinesRVRyR�((s?/usr/lib/python2.7/site-packages/pip/_vendor/distlib/scripts.pyt _copy_scriptsR$              %cCs |jjS(N(R#R&(R%((s?/usr/lib/python2.7/site-packages/pip/_vendor/distlib/scripts.pyR&JscCs||j_dS(N(R#R&(R%tvalue((s?/usr/lib/python2.7/site-packages/pip/_vendor/distlib/scripts.pyR&NsRcCsftjd�dkrd}nd}d||f}tjdd�d}t|�j|�j}|S( NtPit64t32s%s%s.exeRhii(tstructtcalcsizet__name__trsplitRtfindtbytes(R%tkindtbitsRtdistlib_packagetresult((s?/usr/lib/python2.7/site-packages/pip/_vendor/distlib/scripts.pyRjVs cCsKg}t|�}|dkr1|j||�n|j||d|�|S(s� Make a script. :param specification: The specification, which is either a valid export entry specification (to make a script from a callable) or a filename (to make a script by copying from a source location). :param options: A dictionary of options controlling script generation. :return: A list of all absolute pathnames written to. R0N(RR�R�R�(R%t specificationR0RxR^((s?/usr/lib/python2.7/site-packages/pip/_vendor/distlib/scripts.pytmakeds   cCs4g}x'|D]}|j|j||��q W|S(s� Take a list of specifications and make scripts from them, :param specifications: A list of specifications. :return: A list of all absolute pathnames written to, (textendR�(R%tspecificationsR0RxR�((s?/usr/lib/python2.7/site-packages/pip/_vendor/distlib/scripts.pyt make_multiplews N(!R�t __module__t__doc__tSCRIPT_TEMPLATERZR�RRHRR(R3RLRMR R;RBRWR_t_DEFAULT_MANIFESTRaRdR�R�R�tpropertyR&tsetterRRRRjR�R�(((s?/usr/lib/python2.7/site-packages/pip/_vendor/distlib/scripts.pyRRs,  8   2  4-  (tioRtloggingRtreR�RLtcompatRRRt resourcesRtutilRRRRR t getLoggerR�R8tstripR�tcompileR�R�RtobjectR(((s?/usr/lib/python2.7/site-packages/pip/_vendor/distlib/scripts.pyts     (