B ¥‘“*ÀMã @ s’ d Z ddlZddlmZ ddlmZmZ ddlmZm Z m Z mZ ddlZddl Z ddlZddlZddlZddlZddlmZ ddlmZ dd lmZ e ¡ d kr¶ddlZddlmZ nG dd „ d ƒZeƒ ZeejjfZ yddl!m"Z" W n e k rú Y nX dd„ Z#d/dd„Z$dd„ Z%dd„ Z&dddddœZ'dd„ Z(dd„ Z)d d!„ Z*d"d#„ Z+d0d%d&„Z,G d'd(„ d(ƒZ-G d)d*„ d*ƒZ.G d+d,„ d,ƒZ/G d-d.„ d.ƒZ0dS )1a 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)Úunique_everseené )Ú 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 ú…/builddir/build/BUILDROOT/alt-python37-setuptools-58.3.0-4.el9.x86_64/opt/alt/python37/lib/python3.7/site-packages/setuptools/msvc.pyr + s r )ÚRegc C s’ d}|d| f }yt |d¡}W nJ tk rj y|d| f }t |d¡}W n tk rd d}Y nX Y nX |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\Nz vcvarsall.bat)r Ú get_valueÚKeyErrorr r r Úmsvc9_find_vcvarsall)ÚversionZvc_baseÚkeyÚ productdirÚ vcvarsallr r r r B s r Úx86c O sŽ yt tƒ}|| |f|ž|ŽS tjjk r2 Y n tk rD Y nX yt|| ƒ ¡ S tjjk rˆ } zt|| |ƒ ‚ W dd}~X Y nX 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ÚkwargsÚorigÚexcr r r r$ l s r$ c C sð yt t jddt jt jB ¡} W n tk r2 dS X d}d}| ¢ xšt ¡ D ]Ž}yt | |¡\}}}W n tk r| P Y nX |rL|t j krLt |ƒrLytt|ƒƒ}W n t tfk r¾ wLY nX |dkrL||krL|| }}qLW W dQ R X ||fS )z0Python 3.8 "distutils/_msvccompiler.py" backportz'Software\Microsoft\VisualStudio\SxS\VC7r )NNNé )r ÚOpenKeyr ÚKEY_READZKEY_WOW64_32KEYÚOSErrorÚ itertoolsÚcountÚ EnumValueÚREG_SZr ÚintÚfloatr( Ú TypeError)r Úbest_versionÚbest_dirÚiÚvZvc_dirZvtr r r r Ú_msvc14_find_vc2015’ s0 rA c C sš t d¡pt d¡} | sdS y>t t| dddƒddd d dd dd dddg¡jddd ¡ }W n tjtt fk rv dS X t|dddƒ}t |ƒr–d|fS dS )a€ Python 3.8 "distutils/_msvccompiler.py" backport 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)ÚProgramFiles)NNzMicrosoft Visual StudioZ Installerzvswhere.exez-latestz-prereleasez-requiresAnyz -requiresz1Microsoft.VisualStudio.Component.VC.Tools.x86.x64z)Microsoft.VisualStudio.Workload.WDExpressz -propertyÚinstallationPathz -productsÚ*ÚmbcsÚstrict)Úencodingr&