o _a@sdZddlZddlmZddlmZmZddlmZm Z m Z m Z ddl Z ddl Z ddlZddlZddlZddlZddlmZddlmZdd lmZed kr[ddlZdd lmZn Gd d d ZeZeejjfZ zddl!m"Z"Wn e y|YnwddZ#d/ddZ$ddZ%ddZ&dddddZ'ddZ(ddZ)d d!Z*d"d#Z+d0d%d&Z,Gd'd(d(Z-Gd)d*d*Z.Gd+d,d,Z/Gd-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)listdirpathsep)joinisfileisdirdirname) LegacyVersion)unique_everseen) get_unpatchedWindows)environc@seZdZdZdZdZdZdS)winregN)__name__ __module__ __qualname__ HKEY_USERSHKEY_CURRENT_USERHKEY_LOCAL_MACHINEHKEY_CLASSES_ROOTrr1/usr/lib/python3/dist-packages/setuptools/msvc.pyr+s r)Regc Csd}|d|f}zt|d}Wn#ty3z|d|f}t|d}Wn ty0d}YnwYnw|rAt|d}t|rA|Stt|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 installdirz Wow6432Node\N vcvarsall.bat)r get_valueKeyErrorrrr msvc9_find_vcvarsall)versionvc_basekey productdir vcvarsallrrrrBs$      rx86c Osztt}|||g|Ri|WStjjyYn ty$Ynwzt||WStjjyB}zt|||d}~ww)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 distutilserrorsDistutilsPlatformError ValueErrorEnvironmentInfo return_env_augment_exception)verarchargskwargsorigexcrrrr&ls  r&c CszttjddtjtjB}Wn tyYdSwd}d}|^tD]D}z t||\}}}Wn ty<Yn8w|ri|tj krit |rizt t |}Wn t tfy[Yq%w|dkri||kri||}}q%Wd||fSWd||fS1swY||fS)0Python 3.8 "distutils/_msvccompiler.py" backportz'Software\Microsoft\VisualStudio\SxS\VC7rNNN)rOpenKeyrKEY_READKEY_WOW64_32KEYOSError itertoolscount EnumValueREG_SZrintfloatr* TypeError)r" best_versionbest_dirivvc_dirvtr rrr_msvc14_find_vc2015sH          rHcCstdp td}|sdSztt|dddddd d d d d d dddg jddd}Wntjtt fy;YdSwt|ddd}t |rKd|fSdS)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) ProgramFilesr5zMicrosoft Visual Studio Installerz vswhere.exez-latestz -prereleasez -requiresAnyz -requiresz1Microsoft.VisualStudio.Component.VC.Tools.x86.x64z)Microsoft.VisualStudio.Workload.WDExpressz -propertyinstallationPathz -products*mbcsstrict)encodingr(VC AuxiliaryBuild) rget subprocess check_outputrdecodestripCalledProcessErrorr:UnicodeDecodeErrorr)rootpathrrr_msvc14_find_vc2017s2     r^x64armarm64)r% x86_amd64x86_arm x86_arm64c Cst\}}d}|tvrt|}nd|vrdnd}|rDt|ddddd|d d }zd dl}|j|d d d}WntttfyCd}Ynw|sUt\}}|rUt|d|dd }|sYdSt|d}t|sddS|rjt|sld}||fS)r4Namd64r_r%z..redistMSVCz**zMicrosoft.VC14*.CRTzvcruntime140.dllrT) recursivezMicrosoft.VC140.CRTr5r) r^PLAT_SPEC_TO_RUNTIMErglob ImportErrorr: LookupErrorrHr) plat_spec_rC vcruntimevcruntime_platvcredistrkrBr$rrr_msvc14_find_vcvarsalls<     rsc Csdtvr ddtDSt|\}}|stjdztjd||tj dj ddd }Wntj yF}z tjd |j |d }~wwd dd d| DD}|r[||d<|S)r4DISTUTILS_USE_SDKcSsi|] \}}||qSrlower).0r"valuerrr sz&_msvc14_get_vc_env..zUnable to find vcvarsall.batzcmd /u /c "{}" {} && set)stderrzutf-16lereplace)r(zError executing {}NcSs$i|]\}}}|r|r||qSrru)rwr"rorxrrrryscss|]}|dVqdS)=N) partition)rwlinerrr sz%_msvc14_get_vc_env..py_vcruntime_redist)ritemsrsr'r(r)rVrWformatSTDOUTrXrZcmd splitlines)rnr$rpoutr3envrrr_msvc14_get_vc_envs<    rc Cs4zt|WStjjy}zt|dd}~ww)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)rr'r(r)r-)rnr3rrrmsvc14_get_vc_env(s  rcOsJdtjvrddl}t|jtdkr|jjj|i|Stt |i|S)z Patched "distutils._msvccompiler.gen_lib_options" for fix compatibility between "numpy.distutils" and "distutils._msvccompiler" (for Numpy < 1.11.2) znumpy.distutilsrNz1.11.2) sysmodulesnumpyr __version__r' ccompilergen_lib_optionsr msvc14_gen_lib_options)r0r1nprrrrBs rrcCs|jd}d|vsd|vrLd}|jdit}d}|dkr5|ddkr0|d 7}n|d 7}n|d krD|d 7}||d 7}n|dkrL|d7}|f|_dS)zl Add details to the exception message to help guide the user as to what action will resolve it. rr$zvisual cz;Microsoft Visual C++ {version:0.1f} or greater is required.z-www.microsoft.com/download/details.aspx?id=%d"@ia64riz( 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 rzd Get it with "Microsoft C++ Build Tools": https://visualstudio.microsoft.com/visual-cpp-build-tools/Nr)r0rvrlocalsfind)r3r r/messagetmpl msdownloadrrrr-Os    r-c@sbeZdZdZeddZddZe ddZ dd Z d d Z dd dZ dddZdddZdS) PlatformInfoz Current and Target Architectures information. Parameters ---------- arch: str Target architecture. processor_architecturercCs|dd|_dS)Nr_re)rvr{r/)selfr/rrr__init__szPlatformInfo.__init__cCs|j|jdddS)zs Return Target CPU architecture. Return ------ str Target CPU ror N)r/rrrrr target_cpus zPlatformInfo.target_cpucC |jdkS)z Return True if target CPU is x86 32 bits.. Return ------ bool CPU is x86 32 bits r%rrrrr target_is_x86 zPlatformInfo.target_is_x86cCr)z Return True if current CPU is x86 32 bits.. Return ------ bool CPU is x86 32 bits r% current_cpurrrrcurrent_is_x86rzPlatformInfo.current_is_x86FcC.|jdkr |r dS|jdkr|rdSd|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) r%rre\x64\%srrhidex86r_rrr current_dir zPlatformInfo.current_dircCr)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) r%rrerrrrrrr target_dirrzPlatformInfo.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. r%r\z\%s_)rrrr{)rforcex86currentrrr cross_dirs  zPlatformInfo.cross_dirN)FFF)rrr__doc__rrUrvrrpropertyrrrrrrrrrrrts   rc@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)r platform_inforrrrs zRegistryInfo.__init__cCdS)z Microsoft Visual Studio root registry key. Return ------ str Registry key VisualStudiorrrrr visualstudio zRegistryInfo.visualstudiocC t|jdS)z Microsoft Visual Studio SxS registry key. Return ------ str Registry key SxS)rrrrrrsxs zRegistryInfo.sxscCr)z| Microsoft Visual C++ VC7 registry key. Return ------ str Registry key VC7rrrrrrvcrzRegistryInfo.vccCr)z Microsoft Visual Studio VS7 registry key. Return ------ str Registry key VS7rrrrrvsrzRegistryInfo.vscCr)z Microsoft Visual C++ for Python registry key. Return ------ str Registry key zDevDiv\VCForPythonrrrrr vc_for_python(rzRegistryInfo.vc_for_pythoncCr)zq Microsoft SDK registry key. Return ------ str Registry key zMicrosoft SDKsrrrrr microsoft_sdk4rzRegistryInfo.microsoft_sdkcCr)z Microsoft Windows/Platform SDK registry key. Return ------ str Registry key r rrrrrr windows_sdk@rzRegistryInfo.windows_sdkcCr)z Microsoft .NET Framework SDK registry key. Return ------ str Registry key NETFXSDKrrrrr netfx_sdkLrzRegistryInfo.netfx_sdkcCr)z Microsoft Windows Kits Roots registry key. Return ------ str Registry key zWindows Kits\Installed Rootsrrrrrwindows_kits_rootsXrzRegistryInfo.windows_kits_rootsFcCs$|js|r dnd}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 r Wow6432NodeSoftware Microsoft)rrr)rr"r%node64rrr microsoftdszRegistryInfo.microsoftc Cstj}tj}tj}|j}|jD]l}d}z ||||d|}Wn+ttfyI|j sEz ||||dd|}WnttfyDYYqwYqYnwz)zt ||dWW|r^||SSttfykYnwW|rs||q|r{||wwdS)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) rr8r7CloseKeyrHKEYSr:IOErrorrr QueryValueEx) rr"namekey_readopenkeyclosekeymshkeybkeyrrrlookupwsD   zRegistryInfo.lookupNr)rrrrrrrrrrrrrrrrrrrrrrrrrrrrs8          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. WinDirrrJrINcCs2||_|jj|_||_|p||_|_dSr)rirfind_programdata_vs_versknown_vs_paths_find_latest_available_vs_vervs_vervc_ver)r registry_inforrrrrs    zSystemInfo.__init__cCs>|}|s|jstjdt|}||jt|dS)zm Find the latest VC version Return ------ float version z%No Microsoft Visual C++ version foundri)find_reg_vs_versrr'r(r)setupdatesorted)r reg_vc_versvc_versrrrrs   z(SystemInfo._find_latest_available_vs_verc Csb|jj}|jj|jj|jjf}g}t|jj|D]\}}z t |||dtj }Wn t t fy5Yqw|lt |\}}} t|D]*} tttt|| d} | |vr`|| Wdn1sjwYqEt|D](} tttt|| } | |vr|| Wdn1swYqtWdn1swYqt|S)z Find Microsoft Visual Studio versions available in registry. Return ------ list of float Versions rN)rrrrrr;productrrr7r8r:r QueryInfoKeyrange contextlibsuppressr*r@r=appendEnumKeyr) rrvckeysvs_versrr"rsubkeysvaluesrorDr.rrrrs>        zSystemInfo.find_reg_vs_versc Csi}d}zt|}Wn ttfy|YSw|D]F}z8t||d}t|ddd }t|}Wdn1s:wY|d}tt|d||||d <Wqtttfy`Yqw|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.jsonrtzutf-8)rPNrL VC\Tools\MSVCinstallationVersion) rr:rrrjsonload_as_float_versionr) r vs_versions instances_dir hashed_namesr state_path state_filestatevs_pathrrrrs0    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)rdefaultrrr VSInstallDir)s zSystemInfo.VSInstallDircCs,|p|}t|sd}tj||S)zm Microsoft Visual C++ directory. Return ------ str path z(Microsoft Visual C++ directory not found) _guess_vc_guess_vc_legacyrr'r(r))rr]msgrrr VCInstallDir:s   zSystemInfo.VCInstallDirc Cs|jdkrdSz|j|j}Wn ty|j}Ynwt|d}zt|d}|||_t||WStt t fy@YdSw)zl Locate Visual C++ for VS2017+. Return ------ str path rrrri) rrrr rrrrr:r IndexError)rvs_dirguess_vcrrrrrLs       zSystemInfo._guess_vccCsbt|jd|j}t|jjd|j}|j|d}|r!t|dn|}|j|jjd|jp0|S)z{ Locate Visual C++ for versions prior to 2017. Return ------ str path z Microsoft Visual Studio %0.1f\VCr rrQ)rr rrrrr)rr reg_path python_vc default_vcrrrrjs zSystemInfo._guess_vc_legacycCsJ|jdkrdS|jdkrdS|jdkrdS|jdkrdS|jd kr#d Sd S) z Microsoft Windows SDK versions for specified MSVC++ version. Return ------ tuple of str versions r)z7.0z6.1z6.0ar)z7.1z7.0a&@)z8.0z8.0a(@)8.1z8.1ar)z10.0rNrrrrrWindowsSdkVersion~s     zSystemInfo.WindowsSdkVersioncC|t|jdS)zt Microsoft Windows SDK last version. Return ------ str version lib)_use_last_dir_namer WindowsSdkDirrrrrWindowsSdkLastVersion z SystemInfo.WindowsSdkLastVersioncCs d}|jD]}t|jjd|}|j|d}|rnq|r"t|s:t|jjd|j}|j|d}|r:t|d}|r@t|s_|jD]}|d|d}d |}t|j |}t|r^|}qC|ret|s{|jD]}d |}t|j |}t|rz|}qh|st|j d }|S) zn Microsoft Windows SDK directory. Return ------ str path rzv%sinstallationfolderr rWinSDKNrzMicrosoft SDKs\Windows Kits\%szMicrosoft SDKs\Windows\v%s PlatformSDK) rrrrrrrrrfindrJr)rsdkdirr.locr] install_baseintverdrrrr s<          zSystemInfo.WindowsSdkDirc Cs|jdkr d}d}nd}|jdkrdnd}|jjd|d}d ||d d f}g}|jd kr?|jD] }|t|jj||g7}q1|jD]}|t|jj d ||g7}qB|D]}|j |d}|rc|SqTdS)zy Microsoft Windows SDK executable directory. Return ------ str path r#r(rTF)r_rzWinSDK-NetFx%dTools%sr-rzv%sAr#N) rrrr{NetFxSdkVersionrrrrrr) rnetfxverr/rfxregpathsr.r]execpathrrrWindowsSDKExecutablePaths&    z#SystemInfo.WindowsSDKExecutablePathcCs&t|jjd|j}|j|dpdS)zl Microsoft Visual F# directory. Return ------ str path z%0.1f\Setup\F#r#r)rrrrr)rr]rrrFSharpInstallDirs zSystemInfo.FSharpInstallDircCsF|jdkrdnd}|D]}|j|jjd|}|r |pdSq dS)zt Microsoft Universal CRT SDK directory. Return ------ str path r)1081rz kitsroot%srN)rrrr)rversr.r'rrrUniversalCRTSdkDirs   zSystemInfo.UniversalCRTSdkDircCr)z Microsoft Universal C Runtime SDK last version. Return ------ str version r)rrr9rrrrUniversalCRTSdkLastVersionr"z%SystemInfo.UniversalCRTSdkLastVersioncCs|jdkrdSdS)z Microsoft .NET Framework SDK versions. Return ------ tuple of str versions r) z4.7.2z4.7.1z4.7z4.6.2z4.6.1z4.6z4.5.2z4.5.1z4.5rrrrrrr/s zSystemInfo.NetFxSdkVersioncCs:d}|jD]}t|jj|}|j|d}|r|Sq|S)zu Microsoft .NET Framework SDK directory. Return ------ str path rkitsinstallationfolder)r/rrrr)rr'r.r(rrr NetFxSdkDir*s zSystemInfo.NetFxSdkDircC"t|jd}|j|jjdp|S)zw Microsoft .NET Framework 32bit directory. Return ------ str path zMicrosoft.NET\Frameworkframeworkdir32rrrrrrguess_fwrrrFrameworkDir32< zSystemInfo.FrameworkDir32cCr=)zw Microsoft .NET Framework 64bit directory. Return ------ str path zMicrosoft.NET\Framework64frameworkdir64r?r@rrrFrameworkDir64LrCzSystemInfo.FrameworkDir64cC |dS)z Microsoft .NET Framework 32bit versions. Return ------ tuple of str versions _find_dot_net_versionsrrrrFrameworkVersion32\ zSystemInfo.FrameworkVersion32cCrF)z Microsoft .NET Framework 64bit versions. Return ------ tuple of str versions @rHrrrrFrameworkVersion64hrKzSystemInfo.FrameworkVersion64cCs|j|jjd|}t|d|}|p||dpd}|jdkr%|dfS|jdkr<|dd d kr8d d fS|d fS|jd krCdS|jdkrJdSdS)z Find Microsoft .NET Framework versions. Parameters ---------- bits: int Platform number of bits: 32 or 64. Return ------ tuple of str versions zframeworkver%dzFrameworkDir%drErrzv4.0rNrv4z v4.0.30319v3.5r)rO v2.0.50727g @)zv3.0rP)rrrgetattrrrrv)rbitsreg_ver dot_net_dirr.rrrrIts  $  z!SystemInfo._find_dot_net_versionscs*fddttD}t|dpdS)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)rwdir_namer]prefixrrrs  z0SystemInfo._use_last_dir_name..Nr)reversedrnext)r]rX matching_dirsrrWrrs  zSystemInfo._use_last_dir_namerr)#rrrrrrUrrJr rrrr staticmethodrrr rrrrr!r r4r5r9r:r/r<rBrErJrMrIrrrrrrs\    *      * "          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)?r+aY 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|krd}tj |dS)Nz.No suitable Microsoft Visual C++ version found) rrrrrsirr'r(r))rr/r vc_min_vererrrrrrs    zEnvironmentInfo.__init__cC|jjS)zk Microsoft Visual Studio. Return ------ float version )r^rrrrrr zEnvironmentInfo.vs_vercCra)zp Microsoft Visual C++ version. Return ------ float version )r^rrrrrrrbzEnvironmentInfo.vc_vercsVddg}jdkr"jjddd}|dg7}|dg7}|d|g7}fd d |DS) zu Microsoft Visual Studio Tools. Return ------ list of str paths z Common7\IDEz Common7\ToolsrTrr_z1Common7\IDE\CommonExtensions\Microsoft\TestWindowzTeam Tools\Performance ToolszTeam Tools\Performance Tools%scg|] }tjj|qSrrr^r rwr]rrr z+EnvironmentInfo.VSTools..)rrr)rpaths arch_subdirrrrVSToolss   zEnvironmentInfo.VSToolscCst|jjdt|jjdgS)z Microsoft Visual C++ & Microsoft Foundation Class Includes. Return ------ list of str paths IncludezATLMFC\Includerr^rrrrr VCIncludess zEnvironmentInfo.VCIncludescsbjdkr jjdd}njjdd}d|d|g}jdkr(|d|g7}fd d |DS) z Microsoft Visual C++ & Microsoft Foundation Class Libraries. Return ------ list of str paths .@Tr_rLib%sz ATLMFC\Lib%srz Lib\store%scrdrrmrfrrrrgrhz/EnvironmentInfo.VCLibraries..)rrr)rrjrirrr VCLibrariess  zEnvironmentInfo.VCLibrariescC|jdkrgSt|jjdgS)z Microsoft Visual C++ store references Libraries. Return ------ list of str paths rzLib\store\references)rrr^rrrrr VCStoreRefss zEnvironmentInfo.VCStoreRefscCs|j}t|jdg}|jdkrdnd}|j|}|r&|t|jd|g7}|jdkr?d|jjdd}|t|j|g7}|S|jdkrw|jrKd nd }|t|j||jjdd g7}|jj |jj kru|t|j||jjdd g7}|S|t|jd g7}|S) zr Microsoft Visual C++ Tools. Return ------ list of str paths VCPackagesrTFBin%srrqroz bin\HostX86%sz bin\HostX64%srpBin) r^rrrrrrrrrr)rr^toolsrrjr]host_dirrrrVCTools(s0    zEnvironmentInfo.VCToolscCsd|jdkr|jjddd}t|jjd|gS|jjdd}t|jjd}|j}t|d||fgS)zw Microsoft Windows SDK Libraries. Return ------ list of str paths rTrcrrrprz%sum%s)rrrrr^r  _sdk_subdir)rrjrlibverrrr OSLibrariesMs zEnvironmentInfo.OSLibrariescCsdt|jjd}|jdkr|t|dgS|jdkr|j}nd}t|d|t|d|t|d|gS) zu Microsoft Windows SDK Include. Return ------ list of str paths includerglrrz%ssharedz%sumz%swinrt)rr^r rr|)rrsdkverrrr OSIncludesas     zEnvironmentInfo.OSIncludescCst|jjd}g}|jdkr||j7}|jdkr |t|dg7}|jdkrM||t|jjdt|ddt|d dt|d dt|jjd d d |jdddg7}|S)z} Microsoft Windows SDK Libraries Paths. Return ------ list of str paths ReferencesrrzCommonConfiguration\Neutralr UnionMetadataz'Windows.Foundation.UniversalApiContractz1.0.0.0z%Windows.Foundation.FoundationContractz,Windows.Networking.Connectivity.WwanContract ExtensionSDKszMicrosoft.VCLibsr CommonConfigurationneutral)rr^r rr~)rreflibpathrrr OSLibpathys2         zEnvironmentInfo.OSLibpathcCs t|S)zs Microsoft Windows SDK Tools. Return ------ list of str paths )list _sdk_toolsrrrrSdkToolsrzEnvironmentInfo.SdkToolsccs|jdkr|jdkr dnd}t|jj|V|js/|jjdd}d|}t|jj|V|jdvrQ|jr.crr)rrErrrrrgr) rr^rrrrrrJrM)rr include32 include64ryrrrFxToolss"    zEnvironmentInfo.FxToolscCs8|jdks |jjs gS|jjdd}t|jjd|gS)z~ Microsoft .Net Framework SDK Libraries. Return ------ list of str paths rTrpzlib\um%s)rr^r<rrr)rrjrrrNetFxSDKLibrariess z!EnvironmentInfo.NetFxSDKLibrariescCs&|jdks |jjs gSt|jjdgS)z} Microsoft .Net Framework SDK Includes. Return ------ list of str paths rz include\um)rr^r<rrrrrNetFxSDKIncludess z EnvironmentInfo.NetFxSDKIncludescCst|jjdgS)z Microsoft Visual Studio Team System Database. Return ------ list of str paths z VSTSDB\DeployrerrrrVsTDb$s zEnvironmentInfo.VsTDbcCsv|jdkrgS|jdkr|jj}|jjdd}n|jj}d}d|j|f}t||g}|jdkr9|t||dg7}|S)zn Microsoft Build Engine. Return ------ list of str paths rroTrqrzMSBuild\%0.1f\bin%sRoslyn)rr^r rrr r)r base_pathrjr]buildrrrMSBuild0s    zEnvironmentInfo.MSBuildcCrt)zt Microsoft HTML Help Workshop. Return ------ list of str paths rzHTML Help Workshop)rrr^r rrrrHTMLHelpWorkshopLrz EnvironmentInfo.HTMLHelpWorkshopcCsD|jdkrgS|jjdd}t|jjd}|j}t|d||fgS)z Microsoft Universal C Runtime SDK Libraries. Return ------ list of str paths rTrprz%sucrt%s)rrrrr^r9 _ucrt_subdir)rrjrrrrr UCRTLibraries[s zEnvironmentInfo.UCRTLibrariescCs.|jdkrgSt|jjd}t|d|jgS)z Microsoft Universal C Runtime SDK Include. Return ------ list of str paths rrz%sucrt)rrr^r9r)rrrrr UCRTIncludesms zEnvironmentInfo.UCRTIncludescCr)z Microsoft Universal C Runtime SDK version subdir. Return ------ str subdir rr)r^r:rrrrr}rzEnvironmentInfo._ucrt_subdircCs$d|jkr dkr gS|jjgS)zk Microsoft Visual F#. Return ------ list of str paths rr)rr^r5rrrrFSharps  zEnvironmentInfo.FSharpc Csd|j}|jjddd}g}|jj}t|dd}t|r3t |t |d}||t |dg7}|t |d g7}d |jd d t |j d f}t ||D]\}}t ||||} t| rd| SqQd S) z Microsoft Visual C++ runtime redistributable dll. Return ------ str path zvcruntime%d0.dllTrprz\Toolsz\RedistrionecorerfzMicrosoft.VC%d.CRT N)rrrrYr^rrr{rrrr?rr;rr) rrprjprefixes tools_path redist_pathcrt_dirsrXcrt_dirr]rrrVCRuntimeRedists$  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}|jdkrWt|jrW|j|d<|S)z Return environment dict. Parameters ---------- exists: bool It True, only return existing paths. Return ------ dict environment rrrr])rrrr]r6r)dict _build_pathsrnrrrrsr~rrrrurr{rkrrrrrrrrr)rexistsrrrrr,sV  zEnvironmentInfo.return_envc Csntj|}t|dt}t||}|rttt |n|}|s.d| }t j |t|} t| S)aC Given an environment variable name and specified paths, return a pathsep-separated string of paths containing unique, extant, directories from those paths and from the environment variable. Raise an error if no paths are resolved. Parameters ---------- name: str Environment variable name spec_path_lists: list of str Paths exists: bool It True, only return existing paths. Return ------ str Pathsep-separated paths rz %s environment variable is empty)r;chain from_iterablerrUr rrfilterrupperr'r(r)r r) rrspec_path_listsr spec_paths env_pathsri extant_pathsr unique_pathsrrrrs     zEnvironmentInfo._build_paths)Nr)T)!rrrrrrrrrkrnrsrur{r~rrrrr|rrrrrrrrrrrrr,rrrrrr+sl        $   #  #              " 2r+)r%r\)1rriorosrros.pathrrrrrrplatformr;rVdistutils.errorsr'#setuptools.extern.packaging.versionr setuptools.extern.more_itertoolsr monkeyr systemrrrrlr(r)_msvc9_suppress_errorsdistutils.msvc9compilerrrr&rHr^rjrsrrrr-rrrr+rrrrsd        *&&'$ %s: