
    IgL                     6   d Z ddlZddlZddlZddlZddlmZ  ej        e          5  ddl	Z	ddd           n# 1 swxY w Y   ddl
mZmZmZmZmZ ddlmZmZ ddlmZ ddlmZ ddlmZ d	 Zd
 ZdddddZd Zd ZddZdddddZ G d de          Z dS )a  distutils._msvccompiler

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

The module is compatible with VS 2015 and later. You can find legacy support
for older versions in distutils.msvc9compiler and distutils.msvccompiler.
    N   )DistutilsExecErrorDistutilsPlatformErrorCompileErrorLibError	LinkError)	CCompilergen_lib_options)log)get_platform)countc                  j   	 t          j        t           j        dt           j        t           j        z            } n%# t
          $ r t          j        d           Y dS w xY wd}d }| 5  t                      D ]}	 t          j	        | |          \  }}}n# t
          $ r Y  n{w xY w|rt|t           j
        k    rdt          j                            |          rE	 t          t          |                    }n# t           t"          f$ r Y w xY w|dk    r
||k    r||}}d d d            n# 1 swxY w Y   ||fS )Nz'Software\Microsoft\VisualStudio\SxS\VC7)accesszVisual C++ is not registeredNNr      )winreg	OpenKeyExHKEY_LOCAL_MACHINEKEY_READKEY_WOW64_32KEYOSErrorr   debugr   	EnumValueREG_SZospathisdirintfloat
ValueError	TypeError)keybest_versionbest_dirivvc_dirvtversions           _/var/www/html/4nations/venv/lib/python3.11/site-packages/setuptools/_distutils/_msvccompiler.py_find_vc2015r+   '   s   %6?V%;;
 
 

    	0111zz LH	 = = 	= 	=A & 0a 8 8622    =R6=((RW]]6-B-B(!%((mmGG"I.   Hb==W|%;%;-4f(L= = = = = = = = = = = = = = = !!si   8; AA&D&8BD&
B D&B  4D&C21D&2DD&DD&&D*-D*c                     t           j                            d          pt           j                            d          } | sdS 	 t          j        t           j                            | ddd          ddd	d
ddddg	dd                                          }n## t          j        t          t          f$ r Y dS w xY wt           j                            |ddd          }t           j                            |          rd|fS dS )aJ  Returns "15, path" based on the result of invoking vswhere.exe
    If no install is found, returns "None, None"

    The version is returned to avoid unnecessarily changing the function
    result. It may be ignored when the path is not None.

    If vswhere.exe is not available, by definition, VS 2017 is not
    installed.
    zProgramFiles(x86)ProgramFilesr   zMicrosoft Visual Studio	Installerzvswhere.exez-latestz-prereleasez	-requiresz1Microsoft.VisualStudio.Component.VC.Tools.x86.x64z	-propertyinstallationPathz	-products*mbcsstrict)encodingerrorsVC	AuxiliaryBuild   )r   environget
subprocesscheck_outputr   joinstripCalledProcessErrorr   UnicodeDecodeErrorr   )rootr   s     r*   _find_vc2017rB   D   s    :>>-..P"*..2P2PD z&3[-  C" 
 
 
  %''! 	" )74FG   zz 7<<dK99D	w}}T 4x:s   AB B76B7x86x64armarm64)rC   	x86_amd64x86_arm	x86_arm64c                 .   t                      \  }}|st                      \  }}|st          j        d           dS t          j                            |d          }t          j                            |          st          j        d|           dS |d fS )Nz$No suitable Visual C++ version foundr   zvcvarsall.batz%s cannot be found)rB   r+   r   r   r   r   r=   isfile)	plat_spec_r$   r#   	vcvarsalls        r*   _find_vcvarsallrO   v   s    ..KAx 0!-h 	8999zX77I7>>)$$ 	&	222zd?    c                    t          j        d          r(d t           j                                        D             S t	          |           \  }}|st          d          	 t          j        d| d|  dt          j                  	                    dd	
          }nG# t          j
        $ r5}t          j        |j                   t          d|j                   d }~ww xY wd d |                                D             D             }|S )NDISTUTILS_USE_SDKc                 >    i | ]\  }}|                                 |S  lower).0r"   values      r*   
<dictcomp>z_get_vc_env.<locals>.<dictcomp>   s&    HHHzsE		UHHHrP   zUnable to find vcvarsall.batzcmd /u /c "z" z && set)stderrzutf-16lereplace)r4   zError executing c                 H    i | ]\  }}}||
|                                 | S rT   rU   )rW   r"   rM   rX   s       r*   rY   z_get_vc_env.<locals>.<dictcomp>   sH       CE 		U  rP   c              3   @   K   | ]}|                     d           V  dS )=N)	partition)rW   lines     r*   	<genexpr>z_get_vc_env.<locals>.<genexpr>   s.      OOddnnS11OOOOOOrP   )r   getenvr9   itemsrO   r   r;   r<   STDOUTdecoder?   r   erroroutputcmd
splitlines)rL   rN   rM   outexcenvs         r*   _get_vc_envrm      sB   	y$%% IHHRZ5E5E5G5GHHHH"9--LIq E$%CDDDC%9)99y999$
 
 
 &I&
.
. 	 ( C C C	#*$%A%A%ABBBC OOcnn>N>NOOO  C Js   !<B C"-0CC"c                 6   |s1t          j        d                              t           j                  }|D ]b}t           j                            t           j                            |          |           }t           j                            |          r|c S c| S )at  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'.
    r   )r   rb   splitpathsepr   r=   abspathrK   )exepathspfns       r*   	_find_exerv      s      4	&!!''
33  W\\"'//!,,c227>>" 	III	JrP   rG   rH   rI   )win32z	win-amd64z	win-arm32z	win-arm64c                   J    e Zd ZdZdZi ZdgZg dZdgZdgZ	eez   ez   e	z   Z
dZdZd	Zd
ZdxZZdZd fd	Zed             Zed             ZddZe fd            Z	 	 	 	 	 	 	 ddZ	 d dZ	 	 	 	 	 	 	 	 	 	 d!dZ fdZej         fd            Z d Z!d Z"d Z#d"dZ$ xZ%S )#MSVCCompilerztConcrete 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.exer   c                 j    t                                          |||           d | _        d| _        d S )NF)super__init__	plat_nameinitialized)selfverbosedry_runforce	__class__s       r*   r~   zMSVCCompiler.__init__   s4    '5111 rP   c                     |                      |                    dd                    | _        |                      |                    dd                    | _        dS )z3
        Set class-level include/lib dirs.
        include libN)_parse_pathr:   include_dirslibrary_dirs)clsvc_envs     r*   
_configurezMSVCCompiler._configure   sN    
 ??6::i+D+DEE??6::eR+@+@AArP   c                 T    d |                      t          j                  D             S )Nc                 P    g | ]#}||                     t          j                  $S rT   )rstripr   sep)rW   dirs     r*   
<listcomp>z,MSVCCompiler._parse_path.<locals>.<listcomp>   s+    KKKssK

26""KKKrP   )ro   r   rp   )vals    r*   r   zMSVCCompiler._parse_path   s$    KKcii
.C.CKKKKrP   Nc                    | j         r
J d            |t                      }|t          vr$t          dt	          t                               t          |         }t          |          }|st          d          |                     |           |                    dd          | _        | j        	                    t          j                  }t          d|          | _        t          d|          | _        t          d|          | _        t          d	|          | _        t          d
|          | _        t          d|          | _        d | _        g d| _        g d| _        g d}g d}g |d| _        g |d| _        g |ddd| _        g |ddd| _        g || _        g || _        t8          j        d f| j        t8          j        df| j        t8          j        df| j        t8          j        d f| j        t8          j        df| j        t8          j        df| j        t8          j        d f| j        t8          j        df| j        t8          j        df| j        i	| _         d| _         d S )Nzdon't init multiple timesz--plat-name must be one of z7Unable to find a compatible Visual Studio installation.r   r   zcl.exezlink.exezlib.exezrc.exezmc.exezmt.exe)/nologoz/O2/W3z/GLz/DNDEBUGz/MD)r   z/Odz/MDdz/Zir   z/D_DEBUG)r   /INCREMENTAL:NO/LTCG)r   r   r   z/DEBUG:FULLz/MANIFEST:EMBED,ID=1z/DLLz/MANIFEST:EMBED,ID=2z/MANIFESTUAC:NOFT)!r   r   PLAT_TO_VCVARSr   tuplerm   r   r:   _pathsro   r   rp   rv   cclinkerr   rcmcmtpreprocess_optionscompile_optionscompile_options_debugldflags_exeldflags_exe_debugldflags_sharedldflags_shared_debugldflags_staticldflags_static_debugr	   
EXECUTABLESHARED_OBJECTSHARED_LIBRARY_ldflags)r   r   rL   r   rs   ldflagsldflags_debugs          r*   
initializezMSVCCompiler.initialize   s   #@@%@@@@$IN**(EeN.C.CEE  
 #9-	Y'' 	(L   	jj,,!!"*--He,,
E22Y..He,,He,,He,,"&  SRR&
 &
 &
" :99NNN=W=&<=!I=!I2H!I


 #
 	
%
%
%
 #%
 	%
! )j$4m$4! !4($*:!5)4+;!4($*@$d+T-@$e,d.A$d+T-F%t,d.A%u-t/B%t,d.G

  rP   c                 f     i t                      j         fd j         j        z   D             S )Nc                      i | ]
}|j         S rT   )res_extension)rW   extr   s     r*   rY   z/MSVCCompiler.out_extensions.<locals>.<dictcomp>E  s.        T'  rP   )r}   out_extensions_rc_extensions_mc_extensions)r   r   s   `r*   r   zMSVCCompiler.out_extensionsA  sS    
gg$
   .1DD  
 	
rP   c	           	      $   | j         s|                                  |                     ||||||          }	|	\  }}
}}}|pg }|                    d           |r|                    | j                   n|                    | j                   d}|
D ]|}	 ||         \  }}n# t          $ r Y w xY w|rt          j	        
                    |          }|| j        v rd|z   }n|| j        v r	d|z   }d}n{|| j        v rN|}d|z   }	 |                     | j        g|z   ||gz              n!# t           $ r}t#          |          d }~ww xY w|| j        v rt          j	                            |          }t          j	                            |          }	 |                     | j        d|d||g           t          j	                            t          j	                            |                    \  }}t          j	                            ||d	z             }|                     | j        d|z   |g           n!# t           $ r}t#          |          d }~ww xY wt#          d
| d|           | j        g|z   |z   }|r|                    d           |                    |           |                    d|z              |                    |           	 |                     |           ]# t           $ r}t#          |          d }~ww xY w|
S )Nz/cFz/Tcz/TpTz/foz-hz-rr{   zDon't know how to compile z to z/EHscz/Fo)r   r   _setup_compileappendextendr   r   KeyErrorr   r   rq   _c_extensions_cpp_extensionsr   spawnr   r   r   r   dirnamer   splitextbasenamer=   r   )r   sources
output_dirmacrosr   r   extra_preargsextra_postargsdependscompile_infoobjectspp_optsbuildcompile_optsadd_cpp_optsobjsrcr   	input_opt
output_optmsgh_dirrc_dirbaserM   rc_fileargss                              r*   compilezMSVCCompiler.compileK  s     	OO**gw
 
 ;G7%$*D!!! 	6 :;;;; 4555 @	( @	(C :SS    + gooc**d(((!CK		,,,!CK	#+++	"S[
,JJy72j)5LLMMMM) , , ,&s+++,+++ ,,--	,JJudFCHIII g..rw/?/?/D/DEEGD! gll64%<@@GJJg>????) , , ,&s+++, ##N#N#N#N#NOOOG9|+g5D %G$$$KK	"""KK$$$KK'''(

4    % ( ( ("3'''( s[   B""
B/.B/#D**
E4EEB"H88
IIIK//
L9LLc                    | j         s|                                  |                     ||          \  }}|                     ||          }|                     ||          r||d|z   gz   }|r	 	 t          j        d| j        d                    |                     | 	                    | j        g|z              d S # t          $ r}t          |          d }~ww xY wt          j        d|           d S )N)r   /OUT:Executing "%s" %s skipping %s (up-to-date))r   r   _fix_object_argslibrary_filename
_need_linkr   r   r   r=   r   r   r   )	r   r   output_libnamer   r   target_langoutput_filenamelib_argsr   s	            r*   create_static_libzMSVCCompiler.create_static_lib  s     	OO"33GZHH//:/VV??7O44 
	C'O";!<<H $	-tx(9K9KLLL

DH:011111% $ $ $smm#$ I0/BBBBBs   /AB= =
CCCc                 8   | j         s|                                  |                     ||          \  }}|                     |||          }|\  }}}|r%|                     dt          |          z              t          | |||          }| t          j        	                    ||          }| 
                    ||          r| j        ||	f         }d |pg D             }||z   |z   |z   d|z   gz   }t          j                            |d                   }|t          j                            t          j                            |                    \  }}t          j        	                    ||                     |                    }|                    d|z              |
r|
|d d<   |r|                    |           t          j                            t          j                            |                    }|                     |           	 t)          j        d| j        d	                    |                     |                     | j        g|z              d S # t0          $ r}t3          |          d }~ww xY wt)          j        d|           d S )	Nz5I don't know what to do with 'runtime_library_dirs': c                     g | ]}d |z   S )z/EXPORT:rT   )rW   syms     r*   r   z%MSVCCompiler.link.<locals>.<listcomp>  s    NNN:+NNNrP   r   r   z/IMPLIB:r   r   r   )r   r   r   _fix_lib_argswarnstrr
   r   r   r=   r   r   r   r   r   r   r   r   rq   mkpathr   r   r   r   r   r   )r   target_descr   r   r   	librariesr   runtime_library_dirsexport_symbolsr   r   r   
build_tempr   
fixed_argslib_optsr   export_optsld_argsdll_namedll_extimplib_filer   s                          r*   linkzMSVCCompiler.link  s   "  	OO"33GZHH''	<AUVV
8B5	<!5 	IIG*++,  
 #47KYWW! gll:GGO??7O44 #	CmK$67GNN8L"NNNK ("[07:g>W=XX  44J)&(g&6&6G$$_55' '#7 !gll:t7L7LX7V7VWWzK7888 ,+ /~...)I)IJJJKK
###%	-t{CHHW<M<MNNN

DK=7233333% % % %nn$% I0/BBBBBs   AI$ $
J.I==Jc                     t          t          j        | j                  }|                     ||          5 }t                                          ||          cd d d            S # 1 swxY w Y   |j        S )N)PATH)rl   )dictr   r9   r   _fallback_spawnr}   r   rX   )r   rh   rl   fallbackr   s       r*   r   zMSVCCompiler.spawn  s    2:DK000!!#s++ 	/x77==#=..	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/~s   #A((A,/A,c              #     K    t          ddi                       }	 |V  dS # t          $ r}dt          |          vr Y d}~nd}~ww xY wt          j        d           t
          j                            d|          5  t                      	                    |          |_
        ddd           dS # 1 swxY w Y   dS )z
        Discovered in pypa/distutils#15, some tools monkeypatch the compiler,
        so the 'env' kwarg causes a TypeError. Detect this condition and
        restore the legacy, unsafe behavior.
        BagrT   Nz!unexpected keyword argument 'env'z>Fallback spawn triggered. Please update distutils monkeypatch.z
os.environ)typer!   r   warningsr   mockpatchr   r}   r   rX   )r   rh   rl   bagrk   r   s        r*   r  zMSVCCompiler._fallback_spawn  s"      "d5"b!!##	III
 F	  	 	 	2#c((BB CBBBB	
 	VWWWZ__\3// 	+ 	+c**CI	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+s&   $ 
A
AA
'B55B9<B9c                     d|z   S )Nz	/LIBPATH:rT   r   r   s     r*   library_dir_optionzMSVCCompiler.library_dir_option#  s    S  rP   c                      t          d          )Nz:don't know how to set runtime library search path for MSVC)r   r  s     r*   runtime_library_dir_optionz'MSVCCompiler.runtime_library_dir_option&  s    $H
 
 	
rP   c                 ,    |                      |          S N)r   )r   r   s     r*   library_optionzMSVCCompiler.library_option+  s    $$S)))rP   c                     |r|dz   |g}n|g}|D ]_}|D ]Z}t           j                            ||                     |                    }t           j                            |          r|c c S [`d S )N_d)r   r   r=   r   rK   )r   dirsr   r   	try_namesr   namelibfiles           r*   find_library_filezMSVCCompiler.find_library_file.  s      	tS)III 	 	C! # #',,sD,A,A$,G,GHH7>>'** #"NNNNN## 4rP   )r   r   r   r  )NNNr   NNN)Nr   N)
NNNNNr   NNNN)r   )&__name__
__module____qualname____doc__compiler_typeexecutablesr   r   r   r   src_extensionsr   obj_extensionstatic_lib_extensionshared_lib_extensionstatic_lib_formatshared_lib_formatexe_extensionr~   classmethodr   staticmethodr   r   propertyr   r   r   r   r   
contextlibcontextmanagerr  r  r  r  r  __classcell__)r   s   @r*   ry   ry      s=       3 3 M K FM---OWNWN #_4~EVNMM!!,22)M! ! ! ! ! ! B B [B L L \LN  N  N  N d 
 
 
 
 X
 ^ ^ ^ ^B NRC C C C4 !DC DC DC DCL     + + + + +,! ! !
 
 

* * *       rP   ry   r  )!r  r   r;   r)  r  unittest.mockr  suppressImportErrorr   r4   r   r   r   r   r   	ccompilerr	   r
   _logr   utilr   	itertoolsr   r+   rB   PLAT_SPEC_TO_RUNTIMErO   rm   rv   r   ry   rT   rP   r*   <module>r4     s    
			               Z%%  MMM                            2 1 1 1 1 1 1 1                  " " ":' ' 'V 	    &  4   , 	 | | | | |9 | | | | |s   :>>