
    Ig\                     Z   d Z ddlZddlZddlZ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Z	 ddlZdZeZej        Zej        Zej        Zej        ZnP# e$ rH 	 ddlZddlZdZeZej        Zej        Zej        Zej        Zn# e$ r  ej        d	           Y nw xY wY nw xY werej        ej        ej         ej!        fZ" ej#        d
e$           d Z%d Z&d Z' G d d          Z(d Z)d Z*d Z+ G d de          Z, e)            dk    r  ej-        d           e,Z.ddl/m,Z, ddl/m(Z( dS dS )zdistutils.msvccompiler

Contains MSVCCompiler, an implementation of the abstract CCompiler class
for the Microsoft Visual Studio.
    N   )DistutilsExecErrorDistutilsPlatformErrorCompileErrorLibError	LinkError)	CCompilergen_lib_options)logFTzWarning: Can't read registry to find the necessary compiler setting
Make sure that Python modules winreg, win32api or win32con are installed.zmsvccompiler is deprecated and slated to be removed in the future. Please discontinue use or file an issue with pypa/distutils describing your use case.c                     	 t          | |          }n# t          $ r Y dS w xY wg }d}	 	 t          ||          }n# t          $ r Y nw xY w|                    |           |dz  }=|S )zReturn list of registry keys.Nr   Tr   )RegOpenKeyExRegError
RegEnumKeyappend)basekeyhandleLiks         ^/var/www/html/4nations/venv/lib/python3.11/site-packages/setuptools/_distutils/msvccompiler.py	read_keysr   J   s    dC((   tt
A	A	61%%AA 	 	 	E			Q Hs    
!!; 
AAc                    	 t          | |          }n# t          $ r Y dS w xY wi }d}	 	 t          ||          \  }}}n# t          $ r Y n=w xY w|                                }t	          |          |t	          |          <   |dz  }_|S )zXReturn dict of registry keys and values.

    All names are converted to lowercase.
    Nr   Tr   )r   r   RegEnumValuelowerconvert_mbcs)r   r   r   dr   namevaluetypes           r   read_valuesr!   \   s    
dC((   tt
A	A	 ,VQ 7 7D% 	 	 	E	zz|| ,U 3 3,t

	Q Hs    
!!? 
AAc                 f    t          | dd           }|	  |d          } n# t          $ r Y nw xY w| S )Ndecodembcs)getattrUnicodeError)sdecs     r   r   r   r   sQ    
!Xt
$
$C
	FAA 	 	 	D	Hs   ! 
..c                   &    e Zd Zd Zd Zd Zd ZdS )MacroExpanderc                 >    i | _         |                     |           d S N)macrosload_macros)selfversions     r   __init__zMacroExpander.__init__}   s#    !!!!!    c                 j    t           D ]*}t          ||          }|r||         | j        d|z  <    d S +d S )Nz$(%s))HKEYSr!   r-   )r/   macropathr   r   r   s         r   	set_macrozMacroExpander.set_macro   sR     	 	DD$''A /0vGeO,	 	r2   c                 6   d|z  }|                      d|dz   d           |                      d|dz   d           d}|                      d|d	           	 |d
k    r|                      d|d           n|                      d|d           n# t          $ r t          d          w xY wd}t          D ]h}	 t	          ||          }n# t
          $ r Y  w xY wt          |d          }t          |d                    ||                    }|d         | j	        d<   id S )Nz%Software\Microsoft\VisualStudio\%0.1fVCInstallDirz	\Setup\VC
productdirVSInstallDirz	\Setup\VSz Software\Microsoft\.NETFrameworkFrameworkDirinstallrootg      @FrameworkSDKDirzsdkinstallrootv1.1sdkinstallroota  Python was built with Visual Studio 2003;
extensions must be built with a compiler than can generate compatible binaries.
Visual Studio 2003 was not found on this system. If you have Cygwin installed,
you can try compiling with MingW32, by passing "-c mingw32" to setup.py.z.Software\Microsoft\NET Framework Setup\Productr   z{}\{}r0   z$(FrameworkVersion))
r7   KeyErrorr   r4   r   r   r   r!   formatr-   )	r/   r0   vsbasenetpr   hr   r   s	            r   r.   zMacroExpander.load_macros   sh   9GC~v'<lKKK~v'<lKKK1~sM:::	}}0#7KLLLL0#7GHHH 	 	 	(L  	 > 	> 	>D q))   Q""CD(//!S"9"9::A129DK-..	> 	>s   5B
 
B$3C
CCc                 p    | j                                         D ]\  }}|                    ||          }|S r,   )r-   itemsreplace)r/   r'   r   vs       r   subzMacroExpander.sub   s;    K%%'' 	  	 DAq		!QAAr2   N)__name__
__module____qualname__r1   r7   r.   rJ    r2   r   r*   r*   |   sP        " " "  > > >:    r2   r*   c                  v   d} t           j                            |           }|dk    rdS |t          |           z   }t           j        |d                             dd          \  }}t          |dd                   dz
  }|dk    r|dz  }t          |d	d
                   dz  }|dk    rd}|dk    r||z   S dS )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   )sysr0   findlensplitint)prefixr   r'   restmajorVersionminorVersions         r   get_build_versionr`      s     F  ABwwq	CKKAk!""o##C++GAtq"v;;?Lrq1v;;%Lqql**4r2   c                      d} t           j                            |           }|dk    rdS t           j                            d|          }t           j        |t          |           z   |         S )zUReturn the processor architecture.

    Possible results are "Intel" or "AMD64".
    z bit (rP   Intel))rW   r0   rX   rY   )r\   r   js      r   get_build_architecturere      s_     F  ABwwwa  A;q3v;;*++r2   c                     g }| D ]:}t           j                            |          }||vr|                    |           ;|S )znReturn a list of normalized paths with duplicates removed.

    The current order of paths is maintained.
    )osr6   normpathr   )pathsreduced_pathsrD   nps       r   normalize_and_reduce_pathsrl      sS     M % %Wa  ]""  $$$r2   c                        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d ZddZ	 	 	 	 	 	 	 d dZ	 d!dZ	 	 	 	 	 	 	 	 	 	 d"dZd Zd Zd Zd#dZd Zd$dZ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                 h   t                                          |||           t                      | _        t	                      | _        | j        dk    rC| j        dk    r!d| _        t          | j                  | _        nd| _        d| j        z  | _	        nd| j        dz   z  | _	        d| _
        d S )	Nrb      zSoftware\Microsoft\VisualStudiozSoftware\Microsoft\DevstudiozVisual Studio version %szMicrosoft SDK compiler %srQ   F)superr1   r`   _MSVCCompiler__versionre   _MSVCCompiler__arch_MSVCCompiler__rootr*   _MSVCCompiler__macros_MSVCCompiler__productinitialized)r/   verbosedry_runforce	__class__s       r   r1   zMSVCCompiler.__init__   s    '5111*,,,..;'!!~""@ -dn = ==7$.HDNN 9DNQ<NODN r2   c                    g | _         dt          j        v rGdt          j        v r9|                     d          r$d| _        d| _        d| _        d| _        d| _        n| 	                    d          | _         t          | j                   d	k    rt          d
| j        z            |                     d          | _        |                     d          | _        |                     d          | _        |                     d          | _        |                     d          | _        |                     d           |                     d           	 t          j        d                             d          D ]}| j                             |           n# t           $ r Y nw xY wt#          | j                   | _         d                    | j                   t          j        d<   d | _        | j        dk    rg d| _        g d| _        ng d| _        g d| _        g d| _        | j        dk    r
g d| _        n	g d| _        dg| _        d| _        d S )NDISTUTILS_USE_SDKMSSdkzcl.exezlink.exezlib.exezrc.exezmc.exer6   r   zxPython was built with %s, and extensions need to be built with the same version of the compiler, but it isn't installed.libinclude;rb   )/nologo/O2/MD/W3/GX/DNDEBUG)r   /Od/MDdr   r   /Z7/D_DEBUG)r   r   r   r   /GS-r   )r   r   r   r   r   r   r   )/DLLr   z/INCREMENTAL:NOrr   )r   r   /INCREMENTAL:no/DEBUG)r   r   r   z	/pdb:Noner   r   T)_MSVCCompiler__pathsrg   environfind_execclinkerr   rcmcget_msvc_pathsrY   r   rx   set_path_env_varrZ   r   r@   rl   joinpreprocess_optionsru   compile_optionscompile_options_debugldflags_sharedrt   ldflags_shared_debugldflags_staticry   )r/   rD   s     r   
initializezMSVCCompiler.initialize  s   2:--2:%%h'' &
 DG$DK DHDGDGG..v66DL4<  A%%,GIMX   mmH--DG--
33DK}}Y//DHmmH--DGmmH--DG!!%(((!!),,,	Z'--c22 ' '##A&&&&' 	 	 	D	1$,?? XXdl33
6"&;'!!#V#V#VD * * *D&& $X#W#WD * * *D& EDD>Q(X(X(XD%%) ) )D%  )ks   AF 
F#"F# c                     |d}g }|D ]s}t           j                            |          \  }}t           j                            |          d         }|t           j                            |          d          }|| j        vrt          d|z            |rt           j                            |          }|| j        v r<|	                    t           j        
                    ||| j        z                        || j        v r=|	                    t           j        
                    ||| j        z                        8|	                    t           j        
                    ||| j        z                        u|S )Nr   r   zDon't know how to compile %s)rg   r6   splitext
splitdriveisabssrc_extensionsr   basename_rc_extensionsr   r   res_extension_mc_extensionsobj_extension)r/   source_filenames	strip_dir
output_dir	obj_namessrc_namer   exts           r   object_filenameszMSVCCompiler.object_filenamesd  sf    J	( 	V 	VH'**844KT37%%d++A.Dd++--.D$--- ##AH#LMMM .w''--d)))  j$AS:S!T!TUUUU+++  j$AS:S!T!TUUUU  j$AS:S!T!TUUUUr2   Nc	                    | j         s|                                  |                     ||||||          }	|	\  }}
}}}|pg }|                    d           |r|                    | j                   n|                    | j                   |
D ]I}	 ||         \  }}n# t          $ r Y w xY w|rt          j	        
                    |          }|| j        v rd|z   }n|| j        v rd|z   }n|| j        v rQ|}d|z   }	 |                     | j        g|z   |gz   |gz              n!# t           $ r}t#          |          d }~ww xY w|| j        v rt          j	                            |          }t          j	                            |          }	 |                     | j        gd|d|gz   |gz              t          j	                            t          j	                            |                    \  }}t          j	                            ||dz             }|                     | j        gd|z   gz   |gz              n!# t           $ r}t#          |          d }~ww xY wt#          d                    ||                    d	|z   }	 |                     | j        g|z   |z   ||gz   |z              *# t           $ r}t#          |          d }~ww xY w|
S )
Nz/cz/Tcz/Tpz/foz-hz-rrp   z"Don't know how to compile {} to {}z/Fo)ry   r   _setup_compiler   extendr   r   r@   rg   r6   abspath_c_extensions_cpp_extensionsr   spawnr   r   r   r   dirnamer   r   r   r   rA   r   )r/   sourcesr   r-   include_dirsdebugextra_preargsextra_postargsdependscompile_infoobjectspp_optsbuildcompile_optsobjsrcr   	input_opt
output_optmsgh_dirrc_dirr   _rc_files                            r   compilezMSVCCompiler.compile}  sw     	OO**gw
 
 ;G7%$*D!!! 	6 :;;;; 4555 A	( A	(C :SS    + gooc**d(((!CK		,,,!CK		+++	"S[
,JJy72j\AYKOPPPP) , , ,&s+++,+++ ,,--	,JJyD%v+FF#NOOO g..rw/?/?/D/DEEGD! gll64%<@@GJJyECK=8G9DEEEE) , , ,&s+++, #8??SII   J	(

WI"# !*-. %	%    & ( ( ("3'''( s[   B  
B-,B-&D))
E3EEB.I
I!II!)J::
KKKc                    | j         s|                                  |                     ||          \  }}|                     ||          }|                     ||          rN|d|z   gz   }|r	 	 |                     | j        g|z              d S # t          $ r}t          |          d }~ww xY wt          j
        d|           d S )N)r   /OUT:skipping %s (up-to-date))ry   r   _fix_object_argslibrary_filename
_need_linkr   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 $ 5 5gz J J*//:/VV??7O44 		C'O";!<<H $

DH:011111% $ $ $smm#$ I0/BBBBBs   /B 
B-B((B-c                 (   | j         s|                                  |                     ||          \  }}|                     |||          }|\  }}}|r%|                     dt          |          z              t          | |||          }| t          j        	                    ||          }| 
                    ||          r|t          j        k    r"|	r| j        dd          }n!| j        dd          }n|	r| j        }n| j        }g }|pg D ]}|                    d|z              ||z   |z   |z   d|z   gz   }|t          j                            t          j                            |                    \  }}t          j        	                    t          j                            |d                   |                     |                    }|                    d|z              |
r|
|d d<   |r|                    |           |                     t          j                            |                     	 |                     | j        g|z              d S # t0          $ r}t3          |          d }~ww xY wt5          j        d|           d S )Nz5I don't know what to do with 'runtime_library_dirs': r   z/EXPORT:r   r   z/IMPLIB:r   )ry   r   r   _fix_lib_argswarnstrr
   rg   r6   r   r   r	   
EXECUTABLEr   r   r   r   r   r   r   r   mkpathr   r   r   r   r   r   )r/   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   s                           r   linkzMSVCCompiler.link  s   "  	OO $ 5 5gz J J*''	<AUVV
:D7L"6 	IIG*++,  
 #47KYWW! gll:GGO??7O44 .	Ci222 6"7;GG"1!""5GG 2"7GG"1GK%+ 5 5"":#34444 ("[07:g>W=XX  )&(g&6&6G$$_55' '#7 !gllGOOGAJ//1F1Fx1P1P  zK7888 ,+ /~...KK88999%

DK=7233333% % % %nn$% I0/BBBBBs   <I 
I:&I55I:c                     d|z   S )Nz	/LIBPATH:rN   r/   dirs     r   library_dir_optionzMSVCCompiler.library_dir_optionE  s    S  r2   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_optionH  s    $J
 
 	
r2   c                 ,    |                      |          S r,   )r   )r/   r   s     r   library_optionzMSVCCompiler.library_optionM  s    $$S)))r2   c                     |r|dz   |g}n|g}|D ]_}|D ]Z}t           j                            ||                     |                    }t           j                            |          r|c c S [`d S )N_d)rg   r6   r   r   exists)r/   dirsr   r   	try_namesr   r   libfiles           r   find_library_filezMSVCCompiler.find_library_fileP  s      	tS)III 	 	C! # #',,sD,A,A$,G,GHH7>>'** #"NNNNN## 4r2   c                    | j         D ]b}t          j                            t          j                            |          |          }t          j                            |          r|c S ct          j        d                             d          D ]b}t          j                            t          j                            |          |          }t          j                            |          r|c S c|S )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   rg   r6   r   r   isfiler   rZ   )r/   exerD   fns       r   r   zMSVCCompiler.find_exeb  s      	 	Abgooa00#66Bw~~b!! 			 F#))#.. 	 	Abgooa00#66Bw~~b!! 			 
r2   x86c                    t           sg S |dz   }| j        dk    r!d                    | j        | j                  }n| j        d|d}t          D ]q}t          ||          }|r]| j        dk    r5| j                            ||                                       d          c S ||                             d          c S r| j        dk    r9t          D ]1}t          |d| j        z            | 	                    d
            n2g S )zGet a list of devstudio directories (include, lib or path).

        Return a list of strings.  The list will be empty if unable to
        access the registry or appropriate registry keys not found.
        z dirsrr   z8{}\{:0.1f}\VC\VC_OBJECTS_PLATFORM_INFO\Win32\Directoriesz.\6.0\Build System\Components\Platforms\Win32 (z)\Directoriesr   rQ   z%s\6.0NzIt seems you have Visual Studio 6 installed, but the expected registry settings are not present.
You must at least run the Visual Studio GUI once so that these entries are created.)
_can_read_regrt   rA   rv   r4   r!   rw   rJ   rZ   r   )r/   r6   platformr   r   r   s         r   r   zMSVCCompiler.get_msvc_pathsx  sL     	Ig~>QMTT CC /3kkk888E 
  	. 	.DD#&&A .>Q&&=,,QtW55;;C@@@@@T7==-----	. >Q  tY%<==III=   E J 	r2   c                     |dk    r|                      d          }n|                      |          }|r$d                    |          t          j        |<   dS dS )zSet environment variable 'name' to an MSVC path type value.

        This is equivalent to a SET command prior to execution of spawned
        commands.
        r   libraryr   N)r   r   rg   r   )r/   r   rD   s      r   r   zMSVCCompiler.set_path_env_var  sc     5==##I..AA##D))A 	+"xx{{BJt	+ 	+r2   )r   r   r   )r   r   )NNNr   NNN)Nr   N)
NNNNNr   NNNN)r   )r  ) rK   rL   rM   __doc__compiler_typeexecutablesr   r   r   r   r   r   r   static_lib_extensionshared_lib_extensionstatic_lib_formatshared_lib_formatexe_extensionr1   r   r   r   r   r   r   r   r   r  r   r   r   __classcell__)r}   s   @r   rn   rn      s       3 3 M K FM---OWNWN #_4~EVNMM!!,22)M! ! ! ! ! !$O  O  O f   8 ] ] ] ]@ NRC C C C2 !OC OC OC OCj! ! !
 
 

* * *   $  ,( ( ( (T+ + + + + + +r2   rn   g       @z3Importing new compiler from distutils.msvc9compiler)rn   )r*   )0r  rW   rg   warningserrorsr   r   r   r   r   	ccompilerr	   r
   _logr   r	  winreghkey_mod	OpenKeyExr   EnumKeyr   	EnumValuer   errorr   ImportErrorwin32apiwin32coninfo
HKEY_USERSHKEY_CURRENT_USERHKEY_LOCAL_MACHINEHKEY_CLASSES_ROOTr4   r   DeprecationWarningr   r!   r   r*   r`   re   rl   rn   r   OldMSVCCompilerdistutils.msvc9compilerrN   r2   r   <module>r+     s    


 				               2 1 1 1 1 1 1 1      MMMMH#LJ#L|HH   ,(
,>   2	
 	
 	
 	*  "#"	E 4 	    $  ,  , , , , , , , ,^  4, , ,  L+ L+ L+ L+ L+9 L+ L+ L+^ #CICDDD"O444444 65555555 s5   $A B (BB BB BB B 