o ?Og=3@sldZddlZddlZddlmZddlmZddlmZddl m Z ddd Z Gd d d eZ dd d Z dS)adistutils.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@seZdZdZgdZddZddZddZd d Zd d Z d dZ ddZ ddZ ddZ d(ddZ  d(ddZd)ddZ  d*ddZ  d*dd Z  !d+d"d#Zdddgfd$d%Z  d)d&d'ZdS),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)compilerZcc include_dirs libraries library_dirsr dump_source temp_filesselfr?/opt/alt/python310/lib64/python3.10/distutils/command/config.pyinitialize_options3s zconfig.initialize_optionscCs|jdur |jjp g|_nt|jtr|jtj|_|jdur$g|_n t|jtr/|jg|_|jdur9g|_dSt|jtrI|jtj|_dSdSN) rZ distribution isinstancestrsplitospathseprrrrrrfinalize_optionsBs        zconfig.finalize_optionscCsdSrrrrrrrunRsz config.runcCsddlm}m}t|j|s=||j|jdd|_t|j|jr'|j|j|j r1|j |j |j r?|j |j dSdSdS)z^Check that 'self.compiler' really is a CCompiler object; if not, make it one. r) CCompiler new_compilerr)rdry_runZforceN) distutils.ccompilerr"r#rrr$rrZset_include_dirsrZ set_librariesrZset_library_dirs)rr"r#rrr_check_compilerYs  zconfig._check_compilercCsdt|}t|d4}|r|D] }|d|q|d|||ddkr7|dWd|SWd|S1sBwY|S)NZ _configtestwz#include <%s>  )LANG_EXTopenwrite)rbodyheaderslangfilenamefileheaderrrr_gen_temp_sourcefileks        zconfig._gen_temp_sourcefilecCs<||||}d}|j||g|jj|||d||fS)Nz _configtest.ir)r3rextendrZ preprocess)rr-r.rr/srcoutrrr _preprocessws zconfig._preprocesscCs\||||}|jrt|d||j|g\}|j||g|jj|g|d||fS)Nzcompiling '%s':r4)r3r dump_filerZobject_filenamesrr5compile)rr-r.rr/r6objrrr_compile~szconfig._compilec Csr|||||\}}tjtj|d} |jj|g| |||d|jjdur.| |jj} |j | ||| fS)Nr)rrZ target_lang) r<rpathsplitextbasenamerZlink_executableZ exe_extensionrappend) rr-r.rrrr/r6r;progrrr_links     z config._linkc GsP|s|j}g|_tdd||D]}zt|Wqty%YqwdS)Nz removing: %s )rrinfojoinrremoveOSError)r filenamesr0rrr_cleans z config._cleanNrcCsPddlm}|d}z |||||Wn |y!d}Ynw||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%rKr&r8rIrr-r.rr/rKokrrrtry_cpps  zconfig.try_cppc Cs||||||\}}t|trt|}t|}d} |} | dkr)n || r1d} nq Wdn1ss     8