
    nj                       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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'  \RP                  " 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)	CCompiler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\
S '   / S!QrS"\
S#'   S$S%S&\4/rS'\
S('   S>S) jr\S* 5       rS>S+ jrS>S, jrS>S- jrS. rS/ rS>S0 jrS1 rS2 r\R4                  S3 5       rS>S4 jrS5 rS6 rS?S7 jrS?S8 jr S?S9 jr!S@S: jr"S; r#S@S< jr$S=r%g%)A	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 rpathzHClassVar[list[tuple[str, str, str]] | list[tuple[str, str | None, str]]]user_options)r"   r+   r-   r1   r2   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_optsr2   parallelselfs    c/var/www/html/pdf-tiff/venv/lib/python3.13/site-packages/setuptools/_distutils/command/build_ext.pyinitialize_optionsbuild_ext.initialize_optionsv   s    26""##''+
$('+ $
 
 #'
 15	$(	$(    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      rJ   _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   )r\   build)r8   r8   )r:   r:   )rC   rC   )r+   r+   )r-   r-   )rG   rG   )r9   r9   T)plat_specificincluder?   rB   ntlibsDebugReleasewin32   PCbuild   cygwinlibpythonconfigrP   ,1 zparallel should be an integer)0	distutilsr\   set_undefined_optionsr;   distributionext_packageext_modulesr7   get_python_incr<   
isinstancestrsplitrY   pathseprW   exec_prefixbase_exec_prefixappendrZ   r[   extendensure_string_listr?   r@   rA   namer   prefixr+   r:   dirnamer   r9   rX   rV   r   r_   r=   r>   rF   r2   r   isdirrG   int
ValueErrorr   )
rI   r\   
py_includeplat_py_includesuffixnew_libdefinessymboluser_includeuser_libs
             rJ   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                  S9U l        [        U R                  5        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                  R/                  U R,                  5        U R0                  b0  U R0                   H   u  p#U R                  R+                  X#5        M"     U R2                  b.  U R2                   H  nU R                  R5                  U5        M      U R                  b%  U R                  R7                  U R                  5        U R                  b%  U R                  R9                  U R                  5        U R:                  b%  U R                  R=                  U R:                  5        U R>                  b%  U R                  RA                  U R>                  5        U RC                  5         g )N
build_clib)rC   verboser-   re   Py_GIL_DISABLEDrr   )"r7   rv   has_c_librariesget_finalized_commandr?   r   get_library_namesr@   r   r   r   rC   r   r-   r   r9   r   
initializerY   r   r   define_macror<   set_include_dirsr=   r>   undefine_macroset_librariesset_library_dirsrA   set_runtime_library_dirsrB   set_link_objectsbuild_extensions)rI   r   r   valuemacros        rJ   runbuild_ext.run9  s    
 ,,..33LAJNN!!*">">"@"FBG$$Z%:%:; %]]LL**

 	4==) >>\^+MM$$T^^4
 77d?00MM&&'8#> (MM**4+<+<=;;"#{{**47  +::!,,U3 $>>%MM''7(MM**4+<+<=::!MM224::>(MM**4+<+<= 	rM   c                H   [        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      =(       d    / 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_argsNrA   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   )rz   listr   	enumerater   tuplelenr   warningr{   extension_name_rematchdictgetsetattrruntime_library_dirsdefine_macrosundef_macrosr   )
rI   r7   r#   extext_name
build_infokeyvalr   r   s
             rJ   check_extensions_listbuild_ext.check_extensions_list  s    *d++%L   
+FA#y)) c5))SX])4 
 $' HKK: 	 x--2C2I2I(2S2S)< 
 j$//)8  H&;<C !nnS)?Cc* (2~~g'>'D"C$Z'WX  ^^H-F$&!#% #E&ue44Uv9M1W  5zQ((//a9Uq))007 $  qMO ,rM   c                    U R                  U R                  5        / nU R                   H  nUR                  UR                  5        M      U$ N)r   r7   r   r   )rI   	filenamesr   s      rJ   get_source_filesbuild_ext.get_source_files  sA    ""4??3	 ??CS[[) #rM   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   r7   get_ext_fullpathr   rI   r   s     rJ   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   r7   rG   _build_extensions_parallel_build_extensions_serialrH   s    rJ   r   build_ext.build_extensions  s3    ""4??3==++-))+rM   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SS9 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_workersF)strict)rG   rY   	cpu_countconcurrent.futuresr   ImportErrorr   r7   submitbuild_extensionzip_filter_build_errorsresult)rI   workersr   executorr   futuresfuts          rJ   r   $build_ext._build_extensions_parallel  s    --==D llnG	= ?))+G4FJooFUs 4 4c:o    G..s3JJL 43 H	 54  	G	 43 54sG   C D!%C+-D3C0DC('C(+D0
C?: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   )r7   r   r   r   s     rJ   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   )rI   r   es      rJ   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&                  [(        5      (       d   S5       eU R&                  R+                  UU R,                  UUR.                  U R                  UUR                  S9nUS S  U l        UR2                  (       a  UR5                  UR2                  5        UR6                  =(       d    / nUR8                  =(       d    U R&                  R;                  U5      n	U R&                  R=                  UUU R?                  U5      UR@                  URB                  UU RE                  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' extensionz$run() must precede build_extension())
output_dirr   r<   r+   extra_postargsdepends)r?   r@   r   r   export_symbolsr+   r:   target_lang)#r   rz   r   r   r   r   sortedr   r   r-   r	   r   r+   infoswig_sourcesr   r   r   r   rC   r
   compiler:   r<   _built_objectsr   r   r   languagedetect_languagelink_shared_objectget_librariesr@   r   get_export_symbols)
rI   r   r   ext_pathr   
extra_argsr   r>   objectsr   s
             rJ   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(# & $--33 	
2	
3 --''))**%KK ( 
 &aj
 NN3,,-((.B
 <<I4==#@#@#I((((-))!$!9!9%2237**  	) 	
rM   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)rE   r   r   rF   rY   rZ   splitextr   rD   	find_swigr   r   spawn)rI   r   	extensionnew_sourcesr   swig_targets
target_extsourcerR   r   rD   swig_cmdtargets                rJ   r   build_ext.swig_sourcesn  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 #
 rM   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.
posixrD   re   )z1.3z1.2z1.1zc:\swigzswig.exez;I don't know how to find (much less run) SWIG on platform '')rY   r   rZ   r[   isfiler   )rI   versfns      rJ   r  build_ext.find_swig  s    
 77gWW_ .WW\\HTF"3Z@77>>"%%I . (MbggYVWX rM   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).
rP   r   Nr   build_py)get_ext_fullnamer|   get_ext_filenamer"   rY   rZ   r[   r8   r   abspathget_package_dir)rI   r   fullnamemodpathfilenamer;   r  package_dirs           rJ   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2rM   c                D    U R                   c  U$ U R                   S-   U-   $ )zKReturns the fullname of a given extension name.

Adds the `package.` prefixrP   )r;   )rI   r   s     rJ   r  build_ext.get_ext_fullname  s'     <<O<<#%00rM   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   rU   rP   
EXT_SUFFIX)r\   rU   r|   rY   rZ   r[   )rI   r   rU   r   
ext_suffixs        rJ   r  build_ext.get_ext_filename  s7    
 	/>>#&#L1
ww||X&33rM   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   )rI   r   r   r   initfunc_names        rJ   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   $ )NrP   r   __init__r   )r   r|   r   )rI   r   partss      rJ   r-  %build_ext._get_module_name_for_symbol  s@     s#9
"s5zQ9RyrM   c                   [         R                  S:X  a  [        5       (       d  SSKJn  [        U R                  U5      (       dc  S[         R                  S-	   [         R                  S-	  S-   3S[        5       -  -   S	[        U R                  5      -  -   nUR                  U/-   $  UR                  $ SS
KJn  SnU" S5      (       ai  [        [         S5      (       d#  [         R                  S:X  d  [        5       (       a  SnO.S[        R                   ;   a  U" S5      S:w  d  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).
ri   r   )MSVCCompilerro            r   _dr!  FrO   getandroidapilevelrm   T_PYTHON_HOST_PLATFORMANDROID_API_LEVELr   MACHDEP	LDVERSION)rW   rX   r   _msvccompilerr:  rz   rC   
hexversionr   boolr+   r?   r\   rU   hasattrrY   environ)rI   r   r:  	pythonlibrU   link_libpython	ldversions          rJ   r   build_ext.get_libraries
  s;    <<7"8::4dmm\::S^^r12CNNb4HD3P2QRO--.T$**--.  }}	{22 ;R }}/ 3"N011 C!566||x/zz%)N,

: '':;q@))4@)-*;7	}}9(<'===}}rM   )r   r8   r:   rC   r+   r=   r7   r-   r<   r"   r?   r@   rB   r;   rG   r9   rA   rD   rE   rF   r>   r2   )returnNone)r   r{   rM  r{   )r   r   rM  z	list[str])&__name__
__module____qualname____firstlineno__descriptionrY   r}   sep_byr   r3   __annotations__r4   r   r5   rK   staticmethodr_   r   r   r   r   r   r   r   r   
contextlibcontextmanagerr   r   r   r  r   r  r  r   r-  r   __static_attributes__ rM   rJ   r   r   &   su   LK(  

|2.F 	HQ)^,A/		
	
 <vE	

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

 	STAL7;GA6=S*	   ,\,O(  
$ :NKWLS )> 5 50ILVE NV p	L,!**
 F FU
n6p.361	4"*6rM   r   )+__doc__
__future__r   rW  rY   rerW   collections.abcr   distutils._logr   siter   typingr   	_modifiedr	   	ccompilerr
   r   r   corer   errorsr   r   r   r   r   r   r  r   r\   r   r   r   utilr   r   r   r   r   r   rZ  rM   rJ   <module>rg     sn    #  	 	 
 $    # ? ?   " U U : : JJUV Z ZrM   