U cf\I@sddlmZddlZddlZddlZddlZddlZddlZddlm Z ddl m Z m Z m Z ddlmZddlmZmZmZmZmZmZeeZdZed Zd Zed ddZ d d ee !dDZ"ddZ#e#Z$Gddde%Z&dS))BytesION)ZipInfo) sysconfigdetect_encodingZipFile)finder) FileOperatorget_export_entry convert_pathget_executable get_platformin_venva s^#!.*pythonw?[0-9.]*([ ].*)?$z# -*- coding: utf-8 -*- import re import sys from %(module)s import %(import_name)s if __name__ == '__main__': sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0]) sys.exit(%(func)s()) .cCs"i|]}|jdr|j|jqS)z.exe)nameendswithbytes).0rrI/opt/hc_python/lib/python3.8/site-packages/pip/_vendor/distlib/scripts.py @s rcCsXd|krT|drB|dd\}}d|krT|dsTd||f}n|dsTd|}|S)N z /usr/bin/env r"z%s "%s"z"%s") startswithsplit) executableenv _executablerrrenquote_executableGs  r c@seZdZdZeZdZd*ddZddZe j d rBd d Z d d Z ddZd+ddZddZeZddZddZdZddZd,ddZddZed d!Zejd"d!Zejd#ksejd krejd#krd$d%Zd-d&d'Z d.d(d)Z!dS)/ ScriptMakerz_ A class to copy or create scripts from source scripts or callable specifications. NTFcCs||_||_||_d|_d|_tjdkp:tjdko:tjdk|_t d|_ |pRt ||_ tjdkprtjdkortjdk|_ tj|_dS)NFposixjava)rX.Ynt) source_dir target_dir add_launchersforceclobberosr_nameset_modesetvariantsr _fileop_is_ntsys version_info)selfr&r'r(dry_runfileoprrr__init__ds zScriptMaker.__init__cCs@|ddr<|jrget_pathget_config_varrrBr2rXrrQr encoder^decodeUnicodeDecodeError ValueError)r4encodingrYr?enquotershebangrrr _get_shebangs`            zScriptMaker._get_shebangcCs$|jt|j|jdd|jdS)Nrr)module import_namefunc)script_templatedictprefixsuffixr)r4entryrrr_get_script_texts zScriptMaker._get_script_textcCstj|}|j|SN)r+r<basenamemanifest)r4exenamebaserrr get_manifest s zScriptMaker.get_manifestc Cs6|jo |j}tjd}||s*||7}|s8||}n|dkrL|d}n |d}t} t| dR} tj d} | rt t | dd} td| d} | | |n | d|W5QRX| }|||}|D]X}tj|j|}|rtj|\}}|d r|}d |}z|j||Wntk rtd d |}tj|rht|t|||j||td zt|Wntk rYnXYnXnl|jr|d|sd||f}tj|r|jstd|q|j|||j r&|j!|g|"|qdS)NrdpytwSOURCE_DATE_EPOCHz __main__.py)filename date_timez.pyz%s.exez:Failed to write executable - trying to use .deleteme logicz %s.deletemez0Able to replace executable using .deleteme logicrz%s.%szSkipping existing file %s)#r(r1r+lineseprir _get_launcherrrenvironr;timegmtimeintrwritestrgetvaluer<r>r'splitextrr0write_binary_file ExceptionrHrIexistsremoverenamedebugr*r-set_executable_modeappend)r4namesro script_bytes filenamesext use_launcherrlauncherstreamzfsource_date_epochrzinfozip_dataroutnamenedfnamerrr _write_script sj                  zScriptMaker._write_script-cCsnt}d|jkr||d|jkr<|d||jdfd|jkrj|d||j|jd|jdf|S)NrXz%s%srr$z %s%s%s.%sr)r.r/addr3variant_separator)r4rr]rrrget_script_filenamesKs    z ScriptMaker.get_script_filenamesc Csd}|r0|dg}|r0dd|}|d}|jd||d}||d}||j}|rr|ddrrd } nd } |||||| dS) Nr_interpreter_argsz %srrdr?r8Fpywr)r;r>rirpryrrr) r4rxrr?rYargsroscript scriptnamesrrrr _make_scriptWs   zScriptMaker._make_scriptcCsd}tj|jt|}tj|jtj|}|jsT|j ||sTt d|dSzt |d}Wn t k r|jszd}YnFX|}|st d|dSt|dd}|rd}|dpd }|s|r||j|||jr|j|g||nt d ||j|jjs~t|j\} } |d || |} d |krVd } nd} tj|} || g| ||| |r|dS)NFznot copying %s (up-to-date)rbz%s is an empty file (skipping)s rVTrr_zcopying and adjusting %s -> %srspythonwrr) r+r<r>r&r r'r{r)r0newerrHrrDrGr5readlinerI FIRST_LINE_REmatchr=groupclose copy_filer-rrinforseekrprrE)r4rradjustrf first_linerrYrmlinesrorrrrr _copy_scriptgsR         zScriptMaker._copy_scriptcCs|jjSrzr0r5)r4rrrr5szScriptMaker.dry_runcCs ||j_dSrzr)r4valuerrrr5sr%cCs\tddkrd}nd}tdkr&dnd}d|||f}|tkrTd |tf}t|t|S) NPZ64Z32z win-arm64z-armrz %s%s%s.exez(Unable to find resource %s in package %s)structcalcsizer WRAPPERSdistlib_packagerl)r4kindbitsZplatform_suffixrmsgrrrrszScriptMaker._get_launchercCs6g}t|}|dkr"|||n|j|||d|S)a 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. Nr)r rr)r4 specificationr?rrxrrrmakes zScriptMaker.makecCs$g}|D]}||||q|S)z 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, )extendr)r4specificationsr?rrrrr make_multipleszScriptMaker.make_multiple)TFN)r_N)N)N)N)"__name__ __module__ __qualname____doc__SCRIPT_TEMPLATErtrr7rBr2rXrrKrQr^rpry_DEFAULT_MANIFESTr|rrrrrrpropertyr5setterr+rr,rrrrrrrr![s>     H< 3   r!)'iorloggingr+rerr2rzipfilercompatrrr resourcesrutilr r r r r r getLoggerrrHstriprcompilerrrsplitriteratorrr _enquote_executableobjectr!rrrrs*