
    ,h                       d Z ddlmZ ddlZddlZddlZddlZddlmZ ddl	m
Z
 ddlmZ ddlmZ dd	lmZ dd
lmZmZ ddlmZ ddlmZmZmZmZmZmZ ddlmZ ddlm Z m!Z!m"Z" ddl#m$Z$m%Z%m&Z&  ejN                  d      Z( G d de      Z)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).    )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                  j   e Zd ZU dZdej
                   dZddddd e        d	fd
dddez   fddddddez   fddddddddddgZg dZ	de
d <   d!d"d#efgZd$e
d%<   d& Zed'        Zd:d(Zd:d)Zd:d*Zd+ Zd, Zd:d-Zd. Zd/ Zej2                  d0        Zd:d1Zd2 Zd3 Zd;d4Zd;d5Zd;d6Z d<d7Z!d8 Z"d<d9Z#y")=	build_extz8build 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+   r/   r0   zClassVar[list[str]]boolean_optionszhelp-compilerNzlist available compilerszAClassVar[list[tuple[str, str | None, str, Callable[[], object]]]]help_optionsc                *   d | _         d | _        d | _        d | _        d| _        d | _        d | _        d | _        d | _        d | _	        d | _
        d | _        d | _        d | _        d | _        d | _        d | _        d | _        d | _        d | _        d | _        y )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_optsr0   parallelselfs    i/var/www/html/Resume-Scraper/venv/lib/python3.12/site-packages/setuptools/_distutils/command/build_ext.pyinitialize_optionszbuild_ext.initialize_optionsp   s     
 
 

		    c              #  (  K   | j                  d      sy| j                  rd yt        j                  dk(  rE| j                  d      }| j                  d      }t        j
                  j                  ||       y| j                  d       yw)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      rG   _python_lib_dirzbuild_ext._python_lib_dir   s      ''(:;!!I<<5  &44V<M..|<G'',,}g66 **844s   BBc           
     &   ddl m} | j                  ddddddd	d
       | j                  | j                  j
                  | _        | j                  j                  | _        |j                         }|j                  d      }| j                  | j                  j                  xs g | _	        t        | j                  t              r.| j                  j                  t        j                        | _	        t        j                   t        j"                  k7  rG| j                  j%                  t        j&                  j)                  t        j                   d             | j                  j+                  |j                  t        j&                  j                               ||k7  rB| j                  j+                  |j                  t        j&                  j                               | j-                  d       | j-                  d       | j.                  g | _        | j0                  g | _        nHt        | j0                  t              r.| j0                  j                  t        j                        | _        | j2                  g | _        nHt        | j2                  t              r.| j2                  j                  t        j                        | _        t        j4                  dk(  rt7               s| j0                  j%                  t        j&                  j)                  t        j                   d             t        j"                  t        j8                  k7  rG| j0                  j%                  t        j&                  j)                  t        j"                  d             | j:                  r0t        j&                  j)                  | j<                  d      | _        n/t        j&                  j)                  | j<                  d      | _        | j                  j%                  t        j&                  j?                  tA                            | j0                  j%                  t        j"                         | jB                  dk(  rd}n| jB                  dd  }t        j&                  j)                  t        j                   d      }|r t        j&                  j)                  ||      }| j0                  j%                  |       t        jD                  d d dk(  r||jF                  sU| j0                  j%                  t        j&                  j)                  t        j8                  ddtI               z   d             n| j0                  j%                  d       | j0                  j+                  | jK                  |             | jL                  r2| jL                  j                  d      }|D cg c]  }|df c}| _&        | jN                  r | jN                  j                  d      | _'        | jP                  g | _(        n | jP                  j                  d      | _(        | jR                  rt        j&                  j)                  tT        d      }t        j&                  j)                  tT        d      }	t        j&                  jW                  |      r| j                  j%                  |       t        j&                  jW                  |	      r6| j0                  j%                  |	       | j2                  j%                  |	       t        | jX                  t              r	 t[        | jX                        | _,        y y c c}w # t\        $ r t_        d       w xY w)!Nr   )rX   build)r5   r5   )r7   r7   )r@   r@   )r)   r)   )r+   r+   )rD   rD   )r6   r6   T)plat_specificincluder<   r?   ntlibsDebugReleasewin32   PCbuild   cygwinlibpythonconfigrL   ,1 zparallel should be an integer)0	distutilsrX   set_undefined_optionsr8   distributionext_packageext_modulesr4   get_python_incr9   
isinstancestrsplitrU   pathseprS   exec_prefixbase_exec_prefixappendrV   rW   extendensure_string_listr<   r=   r>   namer   prefixr)   r7   dirnamer   r6   rT   rR   r   r[   r:   r;   rC   r0   r   isdirrD   int
ValueErrorr   )
rF   rX   
py_includeplat_py_includesuffixnew_libdefinessymboluser_includeuser_libs
             rG   finalize_optionszbuild_ext.finalize_options   sF   '""&($$&		
 <<,,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j($$_%:%: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>?VFC=?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   )]6]; ;^c                   | j                   sy | j                  j                         rc| j                  d      }| j                  j                  |j                         xs g        | j                  j                  |j                         t        | j                  | j                  | j                  | j                        | _        t        | j                         t         j"                  dk(  r<| j$                  t'               k7  r%| j                  j)                  | j$                         t         j"                  dk(  r&t+               r| j                  j-                  dd       | j.                  %| j                  j1                  | j.                         | j2                  0| j2                  D ]!  \  }}| j                  j-                  ||       # | j4                  ,| j4                  D ]  }| j                  j7                  |        | j                  %| j                  j9                  | j                         | j                  %| j                  j;                  | j                         | j<                  %| j                  j?                  | j<                         | j@                  %| j                  jC                  | j@                         | jE                          y )N
build_clib)r@   verbosedry_runr+   r`   Py_GIL_DISABLEDrm   )#r4   rq   has_c_librariesget_finalized_commandr<   r|   get_library_namesr=   r{   r   r
   r@   r   r   r+   r   rU   r~   r6   r   
initializer   define_macror9   set_include_dirsr:   r;   undefine_macroset_librariesset_library_dirsr>   set_runtime_library_dirsr?   set_link_objectsbuild_extensions)rF   r   r~   valuemacros        rG   runzbuild_ext.run,  s    
 ,,.33LAJNN!!*">">"@"FBG$$Z%:%:; %]]LLLL**	
 	4==) 77d?t~~?MM$$T^^4
 77d?0MM&&'8#> (MM**4+<+<=;;"#{{ 8e**478::! 4,,U34>>%MM''7(MM**4+<+<=::!MM224::>(MM**4+<+<= 	rI   c                   t        |t              st        d      t        |      D ]  \  }}t        |t              rt        |t
              rt        |      dk7  rt        d      |\  }}t        j                  d|       t        |t              rt        j                  |      st        d      t        |t              st        d      t	        ||d         }dD ]#  }|j                  |      }|t        |||       % |j                  d
      |_        d|v rt        j                  d       |j                  d      }|rg |_        g |_        |D ]  }	t        |	t
              rt        |	      dv st        d      t        |	      dk(  r|j"                  j%                  |	d          Xt        |	      dk(  sg|j                   j%                  |	        |||<    y	)a  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)r9   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   )ru   listr   	enumerater   tuplelenr   warningrv   extension_name_rematchdictgetsetattrruntime_library_dirsdefine_macrosundef_macrosr{   )
rF   r4   r!   extext_name
build_infokeyvalr   r   s
             rG   check_extensions_listzbuild_ext.check_extensions_listr  s    *d+%L   
+ G	 FAs#y) c5)SX])4 
 $' HjKK: 	 x-2C2I2I(2S)< 
 j$/)8  Hj&;<C 
+ !nnS)?Cc*
+ (2~~g'>C$Z'WX  ^^H-F$&!#% # 8E&ue4Uv9M1W  5zQ((//a9Uq))0078  JqMOG	 rI   c                    | j                  | j                         g }| j                  D ]  }|j                  |j                          |S N)r   r4   r|   r   )rF   	filenamesr   s      rG   get_source_fileszbuild_ext.get_source_files  sF    ""4??3	 ?? 	*CS[[)	*rI   c                    | j                  | j                         | j                  D cg c]  }| j                  |j                         c}S c c}w r   )r   r4   get_ext_fullpathr~   rF   r   s     rG   get_outputszbuild_ext.get_outputs  s@     	""4??3
 <@??KC%%chh/KKKs   "Ac                    | j                  | j                         | j                  r| j                          y | j	                          y r   )r   r4   rD   _build_extensions_parallel_build_extensions_serialrE   s    rG   r   zbuild_ext.build_extensions  s3    ""4??3==++-))+rI   c                   | j                   }| j                   du rt        j                         }	 ddlm} || j                          y  |      5 }| j                  D cg c]  }|j                  | j                  |        }}t        | j                  |      D ]/  \  }}| j                  |      5  |j                          d d d        1 	 d d d        y # t
        $ r d }Y w xY wc c}w # 1 sw Y   [xY w# 1 sw Y   y xY w)NTr   )ThreadPoolExecutor)max_workers)rD   rU   	cpu_countconcurrent.futuresr   ImportErrorr   r4   submitbuild_extensionzip_filter_build_errorsresult)rF   workersr   executorr   futuresfuts          rG   r   z$build_ext._build_extensions_parallel  s    --==D llnG	= ?))+G4 	!FJoo?B 4 4c:G   9 !S..s3 !JJL! !!		! 	!  	G	! !	! 	!sG   C C:!#C)/C:3C.
C:C&%C&)C:.C73C::Dc                    | j                   D ]-  }| j                  |      5  | j                  |       d d d        / y # 1 sw Y   :xY wr   )r4   r   r   r   s     rG   r   z"build_ext._build_extensions_serial  sK    ?? 	*C**3/ *$$S)* *	** *s	   >A	c              #     K   	 d  y # t         t        t        f$ r8}|j                  s | j	                  d|j
                   d|        Y d }~y d }~ww xY ww)Nzbuilding extension "z
" failed: )r   r   r   optionalwarnr~   )rF   r   es      rG   r   zbuild_ext._filter_build_errors   sR     	F= 	F<<II,SXXJjDEE	Fs*   A	 AA.AAAAc                   |j                   }|t        |t        t        f      st	        d|j
                   d      t        |      }| j                  |j
                        }||j                  z   }| j                  s.t        ||d      s!t        j                  d|j
                         y t        j                  d|j
                         | j                  ||      }|j                  xs g }|j                   d d  }|j"                  D ]  }|j%                  |f        | j&                  j)                  || j*                  ||j,                  | j                  ||j                        }|d d  | _        |j0                  r|j3                  |j0                         |j4                  xs g }|j6                  xs | j&                  j9                  |      }	| j&                  j;                  ||| j=                  |      |j>                  |j@                  || jC                  |      | j                  | j*                  |	
       y )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   r9   r)   extra_postargsdepends)r<   r=   r   r   export_symbolsr)   r7   target_lang)"r   ru   r   r   r   r~   sortedr   r   r+   r	   r   r)   infoswig_sourcesr   r   r   r{   r@   compiler7   r9   _built_objectsr   r|   r   languagedetect_languagelink_shared_objectget_librariesr=   r   get_export_symbols)
rF   r   r   ext_pathr   
extra_argsr   r;   objectsr   s
             rG   r   zbuild_ext.build_extension	  s   ++?*WtUm"D%6sxxj A- -  /((2CKK'

k'8WEII<chhGHH.9
 ##GS1  ++1r
""1%%% 	$EMM5(#	$ --''))**%KK ( 
 &aj
 NN3,,-((.B
 <<I4==#@#@#I((((-))!$!9!9%2237**  	) 	
rI   c                   g }g }i }| j                   rt        j                  d       | j                   sd| j                  v sd|j                  v rd}nd}|D ]k  }t        j
                  j                  |      \  }}	|	dk(  r1|j                  |dz   |z          |j                  |       |d   ||<   [|j                  |       m |s|S | j                  xs | j                         }
|
dg}|j                  | j                         | j                   r|j                  d       | j                  s|j                  |j                         |D ]5  }||   }t        j                  d	||       | j                  |d
||gz          7 |S )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)rB   r   r   rC   rU   rV   splitextr{   rA   	find_swigr|   r   spawn)rF   r   	extensionnew_sourcesr   swig_targets
target_extsourcerN   r   rA   swig_cmdtargets                rG   r   zbuild_ext.swig_sourcesZ  sw     ==KKIJ MM$..()---JJ 	+F''**62KT3d{""4'>J#>?##F+'22V$""6*	+ yy,DNN,)$'==OOF# ~~OOI//0" 	:F!&)FHH(&&9JJx4"889	:
 rI   c                &   t         j                  dk(  ryt         j                  dk(  rNdD ]H  }t         j                  j                  d| d      }t         j                  j	                  |      sF|c S  yt        dt         j                   d      )	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.
        posixrA   r`   )z1.3z1.2z1.1zc:\swigzswig.exez;I don't know how to find (much less run) SWIG on platform '')rU   r~   rV   rW   isfiler   )rF   versfns      rG   r   zbuild_ext.find_swig  s    
 77gWW_ . "WW\\HTF"3Z@77>>"%I"
 "(MbggYVWX rI   c                   | j                  |      }|j                  d      }| j                  |d         }| j                  sMt	        j
                  j                  |dd |gz    }t        j
                  j                  | j                  |      S dj                  |dd       }| j                  d      }t        j
                  j                  |j                  |            }t        j
                  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).
        rL   r   Nr   build_py)get_ext_fullnamerw   get_ext_filenamer    rU   rV   rW   r5   r   abspathget_package_dir)rF   r   fullnamemodpathfilenamer8   r  package_dirs           rG   r   z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2rI   c                B    | j                   |S | j                   dz   |z   S )zSReturns the fullname of a given extension name.

        Adds the `package.` prefixrL   )r8   )rF   r   s     rG   r  zbuild_ext.get_ext_fullname  s'     <<O<<#%00rI   c                ~    ddl m} |j                  d      } |d      }t        j                  j
                  | |z   S )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   rQ   rL   
EXT_SUFFIX)rX   rQ   rw   rU   rV   rW   )rF   r   rQ   r   
ext_suffixs        rG   r  zbuild_ext.get_ext_filename  s7    
 	/>>#&#L1
ww||X&33rI   c                J   | j                  |      }	 |j                  d       d|z   }d|z   }||j
                  vr|j
                  j                  |       |j
                  S # t        $ r6 d|j                  d      j                  dd      j	                  d      z   }Y xw xY w)a  Return 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{   )rF   r   r~   r   initfunc_names        rG   r   z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                x    |j                   j                  d      }|d   dk(  rt        |      dk\  r|d   S |d   S )NrL   r   __init__r   )r~   rw   r   )rF   r   partss      rG   r  z%build_ext._get_module_name_for_symbol  s@     s#9
"s5zQ9RyrI   c                \   t         j                  dk(  rt               swddlm} t        | j                  |      sOd}| j                  r|dz   }|t         j                  dz	  t         j                  dz	  dz  fz  }|j                  |gz   S |j                  S dd	l
m} d
} |d      r`t        t         d      rd}nMt         j                  dk(  s
t               rd}n-dt        j                  v r |d      dk7  rd}n |d      dk(  rd}|r |d      }|j                  d|z   gz   S |j                  S )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).
        rd   r   )MSVCCompilerz
python%d%d_d         r  FrK   getandroidapilevelTrh   _PYTHON_HOST_PLATFORMANDROID_API_LEVELr   MACHDEP	LDVERSIONrj   )rS   rT   r   _msvccompilerr$  ru   r@   r)   
hexversionr<   rX   rQ   hasattrrU   environ)rF   r   r$  template	pythonlibrQ   link_libpython	ldversions           rG   r   zbuild_ext.get_libraries  s    <<7"8:4dmm\:'::'$H$NNb(^^r)T1( 	 }}	{22< }}) 3"N013 45%)N\\X-%)N,

:%&9:a?)-'	2h>)-*;7	}}9(<'===}}rI   )returnNone)r   rv   r6  rv   )r   r   r6  z	list[str])$__name__
__module____qualname__descriptionrU   rx   sep_byr   user_optionsr1   __annotations__r   r2   rH   staticmethodr[   r   r   r   r   r   r   r   r   
contextlibcontextmanagerr   r   r   r   r   r  r  r   r  r    rI   rG   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rI   r   )*__doc__
__future__r   r@  rU   rerS   collections.abcr   distutils._logr   siter   typingr   	_modifiedr	   	ccompilerr
   r   corer   errorsr   r   r   r   r   r   r   r   rX   r   r   r   utilr   r   r   r   r   r   rB  rI   rG   <module>rO     sm    #  	 	 
 $    # 4   " U U : : BJJUV F FrI   