a �DOg�[� @szddlZddlZddlmZmZmZmZmZddlm Z m Z ddl m Z dZ z,ddlZdZ eZejZejZejZejZWndey�z4ddlZddlZdZ eZejZejZejZejZWney�e �d�Yn0Yn0e r�ejejejejfZ dd �Z!d d �Z"d d �Z#Gdd�d�Z$dd�Z%dd�Z&dd�Z'Gdd�de �Z(e%�dk�rve �)d�e(Z*ddl+m(Z(ddl+m$Z$dS)�N)�DistutilsExecError�DistutilsPlatformError� CompileError�LibError� LinkError)� CCompiler�gen_lib_options)�logFTz�Warning: Can't read registry to find the necessary compiler setting Make sure that Python modules winreg, win32api or win32con are installed.cCsjzt||�}Wnty"YdS0g}d}zt||�}WntyPYqfYn0|�|�|d7}q,|S�Nr�)� RegOpenKeyEx�RegError� RegEnumKey�append)�base�key�handle�L�i�k�r�./usr/lib64/python3.9/distutils/msvccompiler.py� read_keys7s     rcCs~zt||�}Wnty"YdS0i}d}zt||�\}}}WntyVYqzYn0|��}t|�|t|�<|d7}q,|Sr )r r � RegEnumValue�lower� convert_mbcs)rrr�dr�name�value�typerrr� read_valuesHs    r cCs8t|dd�}|dur4z |d�}Wnty2Yn0|S)N�decode�mbcs)�getattr� UnicodeError)�sZdecrrrr]s   rc@s,eZdZdd�Zdd�Zdd�Zdd�Zd S) � MacroExpandercCsi|_|�|�dS�N)�macros� load_macros)�self�versionrrr�__init__gszMacroExpander.__init__cCs2tD](}t||�}|r|||jd|<q.qdS)Nz$(%s))�HKEYSr r()r*Zmacro�pathrrrrrr� set_macroks  zMacroExpander.set_macroc Cs�d|}|�d|dd�|�d|dd�d}|�d|d �z*|d krX|�d |d �n|�d |d �Wn,ty�}ztd��WYd}~n d}~00d}tD]T}zt||�}Wnty�Yq�Yn0t|d�}t|d||f�} | d|jd<q�dS)Nz%Software\Microsoft\VisualStudio\%0.1fZ VCInstallDirz \Setup\VCZ productdirZ VSInstallDirz \Setup\VSz Software\Microsoft\.NETFrameworkZ FrameworkDirZ installrootg@ZFrameworkSDKDirzsdkinstallrootv1.1ZsdkinstallrootaPython 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\Productrz%s\%sr+z$(FrameworkVersion)) r/�KeyErrorrr-r r rr r() r*r+Zvsbase�net�exc�pr�hrrrrrr)rs,�   zMacroExpander.load_macroscCs$|j��D]\}}|�||�}q |Sr')r(�items�replace)r*r%r�vrrr�sub�szMacroExpander.subN)�__name__� __module__� __qualname__r,r/r)r8rrrrr&fsr&cCs�d}tj�|�}|dkrdS|t|�}tj|d��dd�\}}t|dd��d}|dkrf|d7}t|dd ��d }|dkr�d }|dkr�||SdS) NzMSC v.������� r ������ ��g$@r)�sysr+�find�len�split�int)�prefixrr%�restZ majorVersionZ minorVersionrrr�get_build_version�s  rJcCs@d}tj�|�}|dkrdStj�d|�}tj|t|�|�S)Nz bit (r<�Intel�))rCr+rDrE)rHr�jrrr�get_build_architecture�s  rNcCs0g}|D]"}tj�|�}||vr|�|�q|Sr')�osr.�normpathr)�pathsZ reduced_pathsr3Znprrr�normalize_and_reduce_paths�s   rRc @s�eZdZdZiZdgZgd�ZdgZdgZeeeeZ dZ dZ dZ d Z d ZZd Zd*d d�Zdd�Zd+dd�Zd,dd�Zd-dd�Zd.dd�Zdd�Zdd�Zdd �Zd/d!d"�Zd#d$�Zd0d&d'�Zd(d)�ZdS)1� MSVCCompilerZmsvcz.c)z.ccz.cppz.cxx�.rcz.mcz.resz.objz.libz.dllz%s%sz.exercCsvt�||||�t�|_t�|_|jdkr\|jdkrHd|_t|j�|_nd|_d|j|_ nd|jd|_ d|_ dS) NrK�zSoftware\Microsoft\VisualStudiozSoftware\Microsoft\DevstudiozVisual Studio version %szMicrosoft SDK compiler %sr=F) rr,rJ�_MSVCCompiler__versionrN�_MSVCCompiler__arch�_MSVCCompiler__rootr&�_MSVCCompiler__macros�_MSVCCompiler__product� initialized)r*�verbose�dry_run�forcerrrr,�s  zMSVCCompiler.__init__cCs�g|_dtjvrDdtjvrD|�d�rDd|_d|_d|_d|_d|_nx|� d�|_t |j�d krlt d |j ��|�d�|_|�d�|_|�d�|_|�d�|_|�d�|_|� d �|� d �z&tjd�d �D]}|j�|�q�Wnty�Yn0t|j�|_d �|j�tjd<d|_|jdk�r|jdkrt|j�||��d�S||�d�Sq>|jdkr�tD]&}t|d|j�dur�|�d�q�q�gS) Nz dirsrUz6%s\%0.1f\VC\VC_OBJECTS_PLATFORM_INFO\Win32\Directoriesz?%s\6.0\Build System\Components\Platforms\Win32 (%s)\Directoriesr`r=z%s\6.0z�It 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_regrVrXr-r rYr8rFr�)r*r.�platformrrrrrrrvKs,  ��    zMSVCCompiler.get_msvc_pathscCs6|dkr|�d�}n |�|�}|r2d�|�tj|<dS)Nr_Zlibraryr`)rvrxrOrp)r*rr3rrrrwos   zMSVCCompiler.set_path_env_var)rrr)rr~)NNNrNNN)NrN) NNNNNrNNNN)r)r�)r9r:r;Z compiler_typeZ executablesr�r�r�r�r�r�r�Zstatic_lib_extensionZshared_lib_extensionZstatic_lib_formatZshared_lib_formatZ exe_extensionr,r}r�r�r�r�r�r�r�r�rqrvrwrrrrrS�s^�� B� � X� � S  $rSg @z3Importing new compiler from distutils.msvc9compiler)rS)r&),rCrOZdistutils.errorsrrrrrZdistutils.ccompilerrrZ distutilsr r��winregZhkey_modZ OpenKeyExr ZEnumKeyrZ EnumValuer�errorr � ImportErrorZwin32apiZwin32con�infoZ HKEY_USERS�HKEY_CURRENT_USER�HKEY_LOCAL_MACHINEZHKEY_CLASSES_ROOTr-rr rr&rJrNrRrSr�ZOldMSVCCompilerZdistutils.msvc9compilerrrrr� s^       � - 9