K i1dZddlmZddlZddlZddlZddlmZddlm Z ddl m Z m Z m Z mZddlmZdd lmZdd lmZd d d ZGddeZddZy)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". ) annotationsN)Sequence)log) CCompiler CompileError LinkError new_compiler)Command)DistutilsExecError)customize_compilerz.cz.cxx)czc++ceZdZdZgdZdZdZdZdZdZ dZ d Z d Z d Z dd ZddZddZ ddZ ddZ ddZd d d gf ddZddZy )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 themctd|_d|_d|_d|_d|_d|_d|_g|_y)N)compilercc include_dirs libraries library_dirsr dump_source temp_filesselfs j/mnt/ssd/data/python-lab/Trading/venv/lib/python3.12/site-packages/setuptools/_distutils/command/config.pyinitialize_optionszconfig.initialize_options2sA    c&|j |jjxsg|_nHt|jtr.|jj t j |_|jg|_n,t|jtr|jg|_|jg|_yt|jtr/|jj t j |_yyN) r distribution isinstancestrsplitospathseprrr s r"finalize_optionszconfig.finalize_optionsAs    $ $ 1 1 > > D"D  ))3 / $ 1 1 7 7 CD  >> !DN  ,"nn-DN    $ "D  ))3 / $ 1 1 7 7 CD 0r$cyr&r s r"runz config.runQs r$ct|jtst|j|jd|_t |j|j r%|jj|j |jr%|jj|j|jr&|jj|jyyy)z^Check that 'self.compiler' really is a CCompiler object; if not, make it one. T)rdry_runforceN) r(rrr r2r rset_include_dirsr set_librariesrset_library_dirsr s r"_check_compilerzconfig._check_compilerXs$--3( DDM t}} -   ..t/@/@A~~ ++DNN;   ..t/@/@A!4r$cdt|z}t|dd5}|r-|D]}|jd|d|jd|j||ddk7r|jdddd|S#1swY|SxYw) N _configtestwutf-8encodingz #include  )LANG_EXTopenwrite)r!bodyheaderslangfilenamefileheaders r"_gen_temp_sourcefilezconfig._gen_temp_sourcefilehs 8D>1 (C' 2 !d%9FJJF83789 4 JJt Bx4 4  ! !s AA??B c|j|||}d}|jj||g|jj |||||fS)Nz _configtest.ir)rIrextendr preprocess)r!rCrDrrEsrcouts r" _preprocesszconfig._preprocesstsT''gt< Sz*   c  ESzr$c|j|||}|jrt|d|d|jj |g\}|j j ||g|jj|g|||fS)Nz compiling 'z':rK)rIr dump_filerobject_filenamesrrLcompile)r!rCrDrrErNobjs r"_compilezconfig._compile{s''gt<    c[R0 1//6 Sz* se,?Szr$c|j||||\}}tjjtjj |d} |j j |g| ||||j j| |j jz} |jj| ||| fS)Nr)rr target_lang) rVr+pathsplitextbasenamerlink_executable exe_extensionrappend) r!rCrDrrrrErNrUprogs r"_linkz config._links]]4,E cww 0 0 56q9 %% E % &  == & & 2$--555D t$S$r$c|s|j}g|_tjddj||D]} t j |y#t $rY'wxYw)Nz removing: %s )rrinfojoinr+removeOSError)r! filenamesrFs r"_cleanz config._cleans`I DO )!45! H  (#   sA A%$A%Nc|jd} |j|||||j|S#t$rd}YwxYw)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.) TF)r7rPrrhr!rCrDrrEoks r"try_cppzconfig.try_cppsT      T7L$ ?   B s: AAc,|j|j||||\}}ttrt j t |d5}tfd|D} ddd|j S#1swYxYw)aConstruct 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. r;r<c3@K|]}j|ywr&)search).0linepatterns r" z$config.search_cpp..s>t,>sN) r7rPr(r)rerTrAanyrh) r!rrrCrDrrErNrOrGmatchs ` r" search_cppzconfig.search_cpps ##D'<FS gs #jj)G # ( ?D>>>E ?   ? ?s B  Bc|j |j||||d}tj|xrdxsd|j |S#t$rd}Y)r7r^rdr}) r!funcrDrrrdeclcallrCs r" check_funczconfig.check_funcs.   KK$tfD) * O$  KK"TF# ' KK"TF! % Cyy%}}T7L)\RRr$c f|j|jd|||gt|z|S)aDetermine 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) { })r7r}list)r!libraryrrDrother_librariess r" check_libzconfig.check_lib:s< }} !   I_- -    r$c,|jd|g|S)zDetermine 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 */)rCrDr)rl)r!rHrrrEs r" check_headerzconfig.check_headerSs# || 6(  r$)NNNr)NNr)NNNNr)NNNNFF)rz Sequence[str])__name__ __module__ __qualname__ description user_optionsr#r-r0r7rIrPrVr`rhrlrwr{r}rrrrr/r$r"rrs$KL& D  B  " *"( $ 6 D  #SP)+  '  2 r$rc|tjd|ntj|tjtj|j dy)zjDumps a file content into log.info. If head is not None, will be dumped before the file content. Nz%sr;r<)rrcpathlibPath read_text)rFheads r"rRrR]sE  | x  HHW\\( # - -w - ?@r$r&)__doc__ __future__rr+rrtcollections.abcrdistutils._logr ccompilerrrr r corer errorsr sysconfigr r@rrRr/r$r"rsL #  $HH'*f %~ W~ B Ar$