ž 7’Re0c@sðddlmZddlZddlZddlZddlZddlZddlmZm Z m Z m Z ddl m Z ddlmZmZmZmZmZejeƒZdjƒZejdƒZd ZGd d „d eƒZdS( i(uBytesIONi(u sysconfigufsencodeudetect_encodinguZipFile(ufinder(u FileOperatoruget_export_entryu convert_pathuget_executableuin_venvuñ s^#!.*pythonw?[0-9.]*([ ].*)?$u{# -*- 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) cBs|EeZdZdZeZdZddddd„Z dd„Z dddd„Z d d „Z eZd d „Zd d„Zddd„Zdd„Zedd„ƒZejdd„ƒZejdkrßdd„Znddd„Zddd„ZdS( u ScriptMakeru_ A class to copy or create scripts from source scripts or callable specifications. cCsg||_||_||_d|_d|_tjdk|_t dƒ|_ |p]t |ƒ|_ dS(NuposixuuX.YF(uuX.Y( u source_diru target_diru add_launchersuFalseuforceuclobberuosunameuset_modeusetuvariantsu FileOperatoru_fileop(uselfu source_diru target_diru add_launchersudry_runufileop((u4/tmp/pip-zej_zi-build/pip/_vendor/distlib/scripts.pyu__init__Ks     uScriptMaker.__init__cCsg|jddƒrctjdkrctjj|ƒ\}}|jddƒ}tjj||ƒ}n|S(NuguiuntupythonupythonwF(ugetuFalseuosunameupathusplitureplaceujoin(uselfu executableuoptionsudnufn((u4/tmp/pip-zej_zi-build/pip/_vendor/distlib/scripts.pyu_get_alternate_executableWs !u%ScriptMaker._get_alternate_executablescCs‡d}|jr!|j}d}n‰tjƒs9tƒ}nqtƒrptjj tj dƒdtj dƒƒ}n:tjj tj dƒdtj dƒtj dƒfƒ}|rÅ|j ||ƒ}n|räd|kräd|}nt |ƒ}d ||d }y|jd ƒWn"tk r7td |ƒ‚YnX|d krƒy|j|ƒWqƒtk rtd ||fƒ‚YqƒXn|S(Nuscriptsupython%suEXEuBINDIRu python%s%suVERSIONu u"%s"s#!s uutf-8u,The shebang (%r) is not decodable from utf-8u?The shebang (%r) is not decodable from the script encoding (%r)TF(uTrueu executableuFalseu sysconfiguis_python_builduget_executableuin_venvuosupathujoinuget_pathuget_config_varu_get_alternate_executableufsencodeudecodeuUnicodeDecodeErroru ValueError(uselfuencodingu post_interpuoptionsuenquoteu executableushebang((u4/tmp/pip-zej_zi-build/pip/_vendor/distlib/scripts.pyu _get_shebang^s@             uScriptMaker._get_shebangcCs |jtd|jd|jƒS(Numoduleufunc(uscript_templateudictuprefixusuffix(uselfuentry((u4/tmp/pip-zej_zi-build/pip/_vendor/distlib/scripts.pyu_get_script_textŒsuScriptMaker._get_script_textcCstjj|ƒ}|j|S(N(uosupathubasenameumanifest(uselfuexenameubase((u4/tmp/pip-zej_zi-build/pip/_vendor/distlib/scripts.pyu get_manifest’suScriptMaker.get_manifestcCs|jotjdk}tjjdƒ}|sA|||}n||dkr_|jdƒ}n|jdƒ}tƒ} t| dƒ} | jd|ƒWdQX| j ƒ} |||| }xË|D]Ã} tj j |j | ƒ} |ràtj j | ƒ\}}|jdƒr|} nd| } y|jj| |ƒWqztk rÜtjd ƒd | }tj j|ƒr‚tj|ƒntj| |ƒ|jj| |ƒtjd ƒytj|ƒWntk r×YnXYqzXnštjdkr| jd |ƒ rd | |f} ntj j| ƒrH|j rHtjd| ƒqÄn|jj| |ƒ|jrz|jj| gƒn|j| ƒqÄWdS(Nuntuutf-8upyutuwu __main__.pyu.pyu%s.exeu:Failed to write executable - trying to use .deleteme logicu %s.deletemeu0Able to replace executable using .deleteme logicu.u%s.%suSkipping existing file %s(u add_launchersuosunameulinesepuencodeu _get_launcheruBytesIOuZipFileuwritestrugetvalueupathujoinu target_dirusplitextu startswithu_fileopuwrite_binary_fileu Exceptionuloggeruwarninguexistsuremoveurenameudebuguendswithuclobberuset_modeuset_executable_modeuappend(uselfunamesushebangu script_bytesu filenamesuextu use_launcherulinesepulauncherustreamuzfuzip_dataunameuoutnameunueudfname((u4/tmp/pip-zej_zi-build/pip/_vendor/distlib/scripts.pyu _write_script–sT            # uScriptMaker._write_scriptc Cs|jdd|ƒ}|j|ƒjdƒ}|j}tƒ}d|jkr^|j|ƒnd|jkrŽ|jd|tjdfƒnd|jkrÄ|jd|tjdd …fƒn|rå|j d d ƒråd }nd }|j |||||ƒdS(Nuutf-8uoptionsuuXu%s%siuX.Yu%s-%siuguiupywupyF( u _get_shebangu_get_script_textuencodeunameusetuvariantsuaddusysuversionugetuFalseu _write_script( uselfuentryu filenamesuoptionsushebanguscriptunameu scriptnamesuext((u4/tmp/pip-zej_zi-build/pip/_vendor/distlib/scripts.pyu _make_scriptÈs  !' uScriptMaker._make_scriptcCsAd }tjj|jt|ƒƒ}tjj|jtjj|ƒƒ}|j r||j j ||ƒ r|t j d|ƒdSyt |dƒ}Wn'tk r¸|js®‚nd}Yn‘Xt|jƒ\}}|jdƒ|jƒ}|s t jd|jƒ|ƒdStj|jddƒƒ} | rId}| jdƒpCd} n|s¤|rb|jƒn|j j||ƒ|jr”|j j|gƒn|j|ƒn™t j d ||jƒ|j js*|j!|| ƒ} d |kríd } nd } tjj|ƒ} |j"| g| |j#ƒ|| ƒn|r=|jƒndS(Nunot copying %s (up-to-date)urbiu"%s: %s is an empty file (skipping)s s isucopying and adjusting %s -> %sspythonwupywupyFT($uFalseuosupathujoinu source_diru convert_pathu target_dirubasenameuforceu_fileopuneweruloggerudebuguopenuIOErrorudry_runuNoneudetect_encodingureadlineuseekuwarninguget_command_nameu FIRST_LINE_REumatchureplaceuTrueugroupucloseu copy_fileuset_modeuset_executable_modeuappenduinfou _get_shebangu _write_scripturead(uselfuscriptu filenamesuadjustuoutnameufuencodingulinesu first_lineumatchu post_interpushebanguextun((u4/tmp/pip-zej_zi-build/pip/_vendor/distlib/scripts.pyu _copy_scriptÙsR$              %uScriptMaker._copy_scriptcCs |jjS(N(u_fileopudry_run(uself((u4/tmp/pip-zej_zi-build/pip/_vendor/distlib/scripts.pyudry_run suScriptMaker.dry_runcCs||j_dS(N(u_fileopudry_run(uselfuvalue((u4/tmp/pip-zej_zi-build/pip/_vendor/distlib/scripts.pyudry_runsuntcCsftjdƒdkrd}nd}d||f}tjddƒd}t|ƒj|ƒj}|S( NuPiu64u32u%s%s.exeu.ii(ustructucalcsizeu__name__ursplitufinderufindubytes(uselfukindubitsunameudistlib_packageuresult((u4/tmp/pip-zej_zi-build/pip/_vendor/distlib/scripts.pyu _get_launchers uScriptMaker._get_launchercCsKg}t|ƒ}|dkr1|j||ƒn|j||d|ƒ|S(uÓ 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. uoptionsN(uget_export_entryuNoneu _copy_scriptu _make_script(uselfu specificationuoptionsu filenamesuentry((u4/tmp/pip-zej_zi-build/pip/_vendor/distlib/scripts.pyumake's   uScriptMaker.makecCs4g}x'|D]}|j|j||ƒƒq W|S(u 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, (uextendumake(uselfuspecificationsuoptionsu filenamesu specification((u4/tmp/pip-zej_zi-build/pip/_vendor/distlib/scripts.pyu make_multiple:s uScriptMaker.make_multipleNTF(u__name__u __module__u __qualname__u__doc__uSCRIPT_TEMPLATEuscript_templateuNoneu executableuTrueuFalseu__init__u_get_alternate_executableu _get_shebangu_get_script_textu_DEFAULT_MANIFESTumanifestu get_manifestu _write_scriptu _make_scriptu _copy_scriptupropertyudry_runusetteruosunameu _get_launcherumakeu make_multiple(u __locals__((u4/tmp/pip-zej_zi-build/pip/_vendor/distlib/scripts.pyu ScriptMakerBs& .   2 4u ScriptMaker(uiouBytesIOulogginguosureustructusysucompatu sysconfigufsencodeudetect_encodinguZipFileu resourcesufinderuutilu FileOperatoruget_export_entryu convert_pathuget_executableuin_venvu getLoggeru__name__uloggerustripu_DEFAULT_MANIFESTucompileu FIRST_LINE_REuSCRIPT_TEMPLATEuobjectu ScriptMaker(((u4/tmp/pip-zej_zi-build/pip/_vendor/distlib/scripts.pyus     "(