usr/lib/python2.7/site-packages/pip/_vendor/distlib/scripts.pyo000064400000030260147205634730020525 0ustar00 abc@sddlmZddlZddlZddlZddlZddlZddlmZm Z m Z ddl m Z ddl mZmZmZmZmZejeZdjZejdZd 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) cCsd|kr|jdre|jdd\}}d|kr|jd rd||f}qq|jdsd|}qn|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 ScriptMakercBseZdZeZdZeeddZ dZ e j j drZdZdZndddZdZeZd Zd Zdd Zd Zed ZejdZejdksejdkrejdkrdZnddZddZ RS(s_ A class to copy or create scripts from source scripts or callable specifications. cCs||_||_||_t|_t|_tjdkpWtjdkoWtjdk|_ t d|_ |p{t ||_ tjdkptjdkotjdk|_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|jdtr]|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|}|jddkSWdQXWn(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}|jjjddkrV|Sn|jjdrV|Sd|S(Nisos.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 RcCst}|jr!|j}t}ntjs9t}nqtrptjj tj ddtj d}n:tjj tj ddtj dtj df}|r|j ||}nt jjdr|j|}ntjj|}|rt|}n|jd}t jd krSd |krSd |krS|d 7}nd ||d}y|jdWn!tk rtd|nX|dkry|j|Wqtk rtd||fqXn|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_shebangsL             cCs |jtd|jd|jS(Ntmoduletfunc(tscript_templatetdicttprefixtsuffix(R%tentry((s?/usr/lib/python2.7/site-packages/pip/_vendor/distlib/scripts.pyt_get_script_textscCstjj|}|j|S(N(RR-tbasenametmanifest(R%texenametbase((s?/usr/lib/python2.7/site-packages/pip/_vendor/distlib/scripts.pyt get_manifestscCs|jo|j}tjjd}|s;|||}n||dkrY|jd}n|jd}t} t| d} | jd|WdQX| j } |||| }x|D]} tj j |j | } |rtj j | \}}|jdr|} nd| } y|jj| |Wqltk rtjdd | }tj j|r|tj|ntj| ||jj| |tjd ytj|Wqtk rqXqlXn|jr| jd | rd | |f} ntj j| r:|j r:tjd | qn|jj| ||jrl|jj| gn|j| qWdS(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_scriptsT             c CsQd}|rL|jdg}|rLddj|}|jd}qLn|jd|d|}|j|jd}|j}t} d|jkr| j|nd|jkr| jd|t j d fnd |jkr | jd |t j d fn|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_scripts(  !! cCs@t}tjj|jt|}tjj|jtjj|}|j r||j j || r|t j d|dSyt |d}Wn&tk r|jsnd}noX|j}|st jd|j|dStj|jdd}|r&t}|jdp d}n|s|r?|jn|j j|||jrq|j j|gn|j|nt jd||j|j js)t|j\} } |j d |j!| |} d |krd } nd } tjj|} |j"| g| |j#|| n|r<|jndS( Nsnot copying %s (up-to-date)trbs"%s: %s is an empty file (skipping)s s iRscopying and adjusting %s -> %siR+RRe($RRR-R/RRRR`RR#tnewerR8RsR4R7R&tNonetreadlineR9tget_command_namet FIRST_LINE_REtmatchR.RHtgrouptcloset copy_fileR RtRutinfoRtseekRWRR5(R%RRxtadjustRtft first_lineRRTRStlinesRVRyR((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&NsRcCsftjddkrd}nd}d||f}tjddd}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(RRRR(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(!Rt __module__t__doc__tSCRIPT_TEMPLATERZRRRHRR(R3RLRMR R;RBRWR_t_DEFAULT_MANIFESTRaRdRRRtpropertyR&tsetterRRRRjRR(((s?/usr/lib/python2.7/site-packages/pip/_vendor/distlib/scripts.pyRRs,  8   2  4-  (tioRtloggingRtreRRLtcompatRRRt resourcesRtutilRRRRR t getLoggerRR8tstripRtcompileRRRtobjectR(((s?/usr/lib/python2.7/site-packages/pip/_vendor/distlib/scripts.pyts     (