VULN_CHECK_I913V6 SSh{dZddlZddlZddlZddlZddlmZddlmZm Z m Z m Z m Z m Z ddlmZmZddlmZddlmZdd lmZdd lmZdd lmZd d lmZddlmZej<dZdZ GddeZ!y)zdistutils.command.build_ext Implements the Distutils 'build_ext' command, for building extension modules (currently limited to C extensions, should accommodate C++ extensions ASAP).N)Command)DistutilsOptionErrorDistutilsSetupErrorCCompilerErrorDistutilsError CompileErrorDistutilsPlatformError)customize_compilerget_python_version)get_config_h_filename) newer_group) Extension) get_platform)log) py37compat) USER_BASEz3^[a-zA-Z_][a-zA-Z_0-9]*(\.[a-zA-Z_][a-zA-Z_0-9]*)*$cddlm}|y)Nrshow_compilers) ccompilerrrs L/usr/lib/python3.12/site-packages/setuptools/_distutils/command/build_ext.pyrr#s *c&eZdZdZdej zZdddddezfdd d d ezfd d ddddezfddddddddddgZgdZ ddde fgZ d Z d!Z d"Zd#Zd$Zd%Zd&Zd'Zd(Zej,d)Zd*Zd+Zd,Zd-Zd.Zd/Zd0Zd1Zy)2 build_extz8build C/C++ extensions (compile/link to build directory)z (separated by '%s'))z build-lib=bz(directory for compiled extension modules)z build-temp=tz1directory for temporary files (build by-products)z plat-name=pz>platform name to cross-compile for, if supported (default: %s))inplaceiziignore build-lib and put compiled extensions into the source directory alongside your pure Python modulesz 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 withz library-dirs=Lz.directories to search for external C libraries)zrpath=Rz7directories to search for shared C libraries at runtime)z link-objects=Oz2extra explicit link objects to include in the link)debuggz'compile/link with debugging information)forcefz2forcibly build everything (ignore file timestamps))z compiler=czspecify the compiler type)z parallel=jznumber of parallel build jobs)swig-cppNz)make SWIG create C++ files (default is C))z swig-opts=Nz!list of SWIG command line options)zswig=Nzpath to the SWIG executable)userNz#add user include, library and rpath)r r)r+r/r0z help-compilerNzlist available compilersc*d|_d|_d|_d|_d|_d|_d|_d|_d|_d|_ d|_ d|_ d|_ d|_ d|_d|_d|_d|_d|_d|_d|_y)Nr) extensions build_lib plat_name build_tempr package include_dirsdefineundef libraries library_dirsrpath link_objectsr)r+compilerswigswig_cpp swig_optsr0parallelselfs rinitialize_optionszbuild_ext.initialize_optionsms               rc ddlm}|jddddddd d |j|jj |_|jj |_|j}|jd }|j|jjxsg|_ t|jtr.|jjtj|_ tj tj"k7rG|jj%tj&j)tj d |jj+|jtj&j||k7rB|jj+|jtj&j|j-d|j-d|j.g|_|j0g|_nHt|j0tr.|j0jtj|_|j2g|_nHt|j2tr.|j2jtj|_tj4dk(r|j0j%tj&j)tj dtj"tj6k7rG|j0j%tj&j)tj"d|j8r0tj&j)|j:d|_n/tj&j)|j:d|_|jj%tj&j=t?|j0j%tj"|j@dk(rd}n|j@dd}tj&j)tj d}|r tj&j)||}|j0j%|tjBdddk(r||jDsU|j0j%tj&j)tj6ddtGzdn|j0j%d|jIdrR|jDs+|j0j%|jIdn|j0j%d|jJr2|jJjd}|Dcgc]}|d fc}|_%|jLr |jLjd|_&|jNg|_'n |jNjd!|_'|jPrtj&j)tRd }tj&j)tRd} tj&jU|r|jj%|tj&jU| r6|j0j%| |j2j%| t|jVtr tY|jV|_+yycc}w#tZ$r t]d"wxYw)#Nr) sysconfigbuild)r3r3)r5r5)r>r>)r)r))r+r+)rBrB)r4r4r) plat_specificincluder:r=ntlibsDebugReleasewin32PCbuildcygwinlibpythonconfig.Py_ENABLE_SHAREDLIBDIR,1 zparallel should be an integer)/ distutilsrGset_undefined_optionsr6 distribution ext_package ext_modulesr2get_python_incr7 isinstancestrsplitospathsepsys exec_prefixbase_exec_prefixappendpathjoinextendensure_string_listr:r;r<nameprefixr)r5dirnamer r4platform python_buildr get_config_varr8r9rAr0risdirrBint ValueErrorr) rDrG py_includeplat_py_includesuffixnew_libdefinessymbol user_includeuser_libs rfinalize_optionszbuild_ext.finalize_optionssv' ""  & ( $   $ &  << ,,88DL++77--/ #222C    $ $ 1 1 > > D"D  d'' - $ 1 1 7 7 CD  ??c22 2    $ $RWW\\#//9%M N   !1!1"''//!BC j (    $ $_%:%:277??%K L  , / >> !DN    $ "D  ))3 / $ 1 1 7 7 CD  :: DJ  C ())"**5DJ 77d?    $ $RWW\\#//6%J K##szz1!!((c6J6JF)STzz"$'',,t"H"$'',,t "J    $ $RWW__5J5L%M N    $ $S%9%9 :~~( +ggll3??I>G'',,w7    $ $W - << x '))!!((GGLL E86H6J+JH!!((-  # #$6 7))!!(()A)A()KL!!((- ;;kk'',G7>?wVFC=w?DK ::))#.DJ >> !DN!^^11#6DN 9977<< 9=Lww||Iu5Hww}}\*!!((6ww}}X&!!((2 !!(+ dmmS ) L #DMM 2  */@4 L*+JKK Ls ^$^))^>cPddlm}|jsy|jj rc|j d}|j j|jxsg|jj|j||j|j|j|j|_ t!|jt"j$dk(r<|j&t)k7r%|jj+|j&|j,%|jj/|j,|j00|j0D]!\}}|jj3||#|j4,|j4D]}|jj7||j %|jj9|j |j%|jj;|j|j<%|jj?|j<|j@%|jjC|j@|jEy)Nr) new_compiler build_clib)r>verbosedry_runr+rK)#rrr2r_has_c_librariesget_finalized_commandr:rnget_library_namesr;rkrr>rrr+r rfrpr4r initializer7set_include_dirsr8 define_macror9undefine_macro set_librariesset_library_dirsr<set_runtime_library_dirsr=set_link_objectsbuild_extensions)rDrrrpvaluemacros rrunz build_ext.runs,     , , .33LAJ NN ! !*">">"@"FB G    $ $Z%:%: ;%]]LLLL**   4==) 77d?t~~? MM $ $T^^ 4    ( MM * *4+<+< = ;; "#{{ e **47 + :: ! ,,U3$ >> % MM ' ' 7    ( MM * *4+<+< = :: ! MM 2 24:: >    ( MM * *4+<+< = rct|ts tdt|D]\}}t|trt|t rt |dk7r td|\}}tjd|t|trtj|s tdt|ts tdt ||d}dD]#}|j|}|t|||%|jd |_d |vrtjd |jd }|rg|_g|_|D]} t| t r t | dvs tdt | dk(r|j"j%| dXt | dk(sg|j j%| |||<y )aEnsure that the list of extensions (presumably provided as a command option 'extensions') is valid, i.e. it is a list of Extension objects. We also support the old-style list of 2-tuples, where the tuples are (ext_name, build_info), which are converted to Extension instances here. Raise DistutilsSetupError if the structure is invalid anywhere; just returns otherwise. z:'ext_modules' option must be a list of Extension instancesrzMeach element of 'ext_modules' option must be an Extension instance or 2-tuplezvold-style (ext_name, build_info) tuple found in ext_modules for extension '%s' -- please convert to Extension instancezRfirst element of each tuple in 'ext_modules' must be the extension name (a string)zOsecond element of each tuple in 'ext_modules' must be a dictionary (build info)sources)r7r;r: extra_objectsextra_compile_argsextra_link_argsNr<def_filez9'def_file' element of build info dict no longer supportedmacros)rrz9'macros' element of build info dict must be 1- or 2-tuplerr)rclistr enumeratertuplelenrwarningrdextension_name_rematchdictgetsetattrruntime_library_dirs define_macros undef_macrosrk) rDr2r!extext_name build_infokeyvalrrs rcheck_extensions_listzbuild_ext.check_extensions_list[s*d+%L  +FAs#y)c5)SX])4 $' Hj KK:  x-2C2I2I(2S)< j$/)8Hj&;C $Z' R  ^^H-F$&!#% #E&ue4Uv9M145zQ((//a9Uq))007$ JqMU,rc|j|jg}|jD]}|j|j|SN)rr2rnr)rD filenamesrs rget_source_fileszbuild_ext.get_source_filessA ""4??3 ??C   S[[ )#rc|j|jg}|jD],}|j|j|j.|Sr)rr2rkget_ext_fullpathrp)rDoutputsrs r get_outputszbuild_ext.get_outputssK ""4??3 ??C NN400: ;#rc|j|j|jr|jy|j yr)rr2rB_build_extensions_parallel_build_extensions_serialrCs rrzbuild_ext.build_extensionss3 ""4??3 ==  + + -  ) ) +rc |j}|jdurtj} ddlm}||j y|5}|jDcgc]}|j|j| }}t|j|D]/\}}|j|5|jddd1 dddy#t $rd}YwxYwcc}w#1swY[xYw#1swYyxYw)NTr)ThreadPoolExecutor) max_workers) rBrf cpu_countconcurrent.futuresr ImportErrorrr2submitbuild_extensionzip_filter_build_errorsresult)rDworkersrexecutorrfuturesfuts rrz$build_ext._build_extensions_parallels-- ==D llnG  = ?  ) ) +  G 4FJooFUs 4 4c:o  9S..s3JJL43: 5 4 G 43 5 4sGCC:!#C)/C:3C. C: C&%C&)C:.C7 3C::Dc|jD]-}|j|5|j|ddd/y#1swY:xYwr)r2rr)rDrs rrz"build_ext._build_extensions_serials;??C**3/$$S)0/#//s >A c#K dy#tttf$rB}|js|j dj |j |Yd}~yd}~wwxYww)Nz"building extension "{}" failed: {})rrr optionalwarnformatrp)rDres rrzbuild_ext._filter_build_errorssR P  = P<< II:AA#((AN O O Ps*A" A"A8AA"AA"c |j}|t|ttfst d|j zt |}|j|j }||jz}|js.t||ds!tjd|j ytjd|j |j||}|jxsg}|j dd}|j"D]}|j%|f|j&j)||j*||j,|j||j}|dd|_|j0r|j3|j0|j4xsg}|j6xs|j&j9|} |j&j;|||j=||j>|j@||jC||j|j*|  y)Nzjin 'ext_modules' option (extension '%s'), 'sources' must be present and must be a list of source filenamesnewerz$skipping '%s' extension (up-to-date)zbuilding '%s' extension) output_dirrr7r)extra_postargsdepends)r:r;rrexport_symbolsr)r5 target_lang)"rrcrrrrpsortedrrr+rrr)info swig_sourcesrrrrkr>compiler5r7_built_objectsrrnrlanguagedetect_languagelink_shared_object get_librariesr;rget_export_symbols) rDrrext_pathr extra_argsrr9objectsrs rrzbuild_ext.build_extensions++ ?*WtUm"D%-/2xx8  /((2CKK' k'8WE IIJ#>?##F+'22 V$""6* yy,DNN,)$' == OOF #~~((")#F!&)F HH(&& 9 JJx4"88 9# rc$tjdk(rytjdk(rNdD]H}tjjd|zd}tjj |sF|cSyt dtjz)zReturn the name of the SWIG executable. On Unix, this is just "swig" -- it should be in the PATH. Tries a bit harder on Windows. posixr?rK)z1.3z1.2z1.1z c:\swig%szswig.exez>I don't know how to find (much less run) SWIG on platform '%s')rfrprlrmisfiler )rDversfns rrzbuild_ext.find_swigs{ 77g  WW_.WW\\,"5zB77>>"%I. "(#%'WW- rc|j|}|jd}|j|d}|jsMt j j |dd|gz}tj j |j|Sdj |dd}|jd}tj j|j|}tj j ||S)zReturns the path of the filename for a given extension. The file is located in `build_lib` or directly in the package (inplace option). rWrNrbuild_py) get_ext_fullnamereget_ext_filenamer rfrlrmr3rabspathget_package_dir)rDrfullnamemodpathfilenamer6r package_dirs rrzbuild_ext.get_ext_fullpaths ((2..%((5||ww||WSb\XJ%>?H77<<9 9((71R=)--j9ggooh&>&>w&GH ww||K22rcB|j|S|jdz|zS)zSReturns the fullname of a given extension name. Adds the `package.` prefixrW)r6)rDrs rrzbuild_ext.get_ext_fullnames' << O<<#%0 0rc~ddlm}|jd}|d}tjj ||zS)zConvert the name of an extension (eg. "foo.bar") into the name of the file from which it will be loaded (eg. "foo/bar.so", or "foo\bar.pyd"). rrurW EXT_SUFFIX)rGrurerfrlrm)rDrrur ext_suffixs rrzbuild_ext.get_ext_filenames7 />>#&#L1 ww||X&33rcd|jjdd} |jdd|z}d |z}||j vr|j j||j S#t$r6d|jdj ddj dz}YxwxYw) aReturn the list of symbols that a shared extension has to export. This either uses 'ext.export_symbols' or, if it's not provided, "PyInit_" + module_name. Only relevant on Windows, where the .pyd file (DLL) must export the module "PyInit_" function. rWrascii_U_punycode-_PyInit)rpreencodeUnicodeEncodeErrorreplacedecoderrk)rDrrpr{ initfunc_names rrzbuild_ext.get_export_symbolss xx~~c"2&  KK 4ZF 6)  2 2 2    % %m 4!!!" XDKK 3;;D$GNNwWWF XsA00r) hexversionr:rGruhasattrrfenvironr pythonlib)rDrrtemplater#rulink_libpython ldversions rrzbuild_ext.get_librariess <<7 " 4dmm\:'::'$H$NNb(^^r)T1( }} {22 3"N013 45%)N\\X-%)N, :%&9:a?)-' 2h>)-*;7 }}9(<'===}}z33555r) __name__ __module__ __qualname__ descriptionrfrgsep_byr user_optionsboolean_optionsr help_optionsrErrrrrrrr contextlibcontextmanagerrrrrrrrrrrrrr)s2LK($bjj 0FGQ   *n -     r;sf  ?-#!BJJUV k 6k 6r