U e5dRN ã @ sÖ d Z ddlZddlZddlZddlZddlZddlmZmZm Z m Z mZ ddlm Z mZ ddlmZ 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 tk r> t d¡ Y dS X d}d }| ¦ tƒ D ]˜}zt | |¡\}}}W n tk rˆ Y qîY nX |rT|t j krTtj |¡rTztt|ƒƒ}W n ttfk rÐ Y qTY nX |dkrT||krT|| }}qTW 5 Q R X ||fS )Nz'Software\Microsoft\VisualStudio\SxS\VC7)ÚaccesszVisual C++ is not registered©NNr é )ÚwinregZ OpenKeyExÚHKEY_LOCAL_MACHINEZKEY_READZKEY_WOW64_32KEYÚOSErrorr Údebugr Z EnumValueZREG_SZÚosÚpathÚisdirÚintÚfloatÚ ValueErrorÚ TypeError)ÚkeyÚbest_versionÚbest_dirÚiÚvZvc_dirZvtÚversion© r ú//usr/lib64/python3.8/distutils/_msvccompiler.pyÚ_find_vc2015 s2 ý r" c C sª ddl } tj d¡ptj d¡}|s(dS z8tjtj |ddd¡d d ddd dddg ddd ¡ }W n tj t tfk r~ Y dS X tj |ddd¡}tj |¡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. r NzProgramFiles(x86)ZProgramFilesr zMicrosoft Visual StudioZ Installerzvswhere.exez-latestz-prereleasez -requiresz1Microsoft.VisualStudio.Component.VC.Tools.x86.x64z -propertyZinstallationPathz -productsÚ*ÚmbcsÚstrict)ÚencodingÚerrorsZVCZ AuxiliaryZBuildé ) Újsonr ÚenvironÚgetÚ subprocessÚcheck_outputr ÚjoinÚstripÚCalledProcessErrorr ÚUnicodeDecodeErrorr )r) Úrootr r r r! Ú_find_vc2017: s2 ú ùr3 Úx86Zx64ZarmZarm64)r4 Ú 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)r3 r" r r r r r. Úisfile)Ú plat_specÚ_r r Ú vcvarsallr r r! Ú_find_vcvarsallc s r<