źh{dZddlZddlZddlZddlZddlmZddlmZm Z m Z m Z m Z m Z ddlmZmZddlmZddlmZdd lmZdd lmZdd lmZd d lmZddlmZejdZdZ GddeZ!dS)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]*)*$c&ddlm}|dS)Nrshow_compilers) ccompilerrrs /builddir/build/BUILD/imunify360-venv-2.5.2/opt/imunify360/venv/lib/python3.11/site-packages/setuptools/_distutils/command/build_ext.pyrr#s(******Nc eZdZdZdejzZdddddezfdd d d ezfd d ddddezfddddddddddgZgdZ ddde fgZ d Z d!Z d"Zd#Zd$Zd%Zd&Zd'Zd(Zejd)Zd*Zd+Zd,Zd-Zd.Zd/Zd0Zd1ZdS)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|_dS)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 Nddlm}|ddddddd d |j|jj|_|jj|_|}|d }|j |jj pg|_ t|j tr)|j tj|_ tjtjkrB|j tjtjd |j | tjj||kr<|j | tjj|d|d|jg|_|jg|_nCt|jtr)|j tj|_|jg|_nCt|jtr)|j tj|_tjdkr|jtjtjdtjtjkrB|jtjtjd|jr+tj|jd|_n*tj|jd|_|j tjt?|jtj|j dkrd}n|j dd}tjtjd}|r tj||}|j|tj!dddkru|j"sT|jtjtjddtGzdn|jd|$drO|j"s.|j|$dn|jd|j%r+|j% d}d |D|_%|j&r|j& d|_&|j'g|_'n|j' d!|_'|j(rtjtRd }tjtRd}tj*|r|j |tj*|r4|j||j|t|j+tr9 tY|j+|_+dS#tZ$rt]d"wxYwdS)#Nr) sysconfigbuild)r3r3)r5r5)r>r>)r)r))r+r+)rBrB)r4r4r) plat_specificincluder:r=ntlibsDebugReleasewin32PCbuildcygwinlibpythonconfig.Py_ENABLE_SHAREDLIBDIR,cg|]}|dfS)1).0symbols r z.build_ext.finalize_options..s???VFC=???r 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_libdefines user_includeuser_libs rfinalize_optionszbuild_ext.finalize_optionss'''''' ""  & ( $   $ &  < ,8DL+7--// #222CC   $ $ 1 > D"D  d' - - D $ 1 7 7 C CD  ?c2 2 2   $ $RW\\#/9%M%M N N N   !1!1"'/!B!BCCC j ( (   $ $_%:%:27?%K%K L L L  ,,, /// > !DN   $ "D   )3 / / D $ 1 7 7 C CD  : DJJ  C ( ( 6))"*55DJ 7d??   $ $RW\\#/6%J%J K K K#sz11!((c6JF)S)STTTz K"$',,t"H"H"$',,t "J"J   $ $RW__5J5L5L%M%M N N N   $ $S%9 : : :~(( +gll3?I>>G 8',,w77   $ $W - - - < x ' ') .!((GLL E86H6J6J+JH!((---  # #$6 7 7 .) .!(()A)A()K)KLLLL!((--- ; @k'',,G??w???DK : /))#..DJ > !DNN!^11#66DN 9 ,7<< 9==Lw||Iu55Hw}}\** 7!((666w}}X&& ,!((222 !!(+++ dmS ) ) L L #DM 2 2  L L L*+JKKK L L Ls -\\"cvddlm}|jsdS|jrb|d}|j|pg|j |j ||j |j |j|j|_ t!|j t"jdkr6|jt)kr|j |j|j|j |j|j(|jD] \}}|j ||!|j$|jD]}|j ||j|j |j|j |j |j |j|j |j|j |j !|j |"dS)Nr) new_compiler build_clib)r>verbosedry_runr+rK)#rrr2rdhas_c_librariesget_finalized_commandr:rsget_library_namesr;rprr>rrr+r rkrur4r initializer7set_include_dirsr8 define_macror9undefine_macro set_librariesset_library_dirsr<set_runtime_library_dirsr=set_link_objectsbuild_extensions)rDrrruvaluemacros rrunz build_ext.runs3,,,,,,  F   , , . . <33LAAJ N ! !*">">"@"@"FB G G G   $ $Z%: ; ; ;% ]LL*     4=))) 7d??t~?? M $ $T^ 4 4 4   ( M * *4+< = = = ; "#{ 8 8 e **47777 : ! 4 4 ,,U3333 > % M ' ' 7 7 7   ( M * *4+< = = = : ! M 2 24: > > >   ( M * *4+< = = = rct|tstdt|D] \}}t|trt|t rt |dkrtd|\}}tjd|t|trt |stdt|tstdt ||d}dD]*}| |}|t|||+| d |_d |vrtjd | d }|rg|_g|_|D]} t| t rt | dvstdt | dkr!|j| dkt | dkr|j| |||< d S)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)rhlistr enumeratertuplelenrwarningriextension_name_rematchdictgetsetattrruntime_library_dirs define_macros undef_macrosrp) rDr2r!extext_name build_infokeyvalrrs rcheck_extensions_listzbuild_ext.check_extensions_list[s*d++ %L  ++J J FAs#y)) c5)) SXX]])4 $' Hj K:    x-- 2C2I2I(2S2S )< j$// )8Hj&;<'>C $Z'' R  ^^H--F 8$&!#% # 8 8E&ue44Uv9M9M145zzQ(//a9999Uq)00777JqMMUJ J rc||jg}|jD]}||j|SN)rr2rsr)rD filenamesrs rget_source_fileszbuild_ext.get_source_filessO ""4?333 ? * *C   S[ ) ) ) )rc||jg}|jD]/}|||j0|Sr)rr2rpget_ext_fullpathru)rDoutputsrs r get_outputszbuild_ext.get_outputss\ ""4?333 ? < .s7?B 4c::r) rBrk cpu_countconcurrent.futuresr ImportErrorrr2zip_filter_build_errorsresult)rDworkersrfuturesrfutrs` @rrz$build_ext._build_extensions_parallels- =D lnnG  = = = = = = =   GGG  ?  ) ) + + + F  G 4 4 4 !FJoG 99 ! !S..s33!!JJLLL!!!!!!!!!!!!!!! !  ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! !sC. ==$AC#(C = C# C C#C C##C'*C'c|jD]D}||5||dddn #1swxYwYEdSr)r2rr)rDrs rrz"build_ext._build_extensions_serials? * *C**3// * *$$S))) * * * * * * * * * * * * * * * * *sAA A c#K dVdS#tttf$rA}|js|d|j|Yd}~dSd}~wwxYw)Nz"building extension "{}" failed: {})rrr optionalwarnformatru)rDres rrzbuild_ext._filter_build_errorss P EEEEE = P P P<  II:AA#(ANN O O O O O O O O O Ps A"6AA"c |j}|t|ttfst d|jzt |}||j}||jz}|j s-t||dstj d|jdStj d|j|||}|jpg}|jdd}|jD]}||f|j||j||j|j ||j}|dd|_|jr||j|jpg}|jp|j|} |j|||||j|j ||!||j |j|  dS)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)"rrhrrrrusortedrrr+rrr)info swig_sourcesrrrrpr>compiler5r7_built_objectsrrsrlanguagedetect_languagelink_shared_object get_librariesr;rget_export_symbols) rDrrext_pathr extra_argsrr9objectsrs rrzbuild_ext.build_extensions!+ ?*WtUm"D"D?%-/2x8  //((22CK'  :k'8WEE : IJ#>???##F+++'22 V$$""6****  y,DNN,,)$''' = $ OOF # # #~ #( # #""""" : :F!&)F H(&& 9 9 9 JJx4"88 9 9 9 9rctjdkrdStjdkrMdD]H}tjd|zd}tj|r|cSIdSt 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')rkrurqrrisfiler )rDversfns rrzbuild_ext.find_swigs 7g  6 W__. " "W\\,"5zBB7>>"%%III"z(#%'W- rc*||}|d}||d}|jsDt jj|dd|gz}tj|j|Sd|dd}|d}tj | |}tj||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_fullnamerjget_ext_filenamer rkrqrrr3rabspathget_package_dir)rDrfullnamemodpathfilenamer6r package_dirs rrzbuild_ext.get_ext_fullpaths ((22..%%((55| :w|WSbS\XJ%>?H7<<99 9((71R4=))--j99gooh&>&>w&G&GHH w||K222rc.|j|S|jdz|zS)zSReturns the fullname of a given extension name. Adds the `package.` prefixNrW)r6)rDrs rrzbuild_ext.get_ext_fullnames# < O<#%0 0rczddlm}|d}|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"). rrzrW EXT_SUFFIX)rGrzrjrkrqrr)rDrrzr ext_suffixs rrzbuild_ext.get_ext_filenamesJ /.....>>#&&#^L11 w|X&33rcv|jdd} |dd|z}nO#t$rBd|ddddz}YnwxYwd |z}||jvr|j||jS) 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)rurjencodeUnicodeEncodeErrorreplacedecoderrp)rDrrur initfunc_names rrzbuild_ext.get_export_symbolss x~~c""2&  KK 4ZFF" X X XDKK 33;;D$GGNNwWWWFFF X !6)  2 2 2   % %m 4 4 4!!s=A B B ctjdkrYddlm}t |j|s=d}|jr|dz}|tjdz tjdz dzfz}|j|gzSndd l m }d }|d r\ttd rd }nDtjdkrd }n1dtj vr#|ddkrd }n|ddkrd }|r|d}|jd|zgzS|jtjzS)zReturn the list of libraries to link against when building a shared extension. On most platforms, this is just 'ext.libraries'; on Windows, we add the Python library (eg. python20.dll). rOr) MSVCCompilerz python%d%d_dr FrXgetandroidapilevelTrS_PYTHON_HOST_PLATFORMANDROID_API_LEVELrMACHDEP LDVERSIONrU)rmrx _msvccompilerrrhr>r) hexversionr:rGrzhasattrrkenvironr pythonlib)rDrrtemplater(rzlink_libpython ldversions rrzbuild_ext.get_librariessm <7 " " 4 4 4 4 4 4dm\:: 3':/'$H$Nb(^r)T1( } {22 3( 3 2 2 2 2 2"N~011 .3 455 .%)NN\X--%)NN, ::%~&9::a??)-' 22h>>)- >*N;77 }9(<'===}z35555r) __name__ __module__ __qualname__ descriptionrkrlsep_byr user_optionsboolean_optionsr help_optionsrErrrrrrrr contextlibcontextmanagerrrrrrrrrrr]rrrr)sLK($bj 0FGQ   *lnn -     r?s  ?>>>>>>>------######!!!!!!BJUVV k 6k 6k 6k 6k 6k 6k 6k 6k 6k 6r