f=3v ddlZddlZddlmZddlmZddlmZddlm Z dddZ Gd d eZ d d Z dS) N)Command)DistutilsExecError)customize_compiler)logz.cz.cxx)czc++ceZdZdZgdZdZdZdZdZdZ dZ d Z d Z d Z ddZ ddZddZ ddZ ddZ ddZd d d gfdZ ddZd S)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 themcvd|_d|_d|_d|_d|_d|_d|_g|_dS)N)compilercc include_dirs libraries library_dirsr dump_source temp_filesselfs ?/opt/alt/python311/lib64/python3.11/distutils/command/config.pyinitialize_optionszconfig.initialize_options3sE    c|j|jjpg|_nCt|jtr)|jt j|_|jg|_n't|jtr |jg|_|j g|_dSt|jtr+|jt j|_dSdSN) r distribution isinstancestrsplitospathseprrrs rfinalize_optionszconfig.finalize_optionsBs   $ $ 1 > D"D   )3 / / D $ 1 7 7 C CD  > !DNN  , , ."n-DN   $ "D    )3 / / D $ 1 7 7 C CD    D DrcdSrrs rrunz config.runRs rc ddlm}m}t|j|s||j|jd|_t |j|jr|j|j|j r|j |j |j r#|j |j dSdSdS)Nr) CCompiler new_compilerr)rdry_runforce) distutils.ccompilerr+r,r!rr-rrset_include_dirsr set_librariesrset_library_dirs)rr+r,s r_check_compilerzconfig._check_compilerYs @???????$-33 B(L$-15QHHHDM t} - - -  B ..t/@AAA~ < ++DN;;;  B ..t/@AAAAA B B B BrcJdt|z}t|d5}|r2|D]}|d|z|d|||ddkr|ddddn #1swxYwY|S)N _configtestwz#include <%s>  )LANG_EXTopenwrite)rbodyheaderslangfilenamefileheaders r_gen_temp_sourcefilezconfig._gen_temp_sourcefileks 8D>1 (C  !D !%;;FJJ069:::: 4   JJt   Bx4 4    ! ! ! ! ! ! ! ! ! ! ! ! ! ! !sA+BBBc||||}d}|j||g|j|||||fS)Nz _configtest.ir)rBrextendr preprocess)rr<r=rr>srcouts r _preprocesszconfig._preprocessws_''gt<< Sz***   c  EEESzrc||||}|jrt|d|z|j|g\}|j||g|j|g|||fS)Nzcompiling '%s':rD)rBr dump_filerobject_filenamesrrEcompile)rr<r=rr>rGobjs r_compilezconfig._compile~s''gt<<   4 c,s2 3 3 3//66 Sz*** se,???Szrcp|||||\}}tjtj|d} |j|g| ||||jj| |jjz} |j | ||| fS)Nr)rr target_lang) rOr$pathsplitextbasenamerlink_executable exe_extensionrappend) rr<r=rrrr>rGrNprogs r_linkz config._links]]4,EE cw 0 0 5 566q9 %%seT093?26 & 8 8 8 = & 2$-55D t$$$S$rc|s|j}g|_tjdd||D]'} t j|#t $rY$wxYwdS)Nz removing: %s )rrinfojoinr$removeOSError)r filenamesr?s r_cleanz config._cleans !I DO )!4!4555!  H  (####      sA A A Nrc ddlm}|d} |||||n #|$rd}YnwxYw||S)Nr CompileErrorTF)r/rdr3rIrarr<r=rr>rdoks rtry_cppzconfig.try_cpps 544444      T7L$ ? ? ? ?   BBB   s8AAc ||||||\}}t|trt j|}t |5}d} |} | dkrn|| rd} n4dddn #1swxYwY| | S)NFT) r3rIr!r"rerMr:readlinesearchra) rpatternr<r=rr>rGrHr@matchlines r search_cppzconfig.search_cpps  ##D'<FFS gs # # *j))G #YY $E }}2::>>$'' E                   s)8B--B14B1c ddlm}| |||||d}n #|$rd}YnwxYwt j|rdpd||S)NrrcTFsuccess!failure.)r/rdr3rOrr\rares r try_compilezconfig.try_compiles  544444   MM$t < < <BB   BBB  " 0j111  s8AAc ddlm}m}| |||||||d} n#||f$rd} YnwxYwt j| rdpd|| SNr)rd LinkErrorTFrrrs)r/rdrwr3rYrr\ra) rr<r=rrrr>rdrwrfs rtry_linkzconfig.try_links  @???????   JJtWl , 6 6 6BBi(   BBB  " 0j111  s< AAc2 ddlm}m}| |||||||\} } } || gd} n#||t f$rd} YnwxYwtj| rdpd| | Srv) r/rdrwr3rYspawnrrr\ra) rr<r=rrrr>rdrwrGrNexerfs rtry_runzconfig.try_runs  @???????   JJtWl'0,FFMCc JJu   BBi);<   BBB  " 0j111  s6AA('A(rc |g}|r|d|z|d|r|d|zn|d|z|dd|dz}||||||S)Nz int %s ();z int main () {z %s();z %s;}r7)r3rWr]rx) rfuncr=rrrdeclcallr<s r check_funczconfig.check_funcs    - KK t+ , , , O$$$  ( KK D( ) ) ) ) KK$ ' ' ' Cyy%}}T7L& 66 6rcf ||d|||g|z|S)Nzint main (void) { })r3rx)rlibraryrr=rother_librariess r check_libzconfig.check_lib4sG  }}2G\%Y8,HH Hrc6 |d|g|S)Nz /* No body */)r<r=r)rg)rrArrr>s r check_headerzconfig.check_headerBs- ||6()577 7r)NNNr)NNr)NNNNr)NNNNrr)__name__ __module__ __qualname__ description user_optionsrr&r)r3rBrIrOrYrargrprtrxr|rrrr(rrr r s$K   L4   DDD    BBB$          ,$IM8 IM),&HL(+2;?CD6666</3D#R H H H HDH777777rr c& |tjd|ntj|t|} tj||dS#|wxYw)Nz%s)rr\r:readclose)r?headr@s rrKrKKs{ | x      >>D   s &A::Br) r$rjdistutils.corerdistutils.errorsrdistutils.sysconfigr distutilsrr9r rKr(rrrs  """"""//////222222f % %t7t7t7t7t7Wt7t7t7l      r