a oe>@s2dZddlZddlmZddlmZmZddlmZm Z m Z m Z ddl m Z ddlZddlZddlZddl Z ddlZddlmZedkrddlZdd lmZnGd d d ZeZd d ZddZdddddZddZddZddZd&ddZGdddZ Gd d!d!Z!Gd"d#d#Z"Gd$d%d%Z#dS)'a Improved support for Microsoft Visual C++ compilers. Known supported compilers: -------------------------- 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)listdirpathsep)joinisfileisdirdirname)CalledProcessError)unique_everseenWindows)environc@seZdZdZdZdZdZdS)winregN)__name__ __module__ __qualname__ HKEY_USERSHKEY_CURRENT_USERHKEY_LOCAL_MACHINEHKEY_CLASSES_ROOTrr0C:\Program Files\Certbot\pkgs\setuptools\msvc.pyr sr c CszttjddtjtjB}Wnty2YdS0d}d}|tD]}zt||\}}}Wnty|YqYn0|rJ|tj krJt |rJzt t |}Wnt tfyYqJYn0|dkrJ||krJ||}}qJWdn1s0Y||fS)0Python 3.8 "distutils/_msvccompiler.py" backportz'Software\Microsoft\VisualStudio\SxS\VC7rNNN)r OpenKeyrKEY_READKEY_WOW64_32KEYOSError itertoolscount EnumValueREG_SZrintfloat ValueError TypeError)key best_versionbest_dirivZvc_dirZvtversionrrr_msvc14_find_vc2015)s2      *r,c Cstdptd}|sdSd}|D]}ttttttt |ddddd d |d d d dg j ddd }t |ddd}t |rd|fWdSWdq$1s0Yq$dS)aPython 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. ProgramFiles(x86) ProgramFilesr)z1Microsoft.VisualStudio.Component.VC.Tools.x86.x64z)Microsoft.VisualStudio.Workload.WDExpresszMicrosoft Visual StudioZ Installerz vswhere.exez-latestz -prereleasez -requiresz -propertyinstallationPathz -products*mbcsstrict)encodingerrorsVCZ AuxiliaryZBuildN) r get contextlibsuppressr rUnicodeDecodeError subprocess check_outputrdecodestripr)rootZsuitable_componentsZ componentpathrrr_msvc14_find_vc2017Gs6 :rAx86x64ZarmZarm64)rBZ x86_amd64Zx86_armZ x86_arm64c Cst\}}d}|tvr t|}nd|vr,dnd}|rt|ddddd|d d }zd dl}|j|d d d}Wntttfyd}Yn0|st\}}|rt|d|dd }|sdSt|d}t|sdS|rt|sd}||fS)rNamd64rCrBz..redistZMSVCz**zMicrosoft.VC14*.CRTzvcruntime140.dllrT) recursivezMicrosoft.VC140.CRTrz vcvarsall.bat) rAPLAT_SPEC_TO_RUNTIMErglob ImportErrorr LookupErrorr,r) plat_spec_r( vcruntimeZvcruntime_platZvcredistrIr' vcvarsallrrr_msvc14_find_vcvarsallsP       rPc CsdtvrddtDSt|\}}|s6tjdz&tjd||tj dj ddd }Wn<tj y}z"tjd |j |WYd }~n d }~00d dd d| DD}|r||d<|S)rZDISTUTILS_USE_SDKcSsi|]\}}||qSrlower).0r&valuerrr z&_msvc14_get_vc_env..zUnable to find vcvarsall.batzcmd /u /c "{}" {} && set)stderrzutf-16lereplace)r4zError executing {}NcSs$i|]\}}}|r|r||qSrrQ)rSr&rMrTrrrrUscss|]}|dVqdS)=N) partition)rSlinerrr rVz%_msvc14_get_vc_env..py_vcruntime_redist)r itemsrP distutilsr4DistutilsPlatformErrorr;r<formatZSTDOUTr=r cmd splitlines)rLrOrNoutexcenvrrr_msvc14_get_vc_envs0     rgc CsDz t|WStjjy>}zt|dWYd}~n d}~00dS)a* Patched "distutils._msvccompiler._get_vc_env" for support extra Microsoft Visual C++ 14.X compilers. Set environment without use of "vcvarsall.bat". Parameters ---------- plat_spec: str Target architecture. Return ------ dict environment ,@N)rgr_r4r`_augment_exception)rLrerrrmsvc14_get_vc_envs   rjcCs|jd}d|vs"d|vrd}|jfit}d}|dkrj|ddkr`|d 7}q|d 7}n.|d kr|d 7}||d 7}n|dkr|d7}|f|_dS)zl Add details to the exception message to help guide the user as to what action will resolve it. rrOzvisual cz;Microsoft Visual C++ {version:0.1f} or greater is required.z-www.microsoft.com/download/details.aspx?id=%d"@Zia64rGz( Get it with "Microsoft Windows SDK 7.0"z% Get it from http://aka.ms/vcpython27$@z* Get it with "Microsoft Windows SDK 7.1": iW rhzd Get it with "Microsoft C++ Build Tools": https://visualstudio.microsoft.com/visual-cpp-build-tools/N)argsrRralocalsfind)rer+archmessageZtmplZ msdownloadrrrris"   ric@sbeZdZdZeddZddZe ddZ dd Z d d Z dd dZ dddZdddZdS) PlatformInfoz Current and Target Architectures information. Parameters ---------- arch: str Target architecture. Zprocessor_architecturerkcCs|dd|_dS)NrCrD)rRrXrq)selfrqrrr__init__"szPlatformInfo.__init__cCs|j|jdddS)zs Return Target CPU architecture. Return ------ str Target CPU rMN)rqrprtrrr target_cpu%s zPlatformInfo.target_cpucCs |jdkS)z Return True if target CPU is x86 32 bits.. Return ------ bool CPU is x86 32 bits rBrxrwrrr target_is_x861s zPlatformInfo.target_is_x86cCs |jdkS)z Return True if current CPU is x86 32 bits.. Return ------ bool CPU is x86 32 bits rB current_cpurwrrrcurrent_is_x86<s zPlatformInfo.current_is_x86FcCs.|jdkr|rdS|jdkr$|r$dSd|jS)uk Current platform specific subfolder. Parameters ---------- hidex86: bool return '' and not '†' if architecture is x86. x64: bool return 'd' and not 'md64' if architecture is amd64. Return ------ str subfolder: ' arget', or '' (see hidex86 parameter) rBrkrD\x64\%sr{rthidex86rCrrr current_dirGszPlatformInfo.current_dircCs.|jdkr|rdS|jdkr$|r$dSd|jS)ar Target platform specific subfolder. Parameters ---------- hidex86: bool return '' and not '\x86' if architecture is x86. x64: bool return '\x64' and not '\amd64' if architecture is amd64. Return ------ str subfolder: '\current', or '' (see hidex86 parameter) rBrkrDr~rryrrrr target_dir_szPlatformInfo.target_dircCs0|rdn|j}|j|krdS|dd|S)ap Cross platform specific subfolder. Parameters ---------- forcex86: bool Use 'x86' as current architecture even if current architecture is not x86. Return ------ str subfolder: '' if target architecture is current architecture, '\current_target' if not. rBrk\z\%s_)r|rxrrX)rtforcex86currentrrr cross_dirws zPlatformInfo.cross_dirN)FF)FF)F)rrr__doc__r r7rRr|rupropertyrxrzr}rrrrrrrrss     rsc@seZdZdZejejejejfZ ddZ e ddZ e ddZ e dd Ze d d Ze d d Ze ddZe ddZe ddZe ddZdddZddZdS) RegistryInfoz Microsoft Visual Studio related registry information. Parameters ---------- platform_info: PlatformInfo "PlatformInfo" instance. cCs ||_dSN)pi)rtZ platform_inforrrruszRegistryInfo.__init__cCsdS)z Microsoft Visual Studio root registry key. Return ------ str Registry key Z VisualStudiorrwrrr visualstudios zRegistryInfo.visualstudiocCs t|jdS)z Microsoft Visual Studio SxS registry key. Return ------ str Registry key ZSxS)rrrwrrrsxss zRegistryInfo.sxscCs t|jdS)z| Microsoft Visual C++ VC7 registry key. Return ------ str Registry key ZVC7rrrwrrrvcs zRegistryInfo.vccCs t|jdS)z Microsoft Visual Studio VS7 registry key. Return ------ str Registry key ZVS7rrwrrrvss zRegistryInfo.vscCsdS)z Microsoft Visual C++ for Python registry key. Return ------ str Registry key zDevDiv\VCForPythonrrwrrr vc_for_pythons zRegistryInfo.vc_for_pythoncCsdS)zq Microsoft SDK registry key. Return ------ str Registry key zMicrosoft SDKsrrwrrr microsoft_sdks zRegistryInfo.microsoft_sdkcCs t|jdS)z Microsoft Windows/Platform SDK registry key. Return ------ str Registry key r rrrwrrr windows_sdks zRegistryInfo.windows_sdkcCs t|jdS)z Microsoft .NET Framework SDK registry key. Return ------ str Registry key ZNETFXSDKrrwrrr netfx_sdks zRegistryInfo.netfx_sdkcCsdS)z Microsoft Windows Kits Roots registry key. Return ------ str Registry key zWindows Kits\Installed Rootsrrwrrrwindows_kits_rootss zRegistryInfo.windows_kits_rootsFcCs$|js|rdnd}td|d|S)a Return key in Microsoft software registry. Parameters ---------- key: str Registry key path where look. x86: str Force x86 software registry. Return ------ str Registry key rkZ Wow6432NodeZSoftwareZ Microsoft)rr}r)rtr&rBZnode64rrr microsoftszRegistryInfo.microsoftc Cstj}tj}tj}|j}|jD]}d}z||||d|}WnTty|jsz||||dd|}WqtyYYqYq0nYqYn0zHz$t ||dWW|r||StyYn0W|r||q|r||0qdS)a Look for values in registry in Microsoft software registry. Parameters ---------- key: str Registry key path where look. name: str Value name to find. Return ------ str value NrT) r rrCloseKeyrHKEYSrrr} QueryValueEx) rtr&nameZkey_readZopenkeyZclosekeymshkeybkeyrrrlookup"s4       zRegistryInfo.lookupN)F)rrrrr rrrrrrurrrrrrrrrrrrrrrrrs6          rc@s<eZdZdZeddZeddZedeZd7ddZ d d Z d d Z d dZ e ddZeddZeddZddZddZeddZeddZeddZedd Zed!d"Zed#d$Zed%d&Zed'd(Zed)d*Zed+d,Zed-d.Zed/d0Zed1d2Z d3d4Z!e d8d5d6Z"dS)9 SystemInfoz Microsoft Windows and Visual Studio related system information. Parameters ---------- registry_info: RegistryInfo "RegistryInfo" instance. vc_ver: float Required Microsoft Visual C++ version. WinDirrkr.r-NcCs2||_|jj|_||_|p$||_|_dSr)rirfind_programdata_vs_versknown_vs_paths_find_latest_available_vs_vervs_vervc_ver)rtZ registry_inforrrrru]s  zSystemInfo.__init__cCs>|}|s|jstjdt|}||jt|dS)zm Find the latest VC version Return ------ float version z%No Microsoft Visual C++ version foundrG)find_reg_vs_versrr_r4r`setupdatesorted)rtZ reg_vc_versZvc_versrrrrfs   z(SystemInfo._find_latest_available_vs_verc Csj|jj}|jj|jj|jjf}g}t|jj|D],\}}zt |||dtj }Wnt ylYq2Yn0|t |\}}} t |D]T} tt6tt|| d} | |vr|| Wdq1s0Yqt |D]T} tt4tt|| } | |vr|| Wdq1s40YqWdq21sV0Yq2t|S)z Find Microsoft Visual Studio versions available in registry. Return ------ list of float Versions rN)rrrrrrproductrr rrr QueryInfoKeyranger8r9r$r#r appendEnumKeyr) rtrZvckeysZvs_versrr&rZsubkeysvaluesrMr)verrrrrzs*     *   NzSystemInfo.find_reg_vs_versc Csi}d}z t|}Wnty*|YS0|D]}zpt||d}t|ddd}t|}Wdn1sp0Y|d}tt|d||||d <Wq0ttfyYq0Yq00q0|S) z Find Visual studio 2017+ versions from information in "C:\ProgramData\Microsoft\VisualStudio\Packages\_Instances". Return ------ dict float version as key, path as value. z9C:\ProgramData\Microsoft\VisualStudio\Packages\_Instancesz state.jsonZrtzutf-8)r3Nr/ VC\Tools\MSVCZinstallationVersion)rrrrjsonload_as_float_versionKeyError) rtZ vs_versionsZ instances_dirZ hashed_namesrZ state_pathZ state_filestateZvs_pathrrrrs(     (  z#SystemInfo.find_programdata_vs_verscCstd|dddS)z Return a string version as a simplified float version (major.minor) Parameters ---------- version: str Version. Return ------ float version .N)r#rsplit)r+rrrrszSystemInfo._as_float_versioncCs.t|jd|j}|j|jjd|jp,|S)zp Microsoft Visual Studio directory. Return ------ str path zMicrosoft Visual Studio %0.1f%0.1f)rProgramFilesx86rrrr)rtdefaultrrr VSInstallDirs  zSystemInfo.VSInstallDircCs,|p|}t|s(d}tj||S)zm Microsoft Visual C++ directory. Return ------ str path z(Microsoft Visual C++ directory not found) _guess_vc_guess_vc_legacyrr_r4r`)rtr@msgrrr VCInstallDirs  zSystemInfo.VCInstallDirc Cs|jdkrdSz|j|j}Wnty6|j}Yn0t|d}z$t|d}|||_t||WStt fy~YdS0dS)zl Locate Visual C++ for VS2017+. Return ------ str path rhrkrrGN) rrrrrrrrr IndexError)rtZvs_dirZguess_vcrrrrrs       zSystemInfo._guess_vccCsbt|jd|j}t|jjd|j}|j|d}|rBt|dn|}|j|jjd|jp`|S)z{ Locate Visual C++ for versions prior to 2017. Return ------ str path z Microsoft Visual Studio %0.1f\VCr installdirr5)rrrrrrr)rtrZreg_pathZ python_vcZ default_vcrrrrs  zSystemInfo._guess_vc_legacycCsJ|jdkrdS|jdkrdS|jdkr*dS|jdkr8dS|jd krFd Sd S) z Microsoft Windows SDK versions for specified MSVC++ version. Return ------ tuple of str versions rl)z7.0z6.1z6.0arm)z7.1z7.0a&@)z8.0z8.0a(@)8.1z8.1arh)z10.0rNrrwrrrWindowsSdkVersion+s     zSystemInfo.WindowsSdkVersioncCs|t|jdS)zt Microsoft Windows SDK last version. Return ------ str version lib)_use_last_dir_namer WindowsSdkDirrwrrrWindowsSdkLastVersion@s z SystemInfo.WindowsSdkLastVersioncCs d}|jD],}t|jjd|}|j|d}|r q8q |rDt|stt|jjd|j}|j|d}|rtt|d}|rt|s|jD]6}|d|d}d |}t|j |}t|r|}q|rt|s|jD]$}d |}t|j |}t|r|}q|st|j d }|S) zn Microsoft Windows SDK directory. Return ------ str path rkzv%sinstallationfolderrrZWinSDKNrzMicrosoft SDKs\Windows Kits\%szMicrosoft SDKs\Windows\v%sZ PlatformSDK) rrrrrrrrrfindr.r)rtsdkdirrlocr@Z install_baseZintverdrrrrLs6           zSystemInfo.WindowsSdkDirc Cs|jdkrd}d}n&d}|jdkr&dnd}|jjd|d}d ||d d f}g}|jd kr~|jD]}|t|jj||g7}qb|jD]}|t|jj d ||g7}q|D]}|j |d}|r|SqdS)zy Microsoft Windows SDK executable directory. Return ------ str path r#rk(rTF)rCrzWinSDK-NetFx%dTools%sr-rhzv%sArN) rrrrXNetFxSdkVersionrrrrrr) rtZnetfxverrqrZfxZregpathsrr@ZexecpathrrrWindowsSDKExecutablePathws"    z#SystemInfo.WindowsSDKExecutablePathcCs&t|jjd|j}|j|dp$dS)zl Microsoft Visual F# directory. Return ------ str path z%0.1f\Setup\F#Z productdirrk)rrrrr)rtr@rrrFSharpInstallDirs zSystemInfo.FSharpInstallDircCsF|jdkrdnd}|D]*}|j|jjd|}|r|p:dSqdS)zt Microsoft Universal CRT SDK directory. Return ------ str path rh)Z10Z81rz kitsroot%srkN)rrrr)rtZversrrrrrUniversalCRTSdkDirs zSystemInfo.UniversalCRTSdkDircCs|t|jdS)z Microsoft Universal C Runtime SDK last version. Return ------ str version r)rrrrwrrrUniversalCRTSdkLastVersions z%SystemInfo.UniversalCRTSdkLastVersioncCs|jdkrdSdS)z Microsoft .NET Framework SDK versions. Return ------ tuple of str versions rh) z4.7.2z4.7.1z4.7z4.6.2z4.6.1z4.6z4.5.2z4.5.1z4.5rrrwrrrrs zSystemInfo.NetFxSdkVersioncCs8d}|jD](}t|jj|}|j|d}|r q4q |S)zu Microsoft .NET Framework SDK directory. Return ------ str path rkZkitsinstallationfolder)rrrrr)rtrrrrrr NetFxSdkDirs  zSystemInfo.NetFxSdkDircCs"t|jd}|j|jjdp |S)zw Microsoft .NET Framework 32bit directory. Return ------ str path zMicrosoft.NET\FrameworkZframeworkdir32rrrrrrtZguess_fwrrrFrameworkDir32s zSystemInfo.FrameworkDir32cCs"t|jd}|j|jjdp |S)zw Microsoft .NET Framework 64bit directory. Return ------ str path zMicrosoft.NET\Framework64Zframeworkdir64rrrrrFrameworkDir64s zSystemInfo.FrameworkDir64cCs |dS)z Microsoft .NET Framework 32bit versions. Return ------ tuple of str versions _find_dot_net_versionsrwrrrFrameworkVersion32 s zSystemInfo.FrameworkVersion32cCs |dS)z Microsoft .NET Framework 64bit versions. Return ------ tuple of str versions @rrwrrrFrameworkVersion64s zSystemInfo.FrameworkVersion64cCs|j|jjd|}t|d|}|p6||dp6d}|jdkrJ|dfS|jdkrt|dd d krld n|d fS|jd krdS|jdkrdSdS)z Find Microsoft .NET Framework versions. Parameters ---------- bits: int Platform number of bits: 32 or 64. Return ------ tuple of str versions zframeworkver%dzFrameworkDir%dr*rkrzv4.0rmNrZv4z v4.0.30319v3.5rl)r v2.0.50727g @)zv3.0r)rrrgetattrrrrR)rtbitsZreg_verZ dot_net_dirrrrrr!s     z!SystemInfo._find_dot_net_versionscs*fddttD}t|dp(dS)a) Return name of the last dir in path or '' if no dir found. Parameters ---------- path: str Use dirs in this path prefix: str Use only dirs starting by this prefix Return ------ str name c3s*|]"}tt|r|r|VqdSr)rr startswith)rSZdir_namer@prefixrrr\Osz0SystemInfo._use_last_dir_name..Nrk)reversedrnext)r@rZ matching_dirsrrrr>s  zSystemInfo._use_last_dir_name)N)rk)#rrrrr r7rr.rrurrr staticmethodrrrrrrrrrrrrrrrrrrrrrrrrrrKsZ    *      * "         rc@sTeZdZdZd=ddZeddZedd Zed d Zed d Z eddZ eddZ eddZ eddZ eddZeddZeddZddZeddZed d!Zed"d#Zed$d%Zed&d'Zed(d)Zed*d+Zed,d-Zed.d/Zed0d1Zed2d3Zed4d5Zed6d7Zd>d9d:Zd;d<Z dS)?EnvironmentInfoaY Return environment variables for specified Microsoft Visual C++ version and platform : Lib, Include, Path and libpath. This function is compatible with Microsoft Visual C++ 9.0 to 14.X. Script created by analysing Microsoft environment configuration files like "vcvars[...].bat", "SetEnv.Cmd", "vcbuildtools.bat", ... Parameters ---------- arch: str Target architecture. vc_ver: float Required Microsoft Visual C++ version. If not set, autodetect the last version. vc_min_ver: float Minimum Microsoft Visual C++ version. NrcCsBt||_t|j|_t|j||_|j|kr>d}tj |dS)Nz.No suitable Microsoft Visual C++ version found) rsrrrrsirr_r4r`)rtrqrZ vc_min_vererrrrrruos    zEnvironmentInfo.__init__cCs|jjS)zk Microsoft Visual Studio. Return ------ float version )rrrwrrrrxs zEnvironmentInfo.vs_vercCs|jjS)zp Microsoft Visual C++ version. Return ------ float version )rrrwrrrrs zEnvironmentInfo.vc_vercsVddg}jdkrDjjddd}|dg7}|dg7}|d|g7}fd d |DS) zu Microsoft Visual Studio Tools. Return ------ list of str paths z Common7\IDEz Common7\ToolsrhTrrCz1Common7\IDE\CommonExtensions\Microsoft\TestWindowzTeam Tools\Performance ToolszTeam Tools\Performance Tools%scsg|]}tjj|qSrrrrrSr@rwrr rVz+EnvironmentInfo.VSTools..)rrr)rtpaths arch_subdirrrwrVSToolss    zEnvironmentInfo.VSToolscCst|jjdt|jjdgS)z Microsoft Visual C++ & Microsoft Foundation Class Includes. Return ------ list of str paths ZIncludezATLMFC\Includerrrrwrrr VCIncludess  zEnvironmentInfo.VCIncludescsbjdkrjjdd}njjdd}d|d|g}jdkrP|d|g7}fd d |DS) z Microsoft Visual C++ & Microsoft Foundation Class Libraries. Return ------ list of str paths .@TrCrLib%sz ATLMFC\Lib%srhz Lib\store%scsg|]}tjj|qSrrrrwrrrrVz/EnvironmentInfo.VCLibraries..)rrr)rtrrrrwr VCLibrariess  zEnvironmentInfo.VCLibrariescCs|jdkrgSt|jjdgS)z Microsoft Visual C++ store references Libraries. Return ------ list of str paths rhzLib\store\references)rrrrrwrrr VCStoreRefss zEnvironmentInfo.VCStoreRefscCs|j}t|jdg}|jdkr"dnd}|j|}|rL|t|jd|g7}|jdkr|d|jjdd}|t|j|g7}n|jdkr|jrd nd }|t|j||jjdd g7}|jj |jj kr|t|j||jjdd g7}n|t|jd g7}|S) zr Microsoft Visual C++ Tools. Return ------ list of str paths Z VCPackagesrmTFBin%srhrrz bin\HostX86%sz bin\HostX64%srBin) rrrrrrrr}rr|rx)rtrtoolsrrr@Zhost_dirrrrVCToolss&     zEnvironmentInfo.VCToolscCsh|jdkr.|jjddd}t|jjd|gS|jjdd}t|jjd}|j}t|d||fgSdS) zw Microsoft Windows SDK Libraries. Return ------ list of str paths rmTrrrrz%sum%sN)rrrrrr _sdk_subdir)rtrrZlibverrrr OSLibrariess zEnvironmentInfo.OSLibrariescCsht|jjd}|jdkr&|t|dgS|jdkr8|j}nd}t|d|t|d|t|d|gSd S) zu Microsoft Windows SDK Include. Return ------ list of str paths includermglrhrkz%ssharedz%sumz%swinrtN)rrrrr)rtr sdkverrrr OSIncludess      zEnvironmentInfo.OSIncludescCst|jjd}g}|jdkr&||j7}|jdkr@|t|dg7}|jdkr||t|jjdt|ddt|d dt|d dt|jjd d d |jdddg7}|S)z} Microsoft Windows SDK Libraries Paths. Return ------ list of str paths Z ReferencesrlrzCommonConfiguration\NeutralrhZ UnionMetadataz'Windows.Foundation.UniversalApiContractz1.0.0.0z%Windows.Foundation.FoundationContractz,Windows.Networking.Connectivity.WwanContractZ ExtensionSDKszMicrosoft.VCLibsrZCommonConfigurationZneutral)rrrrr )rtreflibpathrrr OSLibpath*s0         zEnvironmentInfo.OSLibpathcCs t|S)zs Microsoft Windows SDK Tools. Return ------ list of str paths )list _sdk_toolsrwrrrSdkToolsPs zEnvironmentInfo.SdkToolsccs|jdkr,|jdkrdnd}t|jj|V|js\|jjdd}d|}t|jj|V|jdvr|jrvd }n|jjddd }d |}t|jj|VnB|jdkrt|jjd}|jjdd}|jj}t|d ||fV|jj r|jj Vd S)z Microsoft Windows SDK Tools paths generator. Return ------ generator of str paths rrrzBin\x86Trr)rmrrkrzBin\NETFX 4.0 Tools%sz%s%sN) rrrrrr}rrzrr)rtZbin_dirrr@r rrrr\s(     zEnvironmentInfo._sdk_toolscCs|jj}|rd|SdS)zu Microsoft Windows SDK version subdir. Return ------ str subdir %s\rk)rrrtucrtverrrrrs zEnvironmentInfo._sdk_subdircCs|jdkrgSt|jjdgS)zs Microsoft Windows SDK Setup. Return ------ list of str paths rlZSetup)rrrrrwrrrSdkSetups zEnvironmentInfo.SdkSetupcs|j}|j|jdkr0d}| o,| }n$|p>|}|jdkpR|jdk}g}|rt|fddjD7}|r|fddjD7}|S)zv Microsoft .NET Framework Tools. Return ------ list of str paths rmTrDcsg|]}tj|qSr)rrrSrrrrrrVz+EnvironmentInfo.FxTools..csg|]}tj|qSr)rrrrrrrrV) rrrrzr}r|rxrr)rtrZ include32Z include64rrrrFxToolss  zEnvironmentInfo.FxToolscCs8|jdks|jjsgS|jjdd}t|jjd|gS)z~ Microsoft .Net Framework SDK Libraries. Return ------ list of str paths rhTrzlib\um%s)rrrrrr)rtrrrrNetFxSDKLibrariess z!EnvironmentInfo.NetFxSDKLibrariescCs&|jdks|jjsgSt|jjdgS)z} Microsoft .Net Framework SDK Includes. Return ------ list of str paths rhz include\um)rrrrrwrrrNetFxSDKIncludess z EnvironmentInfo.NetFxSDKIncludescCst|jjdgS)z Microsoft Visual Studio Team System Database. Return ------ list of str paths z VSTSDB\DeployrrwrrrVsTDbs zEnvironmentInfo.VsTDbcCsv|jdkrgS|jdkr0|jj}|jjdd}n |jj}d}d|j|f}t||g}|jdkrr|t||dg7}|S)zn Microsoft Build Engine. Return ------ list of str paths rrTrrkzMSBuild\%0.1f\bin%sZRoslyn)rrrrrrr)rt base_pathrr@buildrrrMSBuilds    zEnvironmentInfo.MSBuildcCs|jdkrgSt|jjdgS)zt Microsoft HTML Help Workshop. Return ------ list of str paths rzHTML Help Workshop)rrrrrwrrrHTMLHelpWorkshops z EnvironmentInfo.HTMLHelpWorkshopcCsD|jdkrgS|jjdd}t|jjd}|j}t|d||fgS)z Microsoft Universal C Runtime SDK Libraries. Return ------ list of str paths rhTrrz%sucrt%s)rrrrrr _ucrt_subdir)rtrrrrrr UCRTLibraries s zEnvironmentInfo.UCRTLibrariescCs.|jdkrgSt|jjd}t|d|jgS)z Microsoft Universal C Runtime SDK Include. Return ------ list of str paths rhr z%sucrt)rrrrr")rtr rrr UCRTIncludess zEnvironmentInfo.UCRTIncludescCs|jj}|rd|SdS)z Microsoft Universal C Runtime SDK version subdir. Return ------ str subdir rrk)rrrrrrr".s zEnvironmentInfo._ucrt_subdircCs(d|jkrdkrnngS|jjgS)zk Microsoft Visual F#. Return ------ list of str paths rr)rrrrwrrrFSharp;s zEnvironmentInfo.FSharpc Csd|j}|jjddd}g}|jj}t|dd}t|rft |t |d}||t |dg7}|t |d g7}d |jd d t |j d f}t ||D]&\}}t ||||} t| r| Sqd S) z Microsoft Visual C++ runtime redistributable dll. Return ------ str path zvcruntime%d0.dllTrrz\Toolsz\RedistrGZonecorerEzMicrosoft.VC%d.CRT N)rrrr>rrrrXrrrr"rrrr) rtrNrprefixesZ tools_pathZ redist_pathZcrt_dirsrZcrt_dirr@rrrVCRuntimeRedistJs  zEnvironmentInfo.VCRuntimeRedistTcCst|d|j|j|j|jg||d|j|j|j|j |j g||d|j|j|j |j g||d|j |j|j|j|j|j|j|j|jg |d}|jdkrt|jr|j|d<|S)z Return environment dict. Parameters ---------- exists: bool It True, only return existing paths. Return ------ dict environment r rrr@)r rrr@rr])dict _build_pathsrr r$rrr rr#rrrrrrrrr r!r%rrr()rtexistsrfrrr return_envosV   + zEnvironmentInfo.return_envc Csntj|}t|dt}t||}|rsH     45 'y=