zmc
2023-08-08 e792e9a60d958b93aef96050644f369feb25d61b
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
U
H=®dCã@s°ddlmZddlZddlZddlZddlZddlZddlmZm    Z    m
Z
ddl m Z ddl mZmZmZmZmZe e¡Zd ¡Ze d¡Zd    Zd
d „ZeZGd d „d eƒZdS)é)ÚBytesIONé)Ú    sysconfigÚdetect_encodingÚZipFile)Úfinder)Ú FileOperatorÚget_export_entryÚ convert_pathÚget_executableÚin_venvañ
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
 <assemblyIdentity version="1.0.0.0"
 processorArchitecture="X86"
 name="%s"
 type="win32"/>
 
 <!-- Identify the application security requirements. -->
 <trustInfo xmlns="urn:schemas-microsoft-com:asm.v3">
 <security>
 <requestedPrivileges>
 <requestedExecutionLevel level="asInvoker" uiAccess="false"/>
 </requestedPrivileges>
 </security>
 </trustInfo>
</assembly>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())
cCsXd|krT| d¡rB| dd¡\}}d|krT| d¡sTd||f}n| d¡sTd|}|S)Nú z /usr/bin/env rú"z%s "%s"z"%s")Ú
startswithÚsplit)Ú
executableÚenvÚ _executable©rúRD:\z\workplace\VsCode\pyvenv\venv\Lib\site-packages\pip/_vendor/distlib/scripts.pyÚenquote_executable3s
 
rc@sÚeZdZdZeZdZd'dd„Zdd„Ze    j
  d    ¡rBd
d „Z d d „Z dd„Zd(dd„Zdd„ZeZdd„Zdd„Zd)dd„Zdd„Zedd„ƒZejdd„ƒZejd ksºejd    krÂejd krÂd!d"„Zd*d#d$„Zd+d%d&„ZdS),Ú 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)NFÚposixÚjava)ÚúX.YÚnt)Ú
source_dirÚ
target_dirÚ add_launchersÚforceÚclobberÚosÚnameÚ_nameÚset_modeÚsetÚvariantsrÚ_fileopÚ_is_ntÚsysÚ version_info)ÚselfrrrÚdry_runÚfileoprrrÚ__init__Nsÿ
 
ÿzScriptMaker.__init__cCs@| dd¡r<|jr<tj |¡\}}| dd¡}tj ||¡}|S)NÚguiFÚpythonÚpythonw)Úgetr)r"ÚpathrÚreplaceÚjoin)r,rÚoptionsÚdnÚfnrrrÚ_get_alternate_executable_s
 z%ScriptMaker._get_alternate_executablerc
Cs\z0t|ƒ}| d¡dkW5QR£WSQRXWn&ttfk
rVt d|¡YdSXdS)zl
            Determine if the specified executable is a script
            (contains a #! line)
            éz#!zFailed to open %sFN)ÚopenÚreadÚOSErrorÚIOErrorÚloggerÚwarning)r,rÚfprrrÚ    _is_shellgs 
& zScriptMaker._is_shellcCsD| |¡r*ddl}|jj d¡dkr<|Sn| ¡ d¡r<|Sd|S)Nrzos.nameÚLinuxz
jython.exez/usr/bin/env %s)rCrÚlangÚSystemÚ getPropertyÚlowerÚendswith)r,rrrrrÚ_fix_jython_executabless
z"ScriptMaker._fix_jython_executablecCs‚tjdkrd}n8t|ƒt|ƒd}tjdkr4d}nd}d|koF||k}|r^d||d    }n d
}|d ||d 7}|d 7}|S)a
        Build a shebang line. In the simple case (on Windows, or a shebang line
        which is not too long or contains spaces) use a simple formulation for
        the shebang. Otherwise, use /bin/sh as the executable, with a contrived
        shebang which allows the script to run either under Python or sh, using
        suitable quoting. Thanks to Harald Nordgren for his input.
 
        See also: http://www.in-ulm.de/~mascheck/various/shebang/#length
                  https://hg.mozilla.org/mozilla-central/file/tip/mach
        rTéÚdarwiniéó s#!ó
s
#!/bin/sh
s    '''exec' s  "$0" "$@"
s' ''')r"r#Úlenr*Úplatform)r,rÚ post_interpÚsimple_shebangÚshebang_lengthÚmax_shebang_lengthÚresultrrrÚ_build_shebangs
 
ÿzScriptMaker._build_shebangócCsTd}|jr|j}d}n^t ¡s&tƒ}nNtƒrLtj t d¡dt     d¡¡}n(tj t     d¡dt     d¡t     d¡f¡}|r„| 
||¡}t j   d    ¡rš| |¡}|r¦t|ƒ}| d
¡}t j d krÒd |krÒd |krÒ|d7}| ||¡}z| d
¡Wn"tk
rtd|ƒ‚YnX|d
krPz| |¡Wn&tk
rNtd||fƒ‚YnX|S)NTFÚscriptszpython%sÚEXEÚBINDIRz
python%s%sÚVERSIONrúutf-8Úcliz    -X:Framesz -X:FullFramess
 -X:Framesz,The shebang (%r) is not decodable from utf-8z?The shebang (%r) is not decodable from the script encoding (%r))rrÚis_python_buildr r r"r4r6Úget_pathÚget_config_varr:r*rQrrJrÚencoderWÚdecodeÚUnicodeDecodeErrorÚ
ValueError)r,ÚencodingrRr7ÚenquoterÚshebangrrrÚ _get_shebangžsX ÿ
ÿþ  
 
ÿ ÿ
 
ÿÿ
zScriptMaker._get_shebangcCs$|jt|j|j d¡d|jdS)NÚ.r)ÚmoduleÚ import_nameÚfunc)Úscript_templateÚdictÚprefixÚsuffixr)r,ÚentryrrrÚ_get_script_textÞs
þzScriptMaker._get_script_textcCstj |¡}|j|S©N)r"r4ÚbasenameÚmanifest)r,ÚexenameÚbaserrrÚ get_manifestås zScriptMaker.get_manifestc Csô|jo
|j}tj d¡}| |¡s*||7}|s8||}nZ|dkrL| d¡}n
| d¡}tƒ}    t|    dƒ}
|
     d|¡W5QRX|     
¡} ||| }|D]V} tj   |j | ¡} |rxtj  | ¡\}}| d¡rÐ|} d| } z|j | |¡WnŠtk
rtt d¡d    | }tj  |¡r&t |¡t | |¡|j | |¡t d
¡zt |¡Wntk
rnYnXYnXnl|jrœ|  d |¡sœd | |f} tj  | ¡rÀ|jsÀt d | ¡q–|j | |¡|jrä|j | g¡| | ¡q–dS)Nr]ÚpyÚtÚwz __main__.pyz.pyz%s.exez:Failed to write executable - trying to use .deleteme logicz %s.deletemez0Able to replace executable using .deleteme logicrjz%s.%szSkipping existing file %s)rr)r"ÚlineseprbrIÚ _get_launcherrrÚwritestrÚgetvaluer4r6rÚsplitextrr(Úwrite_binary_fileÚ    Exceptionr@rAÚexistsÚremoveÚrenameÚdebugr!r%Úset_executable_modeÚappend)r,ÚnamesrhÚ script_bytesÚ    filenamesÚextÚ use_launcherr}ÚlauncherÚstreamÚzfÚzip_datar#ÚoutnameÚnÚeÚdfnamerrrÚ _write_scriptésX  
 
 
 
 
 
 
 
  zScriptMaker._write_scriptc Csìd}|r0| dg¡}|r0dd |¡}| d¡}|jd||d}| |¡ d¡}|j}tƒ}    d|jkrp|     |¡d|jkr’|     d    ||j    d
f¡d |jkr¼|     d ||j    d
|j    d f¡|rÒ| dd¡rÒd}
nd}
|    ||||
¡dS)NrXÚinterpreter_argsz %sr r]©r7rÚXz%s%srrz%s-%s.%srr0FÚpywrz) r3r6rbrirsr#r&r'Úaddr+r—) r,rrrŒr7rRÚargsrhÚscriptr#Ú scriptnamesrrrrÚ _make_scripts, 
 
 
 
 
ÿzScriptMaker._make_scriptcCs˜d}tj |jt|ƒ¡}tj |jtj |¡¡}|jsT|j     ||¡sTt
  d|¡dSzt |dƒ}Wn t k
r‚|jsz‚d}YnLX| ¡}|s¦t
 d| ¡|¡dSt | dd¡¡}|rÎd}| d¡pÌd    }|s|rà| ¡|j ||¡|jr|j |g¡| |¡n„t
 d
||j¡|jjs†t|jƒ\}    }
| d ¡| |    |¡} d |kr^d } nd} tj |¡} | | g| |  ¡|| ¡|r”| ¡dS)NFznot copying %s (up-to-date)Úrbz"%s: %s is an empty file (skipping)s
rOTrrXzcopying and adjusting %s -> %srspythonwr›rz)!r"r4r6rr
rrur r(Únewerr@r‡r<r?r-ÚreadlinerAÚget_command_nameÚ FIRST_LINE_REÚmatchr5ÚgroupÚcloseÚ    copy_filer%rˆr‰ÚinforÚseekrir—r=)r,ržrŒÚadjustr“ÚfÚ
first_liner¦rRrfÚlinesrhrr”rrrÚ _copy_script5sX 
ÿ ÿ
 
 
 zScriptMaker._copy_scriptcCs|jjSrt©r(r-)r,rrrr-iszScriptMaker.dry_runcCs ||j_dSrtr±)r,Úvaluerrrr-msrcCs`t d¡dkrd}nd}d||f}t dd¡d}t|ƒ |¡}|sZd    ||f}t|ƒ‚|jS)
NÚPéÚ64Ú32z%s%s.exerjrrz(Unable to find resource %s in package %s)ÚstructÚcalcsizeÚ__name__ÚrsplitrÚfindreÚbytes)r,ÚkindÚbitsr#Údistlib_packageÚresourceÚmsgrrrr~us ÿzScriptMaker._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    r°r )r,Ú specificationr7rŒrrrrrÚmake‡s 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Ã)r,Úspecificationsr7rŒrÂrrrÚ make_multiplešszScriptMaker.make_multiple)TFN)rXN)N)N)N) r¹Ú
__module__Ú __qualname__Ú__doc__ÚSCRIPT_TEMPLATErnrr/r:r*rQrrCrJrWrirsÚ_DEFAULT_MANIFESTrvryr—r r°Úpropertyr-Úsetterr"r#r$r~rÃrÆrrrrrEs6ÿ
 
@4
4
 
 
r)ÚiorÚloggingr"Úrer·r*ÚcompatrrrÚ    resourcesrÚutilrr    r
r r Ú    getLoggerr¹r@ÚstriprËÚcompiler¥rÊrÚ_enquote_executableÚobjectrrrrrÚ<module>s