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
U
W±d»Cã@sždZddlZddlZddlZddlZddlZddlZddlmZm    Z    ddl
m Z m Z m Z ddlmZmZmZmZGdd„dƒZGdd    „d    ƒZGd
d „d ƒZdS) zl
Utilities to create data structures for embedding Python modules and additional files into the executable.
éN)Úget_code_objectÚstrip_paths_in_code)ÚBYTECODE_MAGICÚis_winÚstrict_collect_mode)Ú PYZ_ITEM_DATAÚPYZ_ITEM_MODULEÚPYZ_ITEM_NSPKGÚ PYZ_ITEM_PKGc@s2eZdZdZdZdZdZd
dd„Zedd    „ƒZ    dS) ÚZlibArchiveWriterzª
    Writer for PyInstaller's PYZ (ZlibArchive) archive. The archive is used to store collected byte-compiled Python
    modules, as individually-compressed entries.
    sPYZééNc     CsÂ|pi}t|dƒ¦}| d|j¡g}|D]}| ||||¡}| |¡q,| ¡}    t |¡}
| |
¡| dt    j
¡| |j ¡| t ¡| t  d|    ¡¡| t  d|dk    ¡¡W5QRXdS)a
        filename
            Target filename of the archive.
        entries
            An iterable containing entries in the form of tuples: (name, src_path, typecode), where `name` is the name
            under which the resource is stored (e.g., python module name, without suffix), `src_path` is name of the
            file from which the resource is read, and `typecode` is the Analysis-level TOC typecode (`PYMODULE` or
            `DATA`).
        code_dict
            Optional code dictionary containing code objects for analyzed/collected python modules.
        cipher
            Optional `Cipher` object for bytecode encryption.
        Úwbórz!iz!BN)ÚopenÚwriteÚ_HEADER_LENGTHÚ _write_entryÚappendÚtellÚmarshalÚdumpsÚseekÚosÚSEEK_SETÚ_PYZ_MAGIC_PATTERNrÚstructÚpack) ÚselfÚfilenameÚentriesÚ    code_dictÚcipherÚfpÚtocÚentryÚ    toc_entryÚ
toc_offsetÚtoc_data©r)úRd:\z\workplace\vscode\pyvenv\venv\Lib\site-packages\PyInstaller/archive/writers.pyÚ__init__$s  
 
 
zZlibArchiveWriter.__init__c    Csº|\}}}|dkrXt}|dkr$t}n$tj tj |¡¡\}}    |dkrHt}t ||¡}
n"t    }t
|dƒ} |   ¡}
W5QRXt   |
|j¡} |r–| | ¡} ||| ¡t| ƒff} | | ¡| S)NZPYMODULE)ú-Nr+Úrb)rr    rÚpathÚsplitextÚbasenamer
rrrrÚreadÚzlibÚcompressÚ_COMPRESSION_LEVELZencryptrÚlenr)Úclsr#r%r!r"ÚnameZsrc_pathÚtypecodeZ src_basenameÚ_ÚdataÚfhÚobjr&r)r)r*rPs$
 
 
zZlibArchiveWriter._write_entry)NN)
Ú__name__Ú
__module__Ú __qualname__Ú__doc__rrr4r+Ú classmethodrr)r)r)r*r s
,r c@sjeZdZdZdZdZe e¡ZdZ    e e    ¡Z
dZ dd„Z dd    „Z ded œd d „Zddd„Zedd„ƒZdS)ÚCArchiveWriterah
    Writer for PyInstaller's CArchive (PKG) archive.
 
    This archive contains all files that are bundled within an executable; a PYZ (ZlibArchive), DLLs, Python C
    extensions, and other data files that are bundled in onefile mode.
 
    The archive can be read from either C (bootloader code at application's run-time) or Python (for debug purposes).
    sMEI
z
!8sIIii64sz!iIIIBBé    c Csºtƒ|_t|dƒž}g}|D]}| ||¡}| |¡q| ¡}| |¡}    t|    ƒ}
| |    ¡||
|j    } t
j ddt
j d} t   |j|j| ||
| | d¡¡} | | ¡W5QRXdS)aH
        filename
            Target filename of the archive.
        entries
            An iterable containing entries in the form of tuples: (dest_name, src_name, compress, typecode), where
            `dest_name` is the name under which the resource is stored in the archive (and name under which it is
            extracted at runtime), `src_name` is name of the file from which the resouce is read, `compress` is a
            boolean compression flag, and `typecode` is the Analysis-level TOC typecode.
        pylib_name
            Name of the python shared library.
        rrédéÚasciiN)ÚsetÚ_collected_namesrrrrÚ_serialize_tocr5rÚ_COOKIE_LENGTHÚsysÚ version_inforrÚ_COOKIE_FORMATÚ_COOKIE_MAGIC_PATTERNÚencode)rrr Z
pylib_namer#r$r%r&r'r(Z
toc_lengthZarchive_lengthZpyversZ cookie_datar)r)r*r+‰s,    
 
ù
zCArchiveWriter.__init__c     Cs~|\}}}}tj |¡}tr8tjjdkr8| tjjd¡}tr†d}tdkrJn tj |¡}|r†||j    krzt
d|›d|›dƒ‚|j      |¡|dkrž|  |d||¡S|d    krÀ|  |d|›d
|›|¡S|d krôt ||ƒ}t|ƒ}|j |t |¡|||d S|d krft|dƒ}    |     ¡}
W5QRX|
dd…tks2t‚t |
dd…¡}t|ƒ}|j |t |¡|||d S|j|||||d SdS)Nú/ú\)ÚoÚsÚmÚMz7Attempting to collect a duplicated file into CArchive: z (type: ú)rRóÚdú:rS)r3)rTrUr-éé)rr.ÚnormpathrÚsepÚreplacerÚtypeÚnormcaserHÚ
ValueErrorÚaddÚ _write_blobrrrrrr1rÚAssertionErrorÚloadsÚ _write_file) rr#r%Ú    dest_nameÚsrc_namer3r8Znormalized_destÚcodeÚin_fpr:r)r)r*r´s>   
ÿ 
 
 zCArchiveWriter._write_entryF)ÚblobcCsF| ¡}t|ƒ}|r$tj||jd}| |¡|t|ƒ|t|ƒ||fS)zŽ
        Write the binary contents (**blob**) of a small file to the archive and return the corresponding CArchive TOC
        entry.
        )Úlevel)rr5r2r3r4rÚint)rÚout_fprkrgr8r3Ú data_offsetÚ data_lengthr)r)r*rcës 
zCArchiveWriter._write_blobc     Cs¤| ¡}t |¡j}t|dƒd}|rrtdƒ}    t |j¡}
|     |    ¡} | sHqb| 
|
  |    d| …¡¡q8| 
|
  ¡¡n t  ||¡W5QRX|| ¡||t|ƒ||fS)zl
        Stream copy a large file into the archive and return the corresponding CArchive TOC entry.
        r-i@N)rrÚstatÚst_sizerÚ    bytearrayr2Ú compressobjr4Úreadintorr3ÚflushÚshutilÚ copyfileobjrm) rrnrhrgr8r3rorprjZ
tmp_bufferZ
compressorZnum_readr)r)r*rføs   
zCArchiveWriter._write_filec Cs g}|D]Œ}|\}}}}}}    |     d¡}    t|    ƒd}
|j|
} | ddkr\d| d} |
| 7}
t |j|
›d|j|
||||t|ƒ|    ¡} | | ¡qd |¡S)Núutf-8rEr[rrSrW)    rOr5Ú_TOC_ENTRY_LENGTHrrÚ_TOC_ENTRY_FORMATÚordrÚjoin)r6r$Zserialized_tocr&roZcompressed_lengthrpr3r8r7Z name_lengthZ entry_lengthZpadding_lengthZserialized_entryr)r)r*rI s*
 
  ø
zCArchiveWriter._serialize_tocN)F)F)r=r>r?r@rNrMrÚcalcsizerJr{rzr4r+rÚbytesrcrfrArIr)r)r)r*rBus
 
+7
rBc@s&eZdZdZdZe e¡Zdd„ZdS)Ú SplashWriterzž
    Writer for the splash screen resources archive.
 
    The resulting archive is added as an entry into the CArchive with the typecode PKG_ITEM_SPLASH.
    z!16s 16s 16s 16s ii ii iic    Cs.t|dƒ}    |     d|j¡d}
|     ¡} |D](} |  d¡d} |     | ¡|
t| ƒ7}
q.|     ¡} t|ƒ}|     | d¡¡|     ¡}t|tƒržt|ƒ}|     |¡n2t|dƒ}| ¡}W5QRXt|ƒ}|     |¡~t     
|j | d¡| d¡| d¡| d¡|| |||
| ¡ }|      dt j¡|     |¡W5QRXdS)a
        Writer for splash screen resources that are bundled into the CArchive as a single archive/entry.
 
        :param filename: The filename of the archive to create
        :param name_list: List of filenames for the requirements array
        :param str tcl_libname: Name of the tcl shared library file
        :param str tk_libname: Name of the tk shared library file
        :param str tklib: Root of tk library (e.g. tk/)
        :param str rundir: Unique path to extract requirements to
        :param Union[str, bytes] image: Image like object
        :param str script: The tcl/tk script to execute to create the screen.
        rrrryr-N)rrrrrOr5Ú
isinstancerr1rrÚ_HEADER_FORMATrrr)rrÚ    name_listZ tcl_libnameZ
tk_libnameZtklibZrundirÚimageÚscriptr#Zrequirements_lenZrequirements_offsetr7Z script_offsetZ
script_lenZ image_offsetZ    image_lenZimage_fpZ
image_dataZ header_datar)r)r*r+RsF
 
 
õzSplashWriter.__init__N)    r=r>r?r@r‚rr~rr+r)r)r)r*r€0s
r€)r@rrrwrrKr2ZPyInstaller.building.utilsrrZPyInstaller.compatrrrZ#PyInstaller.loader.pyimod01_archiverrr    r
r rBr€r)r)r)r*Ú<module> sZ<