a
Z��^'N c @ s� d Z ddlZddlZddlZddlmZmZmZmZm Z ddl
mZmZ ddl
mZ ddlmZ ddlmZ dd � Zd
d� Zdd
ddd�Zdd� Zdd� Zddd�Zddddd�ZG dd� de�ZdS )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 C s zt jt jdt jt jB d�} W n ty< t�d� Y dS 0 d}d }| �� t� D ]�}zt � | |�\}}}W n ty� Y q�Y n0 |rR|t j
krRtj�
|�rRztt|��}W n ttfy� Y qRY n0 |dkrR||krR|| }}qRW d � n1 � s�0 Y ||fS )Nz'Software\Microsoft\VisualStudio\SxS\VC7)ZaccesszVisual C++ is not registered�NNr i )�winregZ OpenKeyExZHKEY_LOCAL_MACHINEZKEY_READZKEY_WOW64_32KEY�OSErrorr �debugr
Z EnumValueZREG_SZ�os�path�isdirZintZfloatZ
ValueErrorZ TypeError)�key�best_version�best_dirZiZvZvc_dirZvtZversion� r �//usr/lib64/python3.9/distutils/_msvccompiler.py�_find_vc2015 s2
�
,r c
C s� t j�d�pt j�d�} | s dS z8tjt j�| ddd�ddd d
ddd
dg ddd��� }W n tjt t
fyt Y dS 0 t j�|ddd�}t j�|�r�d|fS dS )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.
zProgramFiles(x86)ZProgramFilesr zMicrosoft Visual StudioZ Installerzvswhere.exez-latestz-prereleasez -requiresz1Microsoft.VisualStudio.Component.VC.Tools.x86.x64z -propertyZinstallationPathz -productsZ*ZmbcsZstrict)Zencoding�errorsZVCZ AuxiliaryZBuildi )r �environ�get�
subprocess�check_outputr �joinZstrip�CalledProcessErrorr
ZUnicodeDecodeErrorr )Zrootr r r r �_find_vc20178 s(
��r �x86Zx64ZarmZarm64)r � x86_amd64�x86_arm� x86_arm64c C s\ t � \}}|st� \}}|s*t�d� dS tj�|d�}tj�|�sTt�d|� dS |d fS )Nz$No suitable Visual C++ version foundr z
vcvarsall.batz%s cannot be found)r r r r r r r �isfile)� plat_spec�_r r � vcvarsallr r r �_find_vcvarsall_ s
r( c
C s� t �d�rdd� t j�� D �S t| �\}}|s6td��z&tjd�|| �tj d�j
ddd �}W nB tjy� } z(t�
|j� td
�|j���W Y d }~n
d }~0 0 dd� dd
� |�� D �D �}|S )NZDISTUTILS_USE_SDKc S s i | ]\}}|� � |�qS r �Zlower)�.0r �valuer r r �
<dictcomp>s s �z_get_vc_env.<locals>.<dictcomp>zUnable to find vcvarsall.batzcmd /u /c "{}" {} && set)Zstderrzutf-16leZreplace)r zError executing {}c S s$ i | ]\}}}|r|r|� � |�qS r r) )r* r r&