a
���f�� � @ s� d Z ddlZddlmZ ddlmZmZ ddlmZm Z m
Z
mZ ddlZddl
Z
ddlZddlZddlZddlZddlmZ ddlmZ e�� d kr�ddlZdd
lmZ nG dd� d�Ze� ZeejjfZzdd
lm Z W n ey� Y n0 dd� Z!d.dd�Z"dd� Z#dd� Z$ddddd�Z%dd� Z&dd� Z'dd � Z(d!d"� Z)d/d$d%�Z*G d&d'� d'�Z+G d(d)� d)�Z,G d*d+� d+�Z-G d,d-� d-�Z.dS )0a�
Improved support for Microsoft Visual C++ compilers.
Known supported compilers:
--------------------------
Microsoft Visual C++ 9.0:
Microsoft Visual C++ Compiler for Python 2.7 (x86, amd64)
Microsoft Windows SDK 6.1 (x86, x64, ia64)
Microsoft Windows SDK 7.0 (x86, x64, ia64)
Microsoft Visual C++ 10.0:
Microsoft Windows SDK 7.1 (x86, x64, ia64)
Microsoft Visual C++ 14.X:
Microsoft Visual C++ Build Tools 2015 (x86, x64, arm)
Microsoft Visual Studio Build Tools 2017 (x86, x64, arm, arm64)
Microsoft Visual Studio Build Tools 2019 (x86, x64, arm, arm64)
This may also support compilers shipped with compatible Visual Studio versions.
� N)�open)�listdir�pathsep)�join�isfile�isdir�dirname)�
LegacyVersion� )�
get_unpatched�Windows)�environc @ s e Zd ZdZdZdZdZdS )�winregN)�__name__�
__module__�__qualname__�
HKEY_USERS�HKEY_CURRENT_USER�HKEY_LOCAL_MACHINE�HKEY_CLASSES_ROOT� r r �3/usr/lib/python3.9/site-packages/setuptools/msvc.pyr * s r )�Regc C s� d}|d| f }zt �|d�}W nF tyf z|d| f }t �|d�}W n ty` d}Y n0 Y n0 |r�t|d�}t|�r�|S tt�| �S )a�
Patched "distutils.msvc9compiler.find_vcvarsall" to use the standalone
compiler build for Python
(VCForPython / Microsoft Visual C++ Compiler for Python 2.7).
Fall back to original behavior when the standalone compiler is not
available.
Redirect the path of "vcvarsall.bat".
Parameters
----------
version: float
Required Microsoft Visual C++ version.
Return
------
str
vcvarsall.bat path
z-Software\%sMicrosoft\DevDiv\VCForPython\%0.1f� �
installdirzWow6432Node\N�
vcvarsall.bat)r Z get_value�KeyErrorr r r �msvc9_find_vcvarsall)�versionZvc_base�key�
productdir� vcvarsallr r r r A s
r �x86c
O s� z"t t�}|| |g|�R i |��W S tjjy8 Y n tyH Y n0 zt|| ��� W S tjjy� } zt|| |� � W Y d}~n
d}~0 0 dS )ao
Patched "distutils.msvc9compiler.query_vcvarsall" for support extra
Microsoft Visual C++ 9.0 and 10.0 compilers.
Set environment without use of "vcvarsall.bat".
Parameters
----------
ver: float
Required Microsoft Visual C++ version.
arch: str
Target architecture.
Return
------
dict
environment
N) r �msvc9_query_vcvarsall� distutils�errors�DistutilsPlatformError�
ValueError�EnvironmentInfo�
return_env�_augment_exception)�ver�arch�args�kwargsZorig�excr r r r# k s r# c C s zt �t jddt jt jB �} W n ty2 Y dS 0 d}d}| �� t�� D ]�}zt �| |�\}}}W n ty| Y q�Y n0 |rJ|t j krJt
|�rJztt|��}W n t
tfy� Y qJY n0 |dkrJ||krJ|| }}qJW d � n1 s�0 Y ||fS )�0Python 3.8 "distutils/_msvccompiler.py" backportz'Software\Microsoft\VisualStudio\SxS\VC7r �NNN� )r �OpenKeyr �KEY_READZKEY_WOW64_32KEY�OSError� itertools�count� EnumValueZREG_SZr �int�floatr'