zmc
2023-12-22 9fdbf60165db0400c2e8e6be2dc6e88138ac719a
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
U
W±dÐ4ã@s¢ddlZddlZddlZddlmZddlmZddlm    Z    e 
e ¡Z dd„Z Gdd„deƒZGd    d
„d
ƒZGd d „d eeƒZd d„Zdd„Zdd„fdd„ZdS)éN)Úlog)Ú_check_guts_eq)ÚmisccCs"|\}}}|dkrtj |¡}|S)z°
    Return the filename used to enforce uniqueness for the given TOC entry.
 
    Parameters
    ----------
    entry : tuple
 
    Returns
    -------
    unique_name: str
    )ÚBINARYÚDATAÚ    EXTENSIONÚ
DEPENDENCY)ÚosÚpathÚnormcase)ÚentryÚnamer
Útypecode©rúVd:\z\workplace\vscode\pyvenv\venv\Lib\site-packages\PyInstaller/building/datastruct.pyÚ unique_names
 rcsveZdZdZd‡fdd„    Z‡fdd„Z‡fdd„Zd    d
„Zd d „Zd d„Z    dd„Z
dd„Z dd„Z ‡fdd„Z ‡ZS)ÚTOCaÑ
    TOC (Table of Contents) class is a list of tuples of the form (name, path, typecode).
 
    typecode    name                   path                        description
    --------------------------------------------------------------------------------------
    EXTENSION   Python internal name.  Full path name in build.    Extension module.
    PYSOURCE    Python internal name.  Full path name in build.    Script.
    PYMODULE    Python internal name.  Full path name in build.    Pure Python module (including __init__ modules).
    PYZ         Runtime name.          Full path name in build.    A .pyz archive (ZlibArchive data structure).
    PKG         Runtime name.          Full path name in build.    A .pkg archive (Carchive data structure).
    BINARY      Runtime name.          Full path name in build.    Shared library.
    DATA        Runtime name.          Full path name in build.    Arbitrary files.
    OPTION      The option.            Unused.                     Python runtime option (frozen into executable).
 
    A TOC contains various types of files. A TOC contains no duplicates and preserves order.
    PyInstaller uses TOC data type to collect necessary files bundle them into an executable.
    Ncs>tƒ ¡tjdtddtƒ|_|r:|D]}| |¡q*dS)NzFTOC class is deprecated. Use a plain list of 3-element tuples instead.é)Ú
stacklevel)ÚsuperÚ__init__ÚwarningsÚwarnÚDeprecationWarningÚsetÚ    filenamesÚappend)ÚselfÚinitlistr ©Ú    __class__rrr>s
ýz TOC.__init__csVt|tƒs(t d|¡tdt|ƒjƒ‚t|ƒ}||jkrR|j     |¡t
ƒ  |¡dS©NzTOC found a %s, not a tuplezExpected tuple, not %s.) Ú
isinstanceÚtupleÚloggerÚinfoÚ    TypeErrorÚtypeÚ__name__rrÚaddrr)rr ÚuniquerrrrMs
 
 z
TOC.appendcsXt|tƒs(t d|¡tdt|ƒjƒ‚t|ƒ}||jkrT|j     |¡t
ƒ  ||¡dSr!) r"r#r$r%r&r'r(rrr)rÚinsert)rÚposr r*rrrr+Xs
 
 z
TOC.insertcCst|ƒ}| |¡|S©N©rÚextend©rÚotherÚresultrrrÚ__add__bs
z TOC.__add__cCst|ƒ}| |¡|Sr-r.r0rrrÚ__radd__gs
z TOC.__radd__cCs|D]}| |¡q|Sr-©r©rr1r rrrÚ__iadd__ls z TOC.__iadd__cCs|D]}| |¡qdSr-r5r6rrrr/qsz
TOC.extendcstˆƒ‰t‡fdd„|DƒƒS)Ncsg|]}t|ƒˆjkr|‘qSr)rr)Ú.0r ©r1rrÚ
<listcomp>yszTOC.__sub__.<locals>.<listcomp>)r)rr1rr9rÚ__sub__vsz TOC.__sub__cCst|ƒ}| |¡Sr-)rr;r0rrrÚ__rsub__{sz TOC.__rsub__cs’t|tƒrB|tdddƒkr8tƒ|_| ¡| |¡dStdƒ‚nL||}t|ƒ}|j |¡t|ƒ}||jkrŽ|j     |¡t
t |ƒ  ||¡dS)Nz%TOC.__setitem__ doesn't handle slices) r"ÚslicerrÚclearr/ÚKeyErrorrÚremover)rrÚ __setitem__)rÚkeyÚvalueÚ    old_valueZold_nameÚnew_namerrrrAs
 
 
 
 zTOC.__setitem__)N)r(Ú
__module__Ú __qualname__Ú__doc__rrr+r3r4r7r/r;r<rAÚ __classcell__rrrrr,s
rc@s4eZdZdZdd„Zdd„ZgZdd„Zdd    „Zd
S) ÚTargetrcCsbddlm}|jj|_|jjd7_tj |dd|jj|jf¡|_tj     |j¡|_
g|_ dS)Nr)ÚCONFéZworkpathz %s-%02d.toc) ZPyInstaller.configrKr Úinvcnumr    r
Újoinr(Ú tocfilenameÚbasenameÚ tocbasenameZ dependencies)rrKrrrr˜s  
"zTarget.__init__cCs°t d|jj¡d}t |j¡}|dkr>t d|jj|j¡nNzt |j¡}Wn"t    k
rpt d|j¡YnXt
t dd„|j Dƒ|ƒƒ}|rœ|  ||¡r¬| ¡| ¡dS)a7
        Check if the target need to be rebuild and if so, re-assemble.
 
        `__postinit__` is to be called at the end of `__init__` of every subclass of Target. `__init__` is meant to
        setup the parameters and `__postinit__` is checking if rebuild is required and in case calls `assemble()`
        z checking %sNrz&Building %s because %s is non existentúBuilding because %s is badcss|]}|dVqdS©rNr©r8ÚgrrrÚ    <genexpr>µsz&Target.__postinit__.<locals>.<genexpr>)r$r%r r(rÚmtimerOrQZload_py_data_structÚ    ExceptionÚdictÚzipÚ_GUTSÚ _check_gutsÚassembleÚ
_save_guts)rÚdataÚ
last_buildrrrÚ __postinit__¢s zTarget.__postinit__cCs`t|ƒt|jƒkr$t d|j¡dS|jD]0\}}|dkr<q*||||t||ƒ|ƒr*dSq*dS)z?
        Returns True if rebuild/assemble is required.
        rRTNF)Úlenr[r$r%rQÚgetattr)rr_r`ÚattrÚfuncrrrr\½szTarget._check_gutscs*t‡fdd„ˆjDƒƒ}t ˆj|¡dS)zr
        Save the input parameters and the work-product of this run to maybe avoid regenerating it later.
        c3s|]}tˆ|dƒVqdSrS)rcrT©rrrrVÐsz$Target._save_guts.<locals>.<genexpr>N)r#r[rZsave_py_data_structrO)rr_rrfrr^ÌszTarget._save_gutsN)    r(rFrGrMrrar[r\r^rrrrrJ•s 
rJcsXeZdZdZddd„Zdefdefdefd    efd
fZd d „Z‡fd d„Zdd„Z    ‡Z
S)ÚTreezˆ
    This class is a way of creating a TOC (Table of Contents) list that describes some or all of the files within a
    directory.
    NrcCsFt |¡t |¡||_||_||_||_|dkr:g|_| ¡dS)az
        root
                The root of the tree (on the build system).
        prefix
                Optional prefix to the names of the target system.
        excludes
                A list of names to exclude. Two forms are allowed:
 
                    name
                        Files with this basename will be excluded (do not include the path).
                    *.ext
                        Any file with the given extension will be excluded.
        typecode
                The typecode to be used for all files found in this tree. See the TOC class for for information about
                the typcodes.
        N)rJrÚlistÚrootÚprefixÚexcludesrra)rrirjrkrrrrrÙs
 
z Tree.__init__rirjrkr)r_NcCs”t |||¡rdS|dg}|r€| ¡}t |¡|krJt d|j|¡dSt     |¡D](}tj
  ||¡}tj
  |¡rT|  |¡qTq|d|dd…<dS)NTriz(Building %s because directory %s changedr_F)rJr\ÚpoprrWr$r%rQr    Úlistdirr
rNÚisdirr)rr_r`ÚstackÚdÚnmr
rrrr\ýs
 zTree._check_gutscs||_tƒ ¡|`dSr-)r_rr^rfrrrr^s
zTree._save_gutsc Cs
t d|j¡|j|jfg}tƒ}tƒ}|jD],}| d¡rP| |dd…¡q.| |¡q.g}|rú|     ¡\}}t
  |¡D]|}||krˆqzt
j   |¡d}    |    |kr¢qzt
j  ||¡}
|rÄt
j  ||¡} n|} t
j  |
¡rä| |
| f¡qz| | |
|jf¡qzq`||dd…<dS)NzBuilding Tree %sÚ*rL)r$r%rQrirjrrkÚ
startswithr)rlr    rmr
ÚsplitextrNrnrr) rrorkZ    xexcludesr r2ÚdirrjÚfilenameÚextZ fullfilenameZ resfilenamerrrr]s2
 
   z Tree.assemble)NNNr) r(rFrGrHrrr[r\r^r]rIrrrrrgÔs
û     rgcCs ddddœ}dd„}t|||ƒS)NrrL)rrrcSs|dkS)N>ÚOPTIONr©rrrrÚ_type_case_normalization_fcn?sz3normalize_toc.<locals>._type_case_normalization_fcn©Ú_normalize_toc)ÚtocÚ_TOC_TYPE_PRIORITIESrzrrrÚ normalize_toc5s ûrcCsddi}t||ƒS)NZPYMODULErLr{)r}r~rrrÚnormalize_pyz_tocHsþr€cCsdS)NFrryrrrÚ<lambda>Rórc Cs˜tƒ}|D]€\}}}tj |¡}||ƒr4t |¡}n|}| |¡}|dkrZ|||f||<q
|\}    }    }
| |d¡| |
d¡kr
|||f||<q
t| ¡ƒS)Nr)    rYr    r
ÚnormpathÚpathlibÚPurePathÚgetrhÚvalues) r}Ztoc_type_prioritiesZtype_case_normalization_fcnZtmp_tocZ    dest_nameÚsrc_namerZ    entry_keyZexisting_entryÚ_Zexisting_typecoderrrr|Rs  
 
r|)r    r„rZ PyInstallerrÚloggingZPyInstaller.building.utilsrZPyInstaller.utilsrÚ    getLoggerr(r$rrhrrJrgrr€r|rrrrÚ<module> s   
i?a