
    n&ph                       S r SSKJr  SSKrSSKrSSKrSSKrSSKJr  SSK	J
r
  SSKJr  SSKJr  SS	KJr  SS
KJrJr  SSKJr  SSKJrJrJrJrJrJr  SSKJr  SSKJ r J!r!J"r"  SSK#J$r$J%r%J&r&  \RN                  " S5      r( " S S\5      r)g)zdistutils.command.build_ext

Implements the Distutils 'build_ext' command, for building extension
modules (currently limited to C extensions, should accommodate C++
extensions ASAP).    )annotationsN)Callable)log)	USER_BASE)ClassVar   )newer_group)new_compilershow_compilers)Command)CCompilerErrorCompileErrorDistutilsErrorDistutilsOptionErrorDistutilsPlatformErrorDistutilsSetupError)	Extension)customize_compilerget_config_h_filenameget_python_version)get_platformis_freethreadedis_mingwz3^[a-zA-Z_][a-zA-Z_0-9]*(\.[a-zA-Z_][a-zA-Z_0-9]*)*$c                     \ rS rSr% SrS\R                   S3rSSSSS	\" 5        S
34SSSS\-   4SSSSSS\-   4SSSSSSSSSS/r	/ SQr
S \S!'   S"S#S$\4/rS%\S&'   S' r\S( 5       rS<S) jrS<S* jrS<S+ jrS, rS- rS<S. jrS/ rS0 r\R4                  S1 5       rS<S2 jrS3 rS4 rS=S5 jrS=S6 jr S=S7 jr!S>S8 jr"S9 r#S>S: jr$S;r%g#)?	build_ext&   z8build C/C++ extensions (compile/link to build directory)z (separated by 'z'))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: ])inplaceiziignore 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)zdefine=DzC preprocessor macros to define)zundef=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)zrpath=Rz7directories to search for shared C libraries at runtime)zlink-objects=Oz2extra explicit link objects to include in the link)debuggz'compile/link with debugging information)forcefz2forcibly build everything (ignore file timestamps))z	compiler=czspecify the compiler type)z	parallel=jznumber of parallel build jobs)swig-cppNz)make SWIG create C++ files (default is C))z
swig-opts=Nz!list of SWIG command line options)zswig=Nzpath to the SWIG executable)userNz#add user include, library and rpath)r!   r*   r,   r0   r1   zClassVar[list[str]]boolean_optionszhelp-compilerNzlist available compilerszAClassVar[list[tuple[str, str | None, str, Callable[[], object]]]]help_optionsc                *   S U l         S U l        S U l        S U l        SU l        S U l        S U l        S U l        S U l        S U l	        S U l
        S U l        S U l        S U l        S U l        S U l        S U l        S U l        S U l        S U l        S U l        g )NF)
extensions	build_lib	plat_name
build_tempr!   packageinclude_dirsdefineundef	librarieslibrary_dirsrpathlink_objectsr*   r,   compilerswigswig_cpp	swig_optsr1   parallelselfs    Z/var/www/html/venv/lib/python3.13/site-packages/setuptools/_distutils/command/build_ext.pyinitialize_optionsbuild_ext.initialize_optionsp   s     
 
 

		    c              #  <  #    U R                  S5      (       d  gU R                  (       a  Sv   g[        R                  S:X  aD  U R                  S5      nU R                  S5      n[        R
                  R                  X5      v   gU R                  S5      v   g7f)z
Resolve Python's library directory for building extensions
that rely on a shared Python library.

See python/cpython#44264 and python/cpython#48686
Py_ENABLE_SHAREDN.zosbase
platlibdirLIBDIR)get_config_varpython_buildsysplatformospathjoin)	sysconfiginstalled_dirlib_dirs      rH   _python_lib_dirbuild_ext._python_lib_dir   s      ''(:;;!!I<<5  &44V<M..|<G'',,}66 **844s   BBc           
        SSK Jn  U R                  SSSSSSS	S
5        U R                  c  U R                  R
                  U l        U R                  R                  U l        UR                  5       nUR                  SS9nU R                  c$  U R                  R                  =(       d    / U l	        [        U R                  [        5      (       a.  U R                  R                  [        R                  5      U l	        [        R                   [        R"                  :w  aG  U R                  R%                  [        R&                  R)                  [        R                   S5      5        U R                  R+                  UR                  [        R&                  R                  5      5        X2:w  aB  U R                  R+                  UR                  [        R&                  R                  5      5        U R-                  S5        U R-                  S5        U R.                  c  / U l        U R0                  c  / U l        OM[        U R0                  [        5      (       a.  U R0                  R                  [        R                  5      U l        U R2                  c  / U l        OM[        U R2                  [        5      (       a.  U R2                  R                  [        R                  5      U l        [        R4                  S:X  Ga*  [7        5       (       Gd  U R0                  R%                  [        R&                  R)                  [        R                   S5      5        [        R"                  [        R8                  :w  aG  U R0                  R%                  [        R&                  R)                  [        R"                  S5      5        U R:                  (       a0  [        R&                  R)                  U R<                  S5      U l        O/[        R&                  R)                  U R<                  S5      U l        U R                  R%                  [        R&                  R?                  [A        5       5      5        U R0                  R%                  [        R"                  5        U RB                  S:X  a  SnOU RB                  SS  n[        R&                  R)                  [        R                   S5      nU(       a  [        R&                  R)                  XT5      nU R0                  R%                  U5        [        RD                  S S S:X  a  URF                  (       dU  U R0                  R%                  [        R&                  R)                  [        R8                  SS[I        5       -   S5      5        OU R0                  R%                  S5        U R0                  R+                  U RK                  U5      5        U RL                  (       a4  U RL                  R                  S5      nU Vs/ s H  owS4PM     snU l&        U RN                  (       a   U RN                  R                  S5      U l'        U RP                  c  / U l(        O U RP                  R                  S5      U l(        U RR                  (       a  [        R&                  R)                  [T        S5      n[        R&                  R)                  [T        S5      n	[        R&                  RW                  U5      (       a  U R                  R%                  U5        [        R&                  RW                  U	5      (       a6  U R0                  R%                  U	5        U R2                  R%                  U	5        [        U RX                  [        5      (       a   [[        U RX                  5      U l,        g g s  snf ! [\         a    [_        S 5      ef = f)!Nr   )rZ   build)r6   r6   )r8   r8   )rA   rA   )r*   r*   )r,   r,   )rE   rE   )r7   r7   T)plat_specificincluder=   r@   ntlibsDebugReleasewin32   PCbuild   cygwinlibpythonconfigrN   ,1 zparallel should be an integer)0	distutilsrZ   set_undefined_optionsr9   distributionext_packageext_modulesr5   get_python_incr:   
isinstancestrsplitrW   pathseprU   exec_prefixbase_exec_prefixappendrX   rY   extendensure_string_listr=   r>   r?   namer   prefixr*   r8   dirnamer   r7   rV   rT   r   r]   r;   r<   rD   r1   r   isdirrE   int
ValueErrorr   )
rG   rZ   
py_includeplat_py_includesuffixnew_libdefinessymboluser_includeuser_libs
             rH   finalize_optionsbuild_ext.finalize_options   sX   '""&($$&		
 <<,,88DL++77 --/
#222F$ $ 1 1 > > D"Dd''-- $ 1 1 7 7

 CD ??c222$$RWW\\#//9%MN 	  !1!1"''//!BC($$_%:%:277??%KL,/ >>!DN$ "D))3// $ 1 1 7 7

 CD::DJ

C(())"**5DJ
 77d?8:: $$RWW\\#//6%JK##szz1!!((c6J6JF)STzz"$'',,t"H"$'',,t	"J $$RWW__5J5L%MN$$S%9%9: ~~(  +ggll3??I>G'',,w7$$W- <<x'))!!((GGLL

E86H6J+JH !!((-  !5!5i!@A ;;kk'',G7>?wVC=w?DK
 ::))#.DJ>>!DN!^^11#6DN 9977<<	9=Lww||Iu5Hww}}\**!!((6ww}}X&&!!((2

!!(+dmmS))L #DMM 2 */ @4  L*+JKKLs   _)_
 
_ c                   U R                   (       d  g U R                  R                  5       (       ah  U R                  S5      nU R                  R                  UR                  5       =(       d    / 5        U R                  R                  UR                  5        [        U R                  U R                  U R                  U R                  S9U l        [        U R                  5        [         R"                  S:X  a=  U R$                  ['        5       :w  a%  U R                  R)                  U R$                  5        [         R"                  S:X  a+  [+        5       (       a  U R                  R-                  SS5        U R.                  b%  U R                  R1                  U R.                  5        U R2                  b0  U R2                   H   u  p#U R                  R-                  X#5        M"     U R4                  b.  U R4                   H  nU R                  R7                  U5        M      U R                  b%  U R                  R9                  U R                  5        U R                  b%  U R                  R;                  U R                  5        U R<                  b%  U R                  R?                  U R<                  5        U R@                  b%  U R                  RC                  U R@                  5        U RE                  5         g )N
build_clib)rA   verbosedry_runr,   rc   Py_GIL_DISABLEDrp   )#r5   rt   has_c_librariesget_finalized_commandr=   r   get_library_namesr>   r~   r   r
   rA   r   r   r,   r   rW   r   r7   r   
initializer   define_macror:   set_include_dirsr;   r<   undefine_macroset_librariesset_library_dirsr?   set_runtime_library_dirsr@   set_link_objectsbuild_extensions)rG   r   r   valuemacros        rH   runbuild_ext.run,  s    
 ,,..33LAJNN!!*">">"@"FBG$$Z%:%:; %]]LLLL**	
 	4==) 77d?t~~?MM$$T^^4
 77d?00MM&&'8#> (MM**4+<+<=;;"#{{**47  +::!,,U3 $>>%MM''7(MM**4+<+<=::!MM224::>(MM**4+<+<= 	rK   c                6   [        U[        5      (       d  [        S5      e[        U5       GH  u  p#[        U[        5      (       a  M  [        U[
        5      (       a  [        U5      S:w  a  [        S5      eUu  pE[        R                  " SU5        [        U[        5      (       a  [        R                  U5      (       d  [        S5      e[        U[        5      (       d  [        S5      e[	        XES   5      nS H%  nUR                  U5      nUc  M  [        X6U5        M'     UR                  S
5      Ul        SU;   a  [        R                  " S5        UR                  S5      nU(       a  / Ul        / Ul        U H  n	[        U	[
        5      (       a  [        U	5      S;   d  [        S5      e[        U	5      S:X  a   UR"                  R%                  U	S   5        Ma  [        U	5      S:X  d  Mr  UR                   R%                  U	5        M     X1U'   GM     g	)at  Ensure 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 instancesr   zMeach 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)r:   r>   r=   extra_objectsextra_compile_argsextra_link_argsNr?   def_filez9'def_file' element of build info dict no longer supportedmacros)   r   z9'macros' element of build info dict must be 1- or 2-tupler   r   )rx   listr   	enumerater   tuplelenr   warningry   extension_name_rematchdictgetsetattrruntime_library_dirsdefine_macrosundef_macrosr~   )
rG   r5   r"   extext_name
build_infokeyvalr   r   s
             rH   check_extensions_listbuild_ext.check_extensions_listr  s    *d++%L   
+FA#y)) c5))SX])4 
 $' HKK: 	 x--2C2I2I(2S2S)< 
 j$//)8  H&;<C !nnS)?Cc* (2~~g'>C$Z'WX  ^^H-F$&!#% #E&ue44Uv9M1W  5zQ((//a9Uq))007 $  qMO ,rK   c                    U R                  U R                  5        / nU R                   H  nUR                  UR                  5        M      U$ N)r   r5   r   r   )rG   	filenamesr   s      rH   get_source_filesbuild_ext.get_source_files  sA    ""4??3	 ??CS[[) #rK   c                    U R                  U R                  5        U R                   Vs/ s H  oR                  UR                  5      PM     sn$ s  snf r   )r   r5   get_ext_fullpathr   rG   r   s     rH   get_outputsbuild_ext.get_outputs  sB     	""4??3
 <@??K?C%%chh/?KKKs   $Ac                    U R                  U R                  5        U R                  (       a  U R                  5         g U R	                  5         g r   )r   r5   rE   _build_extensions_parallel_build_extensions_serialrF   s    rH   r   build_ext.build_extensions  s3    ""4??3==++-))+rK   c                (   U R                   nU R                   SL a  [        R                  " 5       n SSKJn  Uc  U R                  5         g W" US9 nU R                   Vs/ s H  oCR                  U R                  U5      PM      nn[        U R                  U5       H/  u  pFU R                  U5         UR                  5         S S S 5        M1     S S S 5        g ! [
         a    S n Nf = fs  snf ! , (       d  f       Mb  = f! , (       d  f       g = f)NTr   )ThreadPoolExecutor)max_workers)rE   rW   	cpu_countconcurrent.futuresr   ImportErrorr   r5   submitbuild_extensionzip_filter_build_errorsresult)rG   workersr   executorr   futuresfuts          rH   r   $build_ext._build_extensions_parallel  s    --==D llnG	= ?))+G4FJooFUs 4 4c:o    9..s3JJL 43 :	 54  	G	 43 54sG   C D!%C,.D4C1DC)(C),D1
D ;D
Dc                    U R                    H.  nU R                  U5         U R                  U5        S S S 5        M0     g ! , (       d  f       MB  = fr   )r5   r   r   r   s     rH   r   "build_ext._build_extensions_serial  s;    ??C**3/$$S) 0/ #//s   A  
A	c              #     #     S v   g ! [         [        [        4 a=  nUR                  (       d  e U R	                  SUR
                   SU 35         S nAg S nAff = f7f)Nzbuilding extension "z
" failed: )r   r   r   optionalwarnr   )rG   r   es      rH   r   build_ext._filter_build_errors   sQ     	F= 	F<<II,SXXJjDEE	Fs*   A	 AA3AAAAc                   UR                   nUb  [        U[        [        45      (       d  [	        SUR
                   S35      e[        U5      nU R                  UR
                  5      nX!R                  -   nU R                  (       d3  [        XCS5      (       d"  [        R                  " SUR
                  5        g [        R                  " SUR
                  5        U R                  X!5      nUR                  =(       d    / nUR                   S S  nUR"                   H  nUR%                  U45        M     U R&                  R)                  UU R*                  UUR,                  U R                  UUR                  S9nUS S  U l        UR0                  (       a  UR3                  UR0                  5        UR4                  =(       d    / nUR6                  =(       d    U R&                  R9                  U5      n	U R&                  R;                  UUU R=                  U5      UR>                  UR@                  UU RC                  U5      U R                  U R*                  U	S9
  g )Nz$in 'ext_modules' option (extension 'zD'), 'sources' must be present and must be a list of source filenamesnewerz$skipping '%s' extension (up-to-date)zbuilding '%s' extension)
output_dirr   r:   r*   extra_postargsdepends)r=   r>   r   r   export_symbolsr*   r8   target_lang)"r   rx   r   r   r   r   sortedr   r   r,   r	   r   r*   infoswig_sourcesr   r   r   r~   rA   compiler8   r:   _built_objectsr   r   r   languagedetect_languagelink_shared_objectget_librariesr>   r   get_export_symbols)
rG   r   r   ext_pathr   
extra_argsr   r<   objectsr   s
             rH   r   build_ext.build_extension	  s   ++?*WtUm"D"D%6sxxj A- -  /((2KK'

k'WEEII<chhGHH.9
 ##G1  ++1r
""1%%%EMM5(# & --''))**%KK ( 
 &aj
 NN3,,-((.B
 <<I4==#@#@#I((((-))!$!9!9%2237**  	) 	
rK   c                V   / n/ n0 nU R                   (       a  [        R                  " S5        U R                   (       d   SU R                  ;   d  SUR                  ;   a  SnOSnU Hl  n[        R
                  R                  U5      u  pU	S:X  a1  UR                  US-   U-   5        UR                  U5        US   XW'   M[  UR                  U5        Mn     U(       d  U$ U R                  =(       d    U R                  5       n
U
S/nUR                  U R                  5        U R                   (       a  UR                  S5        U R                  (       d  UR                  UR                  5        U H4  nXW   n[        R                  " S	X|5        U R                  US
X/-   5        M6     U$ )zWalk the list of source files in 'sources', looking for SWIG
interface (.i) files.  Run SWIG on all that are found, and
return a modified 'sources' list with SWIG source files replaced
by the generated C (or C++) files.
z/--swig-cpp is deprecated - use --swig-opts=-c++z-c++z.cppz.cz.i_wrapz-pythonzswigging %s to %sz-o)rC   r   r   rD   rW   rX   splitextr~   rB   	find_swigr   r   spawn)rG   r   	extensionnew_sourcesr   swig_targets
target_extsourcerP   r   rB   swig_cmdtargets                rH   r   build_ext.swig_sourcesZ  sc     ==KKIJ MM$..()---JJF''**62KTd{""4'>J#>?##F+'22$""6*  yy,DNN,)$'==OOF# ~~OOI//0"F!)FHH(&9JJx4"889 #
 rK   c                8   [         R                  S:X  a  g[         R                  S:X  aU  S HN  n[         R                  R                  SU 3S5      n[         R                  R	                  U5      (       d  ML  Us  $    g[        S[         R                   S35      e)	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.
posixrB   rc   )z1.3z1.2z1.1zc:\swigzswig.exez;I don't know how to find (much less run) SWIG on platform '')rW   r   rX   rY   isfiler   )rG   versfns      rH   r   build_ext.find_swig  s    
 77gWW_ .WW\\HTF"3Z@77>>"%%I .
 "(MbggYVWX rK   c                   U R                  U5      nUR                  S5      nU R                  US   5      nU R                  (       dN  [        R
                  R                  " USS U/-   6 n[        R
                  R                  U R                  U5      $ SR                  USS 5      nU R                  S5      n[        R
                  R                  UR                  U5      5      n[        R
                  R                  Xt5      $ )zReturns the path of the filename for a given extension.

The file is located in `build_lib` or directly in the package
(inplace option).
rN   r   Nr   build_py)get_ext_fullnamerz   get_ext_filenamer!   rW   rX   rY   r6   r   abspathget_package_dir)rG   r   fullnamemodpathfilenamer9   r  package_dirs           rH   r   build_ext.get_ext_fullpath  s     ((2..%((5|| ww||WSb\XJ%>?H77<<99 ((71R=)--j9ggooh&>&>w&GH ww||K22rK   c                D    U R                   c  U$ U R                   S-   U-   $ )zKReturns the fullname of a given extension name.

Adds the `package.` prefixrN   )r9   )rG   r   s     rH   r  build_ext.get_ext_fullname  s'     <<O<<#%00rK   c                    SSK Jn  UR                  S5      nU" S5      n[        R                  R
                  " U6 U-   $ )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").
r   rS   rN   
EXT_SUFFIX)rZ   rS   rz   rW   rX   rY   )rG   r   rS   r   
ext_suffixs        rH   r  build_ext.get_ext_filename  s7    
 	/>>#&#L1
ww||X&33rK   c                N   U R                  U5      n UR                  S5        SU-   nSU-   nXAR
                  ;  a  UR
                  R                  U5        UR
                  $ ! [         a6    SUR                  S5      R                  SS5      R	                  S5      -   n Nzf = f)zReturn 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.
ascii_U_punycode   -   _PyInit)_get_module_name_for_symbolencodeUnicodeEncodeErrorreplacedecoder   r~   )rG   r   r   r   initfunc_names        rH   r   build_ext.get_export_symbols  s     //4	  KK  4ZF 6) 2 22%%m4!!! " 	XDKK
3;;D$GNNwWWF	Xs   A$ $=B$#B$c                |    UR                   R                  S5      nUS   S:X  a  [        U5      S:  a  US   $ US   $ )NrN   r   __init__r   )r   rz   r   )rG   r   partss      rH   r+  %build_ext._get_module_name_for_symbol  s@     s#9
"s5zQ9RyrK   c                   [         R                  S:X  a  [        5       (       d  SSKJn  [        U R                  U5      (       dT  SnU R                  (       a  US-   nU[         R                  S-	  [         R                  S-	  S-  4-  nUR                  U/-   $  UR                  $ SS	K
Jn  S
nU" S5      (       ao  [        [         S5      (       a  SnOW[         R                  S:X  d  [        5       (       a  SnO1S[        R                  ;   a  U" S5      S:w  a  SnOU" S5      S:X  a  SnU(       a  U" S5      nUR                  SU-   /-   $ UR                  $ )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).
rg   r   )MSVCCompilerz
python%d%d_d         r  FrM   getandroidapilevelTrk   _PYTHON_HOST_PLATFORMANDROID_API_LEVELr   MACHDEP	LDVERSIONrm   )rU   rV   r   _msvccompilerr8  rx   rA   r*   
hexversionr=   rZ   rS   hasattrrW   environ)rG   r   r8  template	pythonlibrS   link_libpython	ldversions           rH   r   build_ext.get_libraries  s/    <<7"8::4dmm\::'::'$H$NNb(^^r)T1( 	 }}	{22 ;P }}) 3"N0113 455%)N\\X-%)N,

:%&9:a?)-'	2h>)-*;7	}}9(<'===}}rK   )r   r6   r8   rA   r*   r;   r5   r,   r:   r!   r=   r>   r@   r9   rE   r7   r?   rB   rC   rD   r<   r1   )returnNone)r   ry   rK  ry   )r   r   rK  z	list[str])&__name__
__module____qualname____firstlineno__descriptionrW   r{   sep_byr   user_optionsr2   __annotations__r   r3   rI   staticmethodr]   r   r   r   r   r   r   r   r   
contextlibcontextmanagerr   r   r   r   r   r  r  r   r+  r   __static_attributes__ rK   rH   r   r   &   se   LK(  

|2.FGQ%(+	
	
 <vE	

 	<<@<vE	

 	STAL7;GA6=K&LP,O(  
$ :NKWLS 0 5 50ILVD LV p	L,!**
 F FO
b6p0361	4"*5rK   r   )*__doc__
__future__r   rV  rW   rerU   collections.abcr   distutils._logr   siter   typingr   	_modifiedr	   	ccompilerr
   r   corer   errorsr   r   r   r   r   r   r  r   rZ   r   r   r   utilr   r   r   r   r   r   rY  rK   rH   <module>rf     sk    #  	 	 
 $    # 4   " U U : : JJUV F FrK   