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
U
G=®d=3ã@sldZddlZddlZddlmZddlmZddlmZddl    m
Z
ddd    œZ Gd
d „d eƒZ dd d „Z dS)aêdistutils.command.config
 
Implements the Distutils 'config' command, a (mostly) empty command class
that exists mainly to be sub-classed by specific module distributions and
applications.  The idea is that while every "config" command is different,
at least they're all named the same, and users always see "config" in the
list of standard commands.  Also, this is a good place to put common
configure-like tasks: "try to compile this C code", or "figure out where
this header file lives".
éN)ÚCommand)ÚDistutilsExecError)Úcustomize_compiler)Úlogz.cz.cxx)Úczc++c    @sÆeZdZdZdddddddd    d
g    Zd d „Zd d„Zdd„Zdd„Zdd„Z    dd„Z
dd„Z dd„Z dd„Z d0dd „Zd1d!d"„Zd2d#d$„Zd3d%d&„Zd4d'd(„Zd5d*d+„Zdddgfd,d-„Zd6d.d/„ZdS)7Úconfigzprepare to build)z    compiler=Nzspecify the compiler type)zcc=Nzspecify the compiler executable)z include-dirs=ÚIz.list of directories to search for header files)zdefine=ÚDzC preprocessor macros to define)zundef=ÚUz!C preprocessor macros to undefine)z
libraries=Úlz!external C libraries to link with)z library-dirs=ÚLz.directories to search for external C libraries)ÚnoisyNz1show every action (compile, link, run, ...) taken)z dump-sourceNz=dump generated source files before attempting to compile themcCs4d|_d|_d|_d|_d|_d|_d|_g|_dS)Né)ÚcompilerÚccÚ include_dirsÚ    librariesÚ library_dirsr Ú dump_sourceÚ
temp_files©Úself©rú[D:\z\workplace\VsCode\pyvenv\venv\Lib\site-packages\setuptools/_distutils/command/config.pyÚinitialize_options3szconfig.initialize_optionscCs|jdkr|jjpg|_nt|jtƒr6|j tj¡|_|jdkrHg|_nt|jtƒr^|jg|_|jdkrpg|_nt|jtƒrŒ|j tj¡|_dS©N)    rÚ distributionÚ
isinstanceÚstrÚsplitÚosÚpathseprrrrrrÚfinalize_optionsBs
 
 
 
 zconfig.finalize_optionscCsdSrrrrrrÚrunRsz
config.runcCszddlm}m}t|j|ƒsv||j|jdd|_t|jƒ|jrN|j |j¡|j    rb|j 
|j    ¡|j rv|j  |j ¡dS)z^Check that 'self.compiler' really is a CCompiler object;
        if not, make it one.
        r)Ú    CCompilerÚ new_compilerr)rÚdry_runÚforceN) Údistutils.ccompilerr$r%rrr&rrZset_include_dirsrZ set_librariesrZset_library_dirs)rr$r%rrrÚ_check_compilerYs ÿ
zconfig._check_compilerc    Csldt|}t|dƒL}|r>|D]}| d|¡q | d¡| |¡|ddkr^| d¡W5QRX|S)NZ _configtestÚwz#include <%s>
Ú
éÿÿÿÿ)ÚLANG_EXTÚopenÚwrite)rÚbodyÚheadersÚlangÚfilenameÚfileÚheaderrrrÚ_gen_temp_sourcefileks  
 
 zconfig._gen_temp_sourcefilecCs<| |||¡}d}|j ||g¡|jj|||d||fS)Nz _configtest.i©r)r6rÚextendrÚ
preprocess)rr0r1rr2ÚsrcÚoutrrrÚ _preprocessws
zconfig._preprocesscCs\| |||¡}|jr"t|d|ƒ|j |g¡\}|j ||g¡|jj|g|d||fS)Nzcompiling '%s':r7)r6rÚ    dump_filerZobject_filenamesrr8Úcompile)rr0r1rr2r:ÚobjrrrÚ_compile~szconfig._compilec
Csr| ||||¡\}}tj tj |¡¡d}    |jj|g|    |||d|jjdk    r\|    |jj}    |j     |    ¡|||    fS)Nr)rrZ target_lang)
r@r ÚpathÚsplitextÚbasenamerZlink_executableZ exe_extensionrÚappend)
rr0r1rrrr2r:r?ÚprogrrrÚ_link‡s ý   z config._linkc    GsT|s|j}g|_t dd |¡¡|D](}zt |¡Wq&tk
rLYq&Xq&dS)Nz removing: %sú )rrÚinfoÚjoinr ÚremoveÚOSError)rÚ    filenamesr3rrrÚ_clean–sz config._cleanNrcCsRddlm}| ¡d}z| ||||¡Wn|k
rDd}YnX| ¡|S)aQConstruct a source file from 'body' (a string containing lines
        of C/C++ code) and 'headers' (a list of header files to include)
        and run it through the preprocessor.  Return true if the
        preprocessor succeeded, false if there were any errors.
        ('body' probably isn't of much use, but what the heck.)
        r©Ú CompileErrorTF)r(rOr)r<rM©rr0r1rr2rOÚokrrrÚtry_cpp¬s 
zconfig.try_cppc     Csx| ¡| ||||¡\}}t|tƒr0t |¡}t|ƒ.}d}    | ¡}
|
dkrPqb| |
¡r>d}    qbq>W5QRX|     ¡|    S)a´Construct a source file (just like 'try_cpp()'), run it through
        the preprocessor, and return true if any line of the output matches
        'pattern'.  'pattern' should either be a compiled regex object or a
        string containing a regex.  If both 'body' and 'headers' are None,
        preprocesses an empty file -- which can be useful to determine the
        symbols the preprocessor and compiler set by default.
        FÚT)
r)r<rrÚrer>r.ÚreadlineÚsearchrM) rÚpatternr0r1rr2r:r;r4ÚmatchÚlinerrrÚ
search_cpp¾s    
 
 
 
zconfig.search_cppcCsdddlm}| ¡z| ||||¡d}Wn|k
rDd}YnXt |rRdpTd¡| ¡|S)zwTry to compile a source file built from 'body' and 'headers'.
        Return true on success, false otherwise.
        rrNTFúsuccess!úfailure.)r(rOr)r@rrHrMrPrrrÚ try_compileÚs 
zconfig.try_compilec
    Cspddlm}m}| ¡z| ||||||¡d}    Wn||fk
rPd}    YnXt |    r^dp`d¡| ¡|    S)zžTry to compile and link a source file, built from 'body' and
        'headers', to executable form.  Return true on success, false
        otherwise.
        r©rOÚ    LinkErrorTFr[r\)r(rOr_r)rFrrHrM)
rr0r1rrrr2rOr_rQrrrÚtry_linkês
ÿ
zconfig.try_linkc
Cs„ddlm}m}| ¡z.| ||||||¡\}    }
} | | g¡d} Wn||tfk
rdd} YnXt | rrdptd¡|     ¡| S)zœTry to compile, link to an executable, and run a program
        built from 'body' and 'headers'.  Return true on success, false
        otherwise.
        rr^TFr[r\)
r(rOr_r)rFÚspawnrrrHrM) rr0r1rrrr2rOr_r:r?ZexerQrrrÚtry_runýs
ÿ
 
zconfig.try_runrc    Cst| ¡g}|r| d|¡| d¡|r<| d|¡n| d|¡| d¡d |¡d}| |||||¡S)aÛDetermine if function 'func' is available by constructing a
        source file that refers to 'func', and compiles and links it.
        If everything succeeds, returns true; otherwise returns false.
 
        The constructed source file starts out by including the header
        files listed in 'headers'.  If 'decl' is true, it then declares
        'func' (as "int func()"); you probably shouldn't supply 'headers'
        and set 'decl' true in the same call, or you might get errors about
        a conflicting declarations for 'func'.  Finally, the constructed
        'main()' function either references 'func' or (if 'call' is true)
        calls it.  'libraries' and 'library_dirs' are used when
        linking.
        z
int %s ();z int main () {z  %s();z  %s;Ú}r+)r)rDrIr`)    rÚfuncr1rrrÚdeclÚcallr0rrrÚ
check_funcs
 
 
ÿzconfig.check_funccCs | ¡| d|||g||¡S)aáDetermine if 'library' is available to be linked against,
        without actually checking that any particular symbols are provided
        by it.  'headers' will be used in constructing the source file to
        be compiled, but the only effect of this is to check if all the
        header files listed are available.  Any libraries listed in
        'other_libraries' will be included in the link, in case 'library'
        has symbols that depend on other libraries.
        zint main (void) { })r)r`)rZlibraryrr1rZother_librariesrrrÚ    check_lib4s
 
 
ÿzconfig.check_libcCs|jd|g|dS)z¤Determine if the system header file named by 'header_file'
        exists and can be found by the preprocessor; return true if so,
        false otherwise.
        z /* No body */)r0r1r)rR)rr5rrr2rrrÚ check_headerBs
ÿzconfig.check_header)NNNr)NNNr)NNr)NNNNr)NNNNr)NNNNrr)NNr)Ú__name__Ú
__module__Ú __qualname__Ú descriptionÚ user_optionsrr"r#r)r6r<r@rFrMrRrZr]r`rbrgrhrirrrrrs\î     
ÿ
 
ÿ
ÿ
ÿ
ÿ
ÿrcCsJ|dkrt d|¡n
t |¡t|ƒ}zt | ¡¡W5| ¡XdS)zjDumps a file content into log.info.
 
    If head is not None, will be dumped before the file content.
    Nz%s)rrHr.ÚcloseÚread)r3Úheadr4rrrr=Ks
r=)N)Ú__doc__r rTÚdistutils.corerÚdistutils.errorsrÚdistutils.sysconfigrÚ    distutilsrr-rr=rrrrÚ<module>s     
8