
    ǆiu                     H   S r SSKrSSK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
Jr  SSKJrJrJrJrJr  SSKJr  \R(                  " S\5        \R,                  r\R0                  r\R4                  r\R8                  r\R<                  \R>                  \R@                  \RB                  4r"\RF                  S	:H  =(       a    \RH                  S
:  r%\%(       a  Sr&Sr'Sr(OSr&Sr'Sr(SSS.r) " S S5      r* " S S5      r+S r,S r-S r.S r/SS jr0\," 5       r1 " S S\
5      r2g) a  distutils.msvc9compiler

Contains MSVCCompiler, an implementation of the abstract CCompiler class
for the Microsoft Visual Studio 2008.

The module is compatible with VS 2005 and VS 2008. You can find legacy support
for older versions of VS in distutils.msvccompiler.
    N   )log)	CCompilergen_lib_options)CompileErrorDistutilsExecErrorDistutilsPlatformErrorLibError	LinkError)get_platformzmsvc9compiler is deprecated and slated to be removed in the future. Please discontinue use or file an issue with pypa/distutils describing your use case.win32l        z1Software\Wow6432Node\Microsoft\VisualStudio\%0.1fz5Software\Wow6432Node\Microsoft\Microsoft SDKs\Windowsz,Software\Wow6432Node\Microsoft\.NETFrameworkz%Software\Microsoft\VisualStudio\%0.1fz)Software\Microsoft\Microsoft SDKs\Windowsz Software\Microsoft\.NETFrameworkx86amd64r   z	win-amd64c                   p    \ rS rSrSrS r\" \5      rS r\" \5      rS r\" \5      rS r	\
" \	5      r	Srg)	RegJ   z-Helper class to read values from the registryc                 |    [          H(  nU R                  X15      nU(       d  M  X$;   d  M$  XB   s  $    [        U5      eN)HKEYSread_valuesKeyError)clspathkeybaseds        s/home/dmtnaga/Documents/work/airagagent/rag_env/lib/python3.13/site-packages/setuptools/_distutils/msvc9compiler.py	get_valueReg.get_valueM   s6    D+AqSXv  sm    c                      [        X5      n/ nSn  [        X55      nUR                  U5        US-  nM$  ! [         a     gf = f! [         a     U$ f = f)zReturn list of registry keys.Nr   r   )RegOpenKeyExRegError
RegEnumKeyappend)r   r   r   handleLiks          r   	read_keysReg.read_keysV   sx    	!$,F v) HHQKFA 	  		   	s    6 A 
AA
AAc                      [        X5      n0 nSn  [        X55      u  pgnUR                  5       nU R	                  U5      X@R	                  U5      '   US-  nMH  ! [         a     gf = f! [         a     U$ f = f)zPReturn dict of registry keys and values.

All names are converted to lowercase.
Nr   r   )r#   r$   RegEnumValuelowerconvert_mbcs)	r   r   r   r'   r   r)   namevaluetypes	            r   r   Reg.read_valuesi   s    
	!$,F $0$;!T ::<D(+(8(8(?At$%FA 	  		   s"   A A* 
A'&A'*
A87A8c                 ^    [        U SS 5      nUb   U" S5      n U $ U $ ! [         a     U $ f = f)Ndecodembcs)getattrUnicodeError)sdecs     r   r0   Reg.convert_mbcs   sG    a4(?K q   s    
,, N)__name__
__module____qualname____firstlineno____doc__r   classmethodr+   r   r0   staticmethod__static_attributes__r=   r!   r   r   r   J   sI    7 I&I" I&I* k*K  -Lr!   r   c                   ,    \ rS rSrS rS rS rS rSrg)MacroExpander   c                 P    0 U l         [        U-  U l        U R                  U5        g r   )macrosVS_BASEvsbaseload_macros)selfversions     r   __init__MacroExpander.__init__   s#    '!r!   c                 P    [         R                  X#5      U R                  SU S3'   g )Nz$())r   r   rJ   )rN   macror   r   s       r   	set_macroMacroExpander.set_macro   s!    %(]]4%=bqM"r!   c                 v   U R                  SU R                  S-   S5        U R                  SU R                  S-   S5        U R                  S[        S5         US:  a  U R                  S	[        S
5        O[        S
5      eUS:  a5  U R                  SU R                  S5        U R                  S[
        S5        g Sn[         HG  n [        X25      n[        US5      n[        R                  X2 SU 35      nUS   U R                  S'   MI     g ! [         a    [	        S5      ef = f! [         a     Mr  f = f)NVCInstallDir	\Setup\VC
productdirVSInstallDirz	\Setup\VSFrameworkDirinstallroot       @FrameworkSDKDirzsdkinstallrootv2.0a  Python was built with Visual Studio 2008;
extensions must be built with a compiler than can generate compatible binaries.
Visual Studio 2008 was not found on this system. If you have Cygwin installed,
you can try compiling with MingW32, by passing "-c mingw32" to setup.py.g      "@FrameworkVersionzclr versionWindowsSdkDircurrentinstallfolderz.Software\Microsoft\NET Framework Setup\Productr   \rO   z$(FrameworkVersion))rU   rL   NET_BASEr   r	   WINSDK_BASEr   r#   r$   r%   r   r   rJ   )rN   rO   pr   hr   r   s          r   rM   MacroExpander.load_macros   s+   ~t{{\'A<P~t{{\'A<P~x?	#~0(<PQ344 c>NN-t{{MJNN?K9OPAA$T-A !A&MM$3au656y\12   	(L 	    s$   D 7D 	D*D'*
D87D8c                 n    U R                   R                  5        H  u  p#UR                  X#5      nM     U$ r   )rJ   itemsreplace)rN   r:   r*   vs       r   subMacroExpander.sub   s-    KK%%'DA		!A (r!   )rJ   rL   N)	r>   r?   r@   rA   rP   rU   rM   rm   rE   r=   r!   r   rG   rG      s    "
>B>r!   rG   c                  8   Sn [         R                  R                  U 5      nUS:X  a  gU[        U 5      -   n[         R                  US R	                  SS5      u  p#[        USS 5      S-
  nUS:  a  US-  n[        US	S
 5      S-  nUS:X  a  SnUS:  a  XE-   $ g)zReturn the version of MSVC that was used to build Python.

For Python 2.3 and up, the version number is included in
sys.version.  For earlier versions, assume the compiler is MSVC 6.
zMSC v.   N r            g      $@r   )sysrO   findlensplitint)prefixr)   r:   restmajorVersionminorVersions         r   get_build_versionr      s     F ABw	CKAkk!"o##C+GAq"v;?Lrq1v;%Lqq**r!   c                     / nU  H:  n[         R                  R                  U5      nX1;  d  M)  UR                  U5        M<     U$ )zfReturn a list of normalized paths with duplicates removed.

The current order of paths is maintained.
)osr   normpathr&   )pathsreduced_pathsrf   nps       r   normalize_and_reduce_pathsr      sC     MWWa "  $	 
 r!   c                     U R                  [        R                  5      n/ nU H  nX2;  d  M
  UR                  U5        M     [        R                  R	                  U5      nU$ )z3Remove duplicate values of an environment variable.)rz   r   pathsepr&   join)variableoldListnewListr)   newVariables        r   removeDuplicatesr      sO    nnRZZ(GGNN1  **//'*Kr!   c                    [         U -  n [        R                  U S3S5      nU(       a%  [        R                  R                  U5      (       Gd  SU S S3n[        R                  R                  US5      nU(       a  [        R                  R                  U5      (       a  [        R                  R                  U[        R                  [        R                  S5      n[        R                  R                  U5      n[        R                  R                  U5      (       d  [        R
                  " U S	35        gO[        R
                  " S
U S35        U(       d  [        R
                  " S5        g[        R                  R                  US5      n[        R                  R                  U5      (       a  U$ [        R
                  " S5        g! [         a    [        R
                  " S5        Sn GNf = f)zFind the vcvarsall.bat file

At first it tries to find the productdir of VS 2008 in the registry. If
that fails it falls back to the VS90COMNTOOLS env var.
rY   rZ   z%Unable to find productdir in registryNVSz0.0f
0COMNTOOLSVCz is not a valid directoryzEnv var z is not set or invalidzNo productdir foundzvcvarsall.batUnable to find vcvarsall.bat)rK   r   r   r   r   debugr   r   isdirenvirongetr   pardirabspathisfile)rO   rL   rZ   toolskeytoolsdir	vcvarsalls         r   find_vcvarsallr      sf    wF]]vhi#8,G

 RWW]]:66~Z0::>>(D1h//h		299dKJ4J77==,,		ZL(ABC - II
*@AB		'(Z9I	ww~~i  II,-/  		9:
s   G "G98G9c                 4   [        U 5      n1 Skn0 nUc  [        S5      e[        R                  " SX5        [        R
                  " SU SU S3[        R                  [        R                  S9n UR                  5       u  pgUR                  5       S	:w  a  [        UR                  S
5      5      eUR                  S
5      nUR                  S5       H  n[        R                  U5      nSU;  a  M   UR                  5       nUR                  SS5      u  pU	R                  5       n	X;   d  M[  U
R                  [         R"                  5      (       a  U
SS n
[%        U
5      XI'   M     UR&                  R)                  5         UR*                  R)                  5         [-        U5      [-        U5      :w  a+  [/        [1        [3        UR5                  5       5      5      5      eU$ ! UR&                  R)                  5         UR*                  R)                  5         f = f)z?Launch vcvarsall.bat and read the settings from its environment>   libr   includelibpathNr   z'Calling 'vcvarsall.bat %s' (version=%s)"z" z & set)stdoutstderrr   r7   
=r   rp   )r   r	   r   r   
subprocessPopenPIPEcommunicatewaitr6   rz   r   r0   stripr/   endswithr   r   r   r   closer   ry   
ValueErrorstrlistkeys)rO   archr   interestingresultpopenr   r   liner   r2   s              r   query_vcvarsallr     s   w'I7KF$%CDDII7G
I;bf%E
**,::<1(v)>??v&LL&D##D)D$::<DC+JC))+C!>>"**--!#2JE.u5 ' 	
6{c+&&T&++-0122M 	s   1B9G! .:G! !6Hc                     ^  \ rS rSrSrSr0 rS/r/ SQrS/r	S/r
\\-   \	-   \
-   rSrS	rS
rSrS=rrSrSU 4S jjrSS jrSS jr       S S jr S!S jr          S"S jrS rS rS rS rS rS rS#S jrS r Sr!U =r"$ )$MSVCCompileri@  zpConcrete class that implements an interface to Microsoft Visual C++,
as defined by the CCompiler abstract class.msvcz.c)z.ccz.cppz.cxx.rcz.mcz.resz.objz.libz.dllz%s%sz.exec                    > [         TU ]  XU5        [        U l        SU l        / U l        S U l        S U l        SU l        g )NzSoftware\Microsoft\VisualStudioF)	superrP   VERSION_MSVCCompiler__version_MSVCCompiler__root_MSVCCompiler__paths	plat_name_MSVCCompiler__archinitialized)rN   verbosedry_runforce	__class__s       r   rP   MSVCCompiler.__init__]  s=    51 8 r!   c                    U R                   (       a   S5       eU R                  S:  a  [        SU R                  S S35      eUc
  [        5       nSnX;  a  [        SU 35      eS[        R
                  ;   aO  S	[        R
                  ;   a;  U R                  S
5      (       a%  S
U l        SU l        SU l	        SU l
        SU l        GO;U[        5       S4;   a
  [        U   nO[        [        5          S-   [        U   -   n[        [        U5      nUS   R                  [        R                   5      U l        US   [        R
                  S'   US   [        R
                  S'   [%        U R"                  5      S:X  a  [        SU R&                   S35      eU R                  S
5      U l        U R                  S5      U l        U R                  S5      U l	        U R                  S5      U l
        U R                  S5      U l         [        R
                  S   R                  S5       H  nU R"                  R)                  U5        M      [-        U R"                  5      U l        SR/                  U R"                  5      [        R
                  S'   S U l        U R2                  S:X  a  / SQU l        / SQU l        O/ SQU l        / SQU l        / SQU l        U R                  S:  a	  / SQU l        S /U l        S!U l         g ! [*         a     Nf = f)"Nzdon't init multiple timesr^   zVC z0.1fz  is not supported by this moduler   z--plat-name must be one of DISTUTILS_USE_SDKMSSdkzcl.exezlink.exezlib.exezrc.exezmc.exer   _r   r   r   r   zPython was built with z`, and extensions need to be built with the same version of the compiler, but it isn't installed.;r   )/nologo/O2/MD/W3/DNDEBUG)r   /Od/MDdr   /Z7/D_DEBUG)r   r   r   r   /GS-r   )r   r   r   r   r   r   r   )/DLLr   z/INCREMENTAL:NO   )r   r   z/INCREMENTAL:noz/DEBUGr   T)r   r   r	   r   r   r   find_execclinkerr   rcmcPLAT_TO_VCVARSr   r   rz   r   r   ry   _MSVCCompiler__productr&   r   r   r   preprocess_optionsr   compile_optionscompile_options_debugldflags_sharedldflags_shared_debugldflags_static)rN   r   ok_plats	plat_specvc_envrf   s         r   
initializeMSVCCompiler.initializeh  s   ##@%@@#>>C(dnnT**JK  $I'$(+Fxj)QRR  2::-2::%h'' DG$DK DHDGDG \^W55*95	 #<>2S8>);TT  %Wi8F!&>//

;DL &uBJJu$*9$5BJJy!4<< A%,,T^^,< =G G  mmH-DG--
3DK}}Y/DHmmH-DGmmH-DG
	ZZ'--c2##A& 3 2$,,? XXdll3

6"&;;%#OD *D& $XD *D& E>>Q(XD%(kE  		s   AK< <
L	L	c                 "   Uc  Sn/ nU GH  n[         R                  R                  U5      u  pg[         R                  R                  U5      S   nU[         R                  R	                  U5      S  nXpR
                  ;  a  [        SU 35      eU(       a  [         R                  R                  U5      nXpR                  ;   a=  UR                  [         R                  R                  X6U R                  -   5      5        M  XpR                  ;   a>  UR                  [         R                  R                  X6U R                  -   5      5        GME  UR                  [         R                  R                  X6U R                  -   5      5        GM     U$ )N r   Don't know how to compile )r   r   splitext
splitdriveisabssrc_extensionsr   basename_rc_extensionsr&   r   res_extension_mc_extensionsobj_extension)rN   source_filenames	strip_dir
output_dir	obj_namessrc_namer   exts           r   object_filenamesMSVCCompiler.object_filenames  s1    J	(H''**84KT77%%d+A.Dd+-.D--- #%?z#JKKww''-)))  jASAS:S!TU+++  jASAS:S!TU  jASAS:S!TU! )" r!   c	                    U R                   (       d  U R                  5         U R                  X#XAX5      n	U	u  p:p{nU=(       d    / nUR                  S5        U(       a  UR	                  U R
                  5        OUR	                  U R                  5        U
 GH  n X   u  nnU(       a  [        R                  R                  U5      nUU R                  ;   a  SU-   nGOkUU R                  ;   a  SU-   nGOTUU R                  ;   a1  UnSU-   n U R                  U R                  /U-   U/-   U/-   5        M  UU R$                  ;   a  [        R                  R'                  U5      n[        R                  R'                  U5      n U R                  U R(                  /SUSU/-   U/-   5        [        R                  R+                  [        R                  R-                  U5      5      u  nn[        R                  R/                  UUS-   5      nU R                  U R                  /SU-   /-   U/-   5        GM  [#        SU S	U 35      eS
U-   n U R                  U R0                  /U-   U-   UU/-   U-   5        GM     U
$ ! [         a     GM  f = f! [          a  n[#        U5      eS nAff = f! [          a  n[#        U5      eS nAff = f! [          a  n[#        U5      eS nAff = f)Nz/cz/Tcz/Tpz/foz-hz-rr   r   z to z/Fo)r   r   _setup_compiler&   extendr   r   r   r   r   r   _c_extensions_cpp_extensionsr   spawnr   r   r   r   dirnamer   r   r   r   r   )rN   sourcesr   rJ   include_dirsr   extra_preargsextra_postargsdependscompile_infoobjectspp_optsbuildcompile_optsobjsrcr  	input_opt
output_optmsgh_dirrc_dirr   r   rc_files                            r   compileMSVCCompiler.compile  s    OO**w
 ;G7%$*D! : :; 4 45C :S  ggooc*d(((!CK	,,,!CK	+++	"S[
,JJy72j\AYKOP +++ ,-	,JJyD%v+FF#NO gg..rww/?/?/DEGD! ggll64%<@GJJyECK=8G9DE  #%?uD#NOOJ	(

WWI"# !*-. %	%o B }  $ * ,&s++,2 * ,&s++,  & ("3''(s[   J'JB0J1*K
JJ
J.J))J.1
K;KK
K(K##K(c                    U R                   (       d  U R                  5         U R                  X5      u  pU R                  X#S9nU R	                  X5      (       a2  USU-   /-   nU(       a    U R                  U R                  /U-   5        g [        R                  " SU5        g ! [         a  n[        U5      eS nAff = f)N)r   /OUT:skipping %s (up-to-date))r   r   _fix_object_argslibrary_filename
_need_linkr	  r   r   r
   r   r   )	rN   r  output_libnamer   r   target_langoutput_filenamelib_argsr  s	            r   create_static_libMSVCCompiler.create_static_libD  s     OO $ 5 5g J///V??744'O";!<<H$

DHH:01 II0/B & $sm#$s   ,B$ $
B>.B99B>c                    U R                   (       d  U R                  5         U R                  X$5      u  p$U R                  XVU5      nUu  pVnU(       a  U R	                  S[        U5      -   5        [        XXu5      nUb  [        R                  R                  XC5      nU R                  X#5      (       Ga  U[        R                  :X  a'  U	(       a  U R                  SS  nO0U R                  SS  nO U	(       a  U R                  nOU R                  n/ nU=(       d    /  H  nUR                  SU-   5        M     UU-   U-   U-   SU-   /-   n[        R                  R!                  US   5      nUb  [        R                  R#                  [        R                  R%                  U5      5      u  nn[        R                  R                  XR'                  U5      5      nUR                  SU-   5        U R)                  X<U5        U
(       a  U
US S& U(       a  UR+                  U5        U R-                  [        R                  R!                  U5      5         U R/                  U R0                  /U-   5        U R7                  UU5      nUb%  Uu  nnSU SU 3n U R/                  S	S
SUU/5        g g [8        R:                  " SU5        g ! [2         a  n[5        U5      eS nAff = f! [2         a  n[5        U5      eS nAff = f)Nz5I don't know what to do with 'runtime_library_dirs': r   z/EXPORT:r   r   z/IMPLIB:z-outputresource:r   zmt.exez-nologoz	-manifestr!  )r   r   r"  _fix_lib_argswarnr   r   r   r   r   r$  r   
EXECUTABLEr   r   r&   r
  r   r   r#  manifest_setup_ldargsr  mkpathr	  r   r   r   manifest_get_embed_infor   r   )rN   target_descr  r'  r   	librarieslibrary_dirsruntime_library_dirsexport_symbolsr   r  r  
build_tempr&  
fixed_argslib_optsldflagsexport_optssymld_argsdll_namedll_extimplib_filer  mfinfo
mffilenamemfidout_args                               r   linkMSVCCompiler.linkW  s     OO $ 5 5g J''	AUV
:D7"6IIG*+,
 #47KW! ggll:GO??744i222"77;G"11!"5G"77G"11GK%++"":#34 , ("[07:g>W=XX  4J)&(gg&6&6GG$$_5'#7 !ggll:7L7LX7VWzK78&&GL+~.KK89%

DKK=723 11+wGF!#) 
D,_,=QtfE)JJ)[*gVW	 " II0/B# & %n$% * )#C.()s0   K K$ 
K!KK!$
K>.K99K>c                     [         R                  R                  U[         R                  R                  U5      S-   5      nUR	                  SU-   5        g )Nz	.manifest/MANIFESTFILE:)r   r   r   r   r&   )rN   r'  r7  r=  temp_manifests        r   r/  "MSVCCompiler.manifest_setup_ldargs  sC     ((9KG
 	'-78r!   c                     U H0  nUR                  S5      (       d  M  UR                  SS5      S   n  O   g U[        R                  :X  a  SnOSnU R	                  U5      nUc  g XE4$ )NrH  :r   ru   )
startswithrz   r   r.  _remove_visual_c_ref)rN   r2  r=  argrI  rC  s         r   r1  $MSVCCompiler.manifest_get_embed_info  sy    
 C~~.// #		#q 1! 4  )... D D 55mDM ""r!   c                 X    [        U5      n UR                  5       nUR                  5         [        R                  " S[        R
                  5      n[        R                  " USU5      nSn[        R                  " USU5      n[        R                  " S[        R
                  5      n[        R                  " XC5      c  g [        US5      n UR                  U5        UUR                  5         $ ! UR                  5         f = f! UR                  5         f = f! [         a     g f = f)NzU<assemblyIdentity.*?name=("|')Microsoft\.VC\d{2}\.CRT("|').*?(/>|</assemblyIdentity>)r   z*<dependentAssembly>\s*</dependentAssembly>zI<assemblyIdentity.*?name=(?:"|')(.+?)(?:"|').*?(?:/>|</assemblyIdentity>)w)
openreadr   rer  DOTALLrm   searchwriteOSError)rN   manifest_file
manifest_fmanifest_bufpatterns        r   rN  !MSVCCompiler._remove_visual_c_ref  s   '	 m,J#)0  "jjD		G
 66'2|<LCG66'2|<L jj5		G
 yy/7mS1J#  .$  "1   "0   " 		sF   D C2 B#D D D !D 2DD DD 
D)(D)c                     SU-   $ )Nz	/LIBPATH:r=   rN   dirs     r   library_dir_optionMSVCCompiler.library_dir_option  s    S  r!   c                     [        S5      e)Nz<don't know how to set runtime library search path for MSVC++)r	   r`  s     r   runtime_library_dir_option'MSVCCompiler.runtime_library_dir_option
  s    $J
 	
r!   c                 $    U R                  U5      $ r   )r#  )rN   r   s     r   library_optionMSVCCompiler.library_option  s    $$S))r!   c                     U(       a  US-   U/nOU/nU Hd  nU H[  n[         R                  R                  XPR                  U5      5      n[         R                  R	                  U5      (       d  MW  Us  s  $    Mf     g )N_d)r   r   r   r#  exists)rN   dirsr   r   	try_namesra  r1   libfiles           r   find_library_fileMSVCCompiler.find_library_file  sj     tS)IIC!'',,s,A,A$,GH77>>'**"N "  r!   c                    U R                    Hh  n[        R                  R                  [        R                  R	                  U5      U5      n[        R                  R                  U5      (       d  Mf  Us  $    [        R                  S   R                  S5       Hh  n[        R                  R                  [        R                  R	                  U5      U5      n[        R                  R                  U5      (       d  Mf  Us  $    U$ )a\  Return path to an MSVC executable program.

Tries to find the program in several places: first, one of the
MSVC program search paths from the registry; next, the directories
in the PATH environment variable.  If any of those work, return an
absolute path that is known to exist.  If none of them work, just
return the original program name, 'exe'.
Pathr   )r   r   r   r   r   r   r   rz   )rN   exerf   fns       r   r   MSVCCompiler.find_exe$  s     Abggooa0#6Bww~~b!!	  F#))#.Abggooa0#6Bww~~b!!	 /
 
r!   )__arch__paths__root	__versionr   r   r   r   r   r   r   r   r   r   r   r   r   )FFFr   )Fr   )NNNFNNN)NFN)
NNNNNFNNNN)F)#r>   r?   r@   rA   rB   compiler_typeexecutablesr  r  r   r   r   r   r   static_lib_extensionshared_lib_extensionstatic_lib_formatshared_lib_formatexe_extensionrP   r   r  r  r)  rE  r/  r1  rN  rb  re  rh  rp  r   rE   __classcell__)r   s   @r   r   r   @  s   3 M K FM-OWNWN #_4~EVNMM!!,22)M	!c N8 Zz RVC0 !\C|
9#0(\!

*$ r!   r   )r   )3rB   r   rU  r   rw   warningswinreg_logr   	ccompilerr   r   errorsr   r   r	   r
   r   utilr   r-  DeprecationWarning	OpenKeyExr#   EnumKeyr%   	EnumValuer.   errorr$   
HKEY_USERSHKEY_CURRENT_USERHKEY_LOCAL_MACHINEHKEY_CLASSES_ROOTr   platformmaxsizeNATIVE_WIN64rK   re   rd   r   r   rG   r   r   r   r   r   r   r   r=   r!   r   <module>r     s:   
 	  
    1   4 	 ^^
<< 


		 ||w&>3;;+> CGJK>H6G>K2H ?. ?.D+ +\4 F'V 
x9 xr!   