3 M(Y @sdZddlZddlZddlZddlZddlZddlmZddl m Z ddl m Z ej dkrpddl mZejZnGd d d ZeZeejjfZydd lmZWnek rYnXd d Zd ddZddZddZd!ddZGdddZGdddZGdddZGdddZ dS)"a@ 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.0: Microsoft Visual C++ Build Tools 2015 (x86, x64, arm) Microsoft Visual Studio 2017 (x86, x64, arm, arm64) Microsoft Visual Studio Build Tools 2017 (x86, x64, arm, arm64) N) LegacyVersion) filterfalse) get_unpatchedWindows)winregc@seZdZdZdZdZdZdS)rN)__name__ __module__ __qualname__ HKEY_USERSHKEY_CURRENT_USERHKEY_LOCAL_MACHINEHKEY_CLASSES_ROOTrr=/private/tmp/pip-build-nl73fm5q/setuptools/setuptools/msvc.pyr(sr)RegcCsd}|d|f}ytj|d}WnJtk rjy|d|f}tj|d}Wntk rdd}YnXYnX|rtjjjj|d}tjj|r|Stt|S)a+ Patched "distutils.msvc9compiler.find_vcvarsall" to use the standalone compiler build for Python (VCForPython). Fall back to original behavior when the standalone compiler is not available. Redirect the path of "vcvarsall.bat". Known supported compilers ------------------------- Microsoft Visual C++ 9.0: Microsoft Visual C++ Compiler for Python 2.7 (x86, amd64) Parameters ---------- version: float Required Microsoft Visual C++ version. Return ------ vcvarsall.bat path: str z-Software\%sMicrosoft\DevDiv\VCForPython\%0.1f installdirz Wow6432Node\Nz vcvarsall.bat) r get_valueKeyErrorospathjoinisfilermsvc9_find_vcvarsall)versionZVC_BASEkey productdir vcvarsallrrrr?s   rx86cOsytt}|||f||Stjjk r2Yntk rDYnXyt||jStjjk r}zt|||WYdd}~XnXdS)a Patched "distutils.msvc9compiler.query_vcvarsall" for support extra compilers. Set environment without use of "vcvarsall.bat". 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) Parameters ---------- ver: float Required Microsoft Visual C++ version. arch: str Target architecture. Return ------ environment: dict N) rmsvc9_query_vcvarsall distutilserrorsDistutilsPlatformError ValueErrorEnvironmentInfo return_env_augment_exception)verarchargskwargsorigexcrrrr js r cCsny tt|Stjjk r$YnXyt|ddjStjjk rh}zt|dWYdd}~XnXdS)a' Patched "distutils._msvccompiler._get_vc_env" for support extra compilers. Set environment without use of "vcvarsall.bat". Known supported compilers ------------------------- Microsoft Visual C++ 14.0: Microsoft Visual C++ Build Tools 2015 (x86, x64, arm) Microsoft Visual Studio 2017 (x86, x64, arm, arm64) Microsoft Visual Studio Build Tools 2017 (x86, x64, arm, arm64) Parameters ---------- plat_spec: str Target architecture. Return ------ environment: dict g,@) vc_min_verN)rmsvc14_get_vc_envr!r"r#r%r&r')Z plat_specr-rrrr/s  r/cOsBdtjkr4ddl}t|jtdkr4|jjj||Stt ||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) sysmodulesZnumpyr __version__r!Z ccompilerZgen_lib_optionsrmsvc14_gen_lib_options)r*r+nprrrr3s  r3rcCs|jd}d|jks"d|jkrd}|jft}d}|dkrr|jjddkrh|d 7}||d 7}q|d 7}n.|d kr|d 7}||d7}n|dkr|d7}|f|_dS)zl Add details to the exception message to help guide the user as to what action will resolve it. rrzvisual cz0Microsoft Visual C++ {version:0.1f} is required.z-www.microsoft.com/download/details.aspx?id=%dg"@Zia64rz* Get it with "Microsoft Windows SDK 7.0": iB z% Get it from http://aka.ms/vcpython27g$@z* Get it with "Microsoft Windows SDK 7.1": iW g,@zj Get it with "Microsoft Visual C++ Build Tools": http://landinghub.visualstudio.com/visual-cpp-build-toolsN)r*lowerformatlocalsfind)r-rr)messagetmplZ msdownloadrrrr's   r'c@sbeZdZdZejddjZddZe ddZ dd Z d d Z dd dZ dddZdddZdS) PlatformInfoz Current and Target Architectures informations. Parameters ---------- arch: str Target architecture. Zprocessor_architecturercCs|jjdd|_dS)Nx64amd64)r6replacer))selfr)rrr__init__szPlatformInfo.__init__cCs|j|jjdddS)N_r)r)r9)r@rrr target_cpuszPlatformInfo.target_cpucCs |jdkS)Nr)rC)r@rrr target_is_x86szPlatformInfo.target_is_x86cCs |jdkS)Nr) current_cpu)r@rrrcurrent_is_x86szPlatformInfo.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 ------ subfolder: str ' arget', or '' (see hidex86 parameter) rrr>z\x64z\%s)rE)r@hidex86r=rrr current_dir szPlatformInfo.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 ------ subfolder: str '\current', or '' (see hidex86 parameter) rrr>z\x64z\%s)rC)r@rGr=rrr target_dirszPlatformInfo.target_dircCs0|rdn|j}|j|krdS|jjdd|S)ao Cross platform specific subfolder. Parameters ---------- forcex86: bool Use 'x86' as current architecture even if current acritecture is not x86. Return ------ subfolder: str '' if target architecture is current architecture, '\current_target' if not. rr\z\%s_)rErCrIr?)r@forcex86currentrrr cross_dir5szPlatformInfo.cross_dirN)FF)FF)F)rr r __doc__safe_envgetr6rErApropertyrCrDrFrHrIrMrrrrr<s   r<c@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 informations. Parameters ---------- platform_info: PlatformInfo "PlatformInfo" instance. cCs ||_dS)N)pi)r@Z platform_inforrrrAZszRegistryInfo.__init__cCsdS)z< Microsoft Visual Studio root registry key. Z VisualStudior)r@rrr visualstudio]szRegistryInfo.visualstudiocCstjj|jdS)z; Microsoft Visual Studio SxS registry key. ZSxS)rrrrT)r@rrrsxsdszRegistryInfo.sxscCstjj|jdS)z8 Microsoft Visual C++ VC7 registry key. ZVC7)rrrrU)r@rrrvckszRegistryInfo.vccCstjj|jdS)z; Microsoft Visual Studio VS7 registry key. ZVS7)rrrrU)r@rrrvsrszRegistryInfo.vscCsdS)z? Microsoft Visual C++ for Python registry key. zDevDiv\VCForPythonr)r@rrr vc_for_pythonyszRegistryInfo.vc_for_pythoncCsdS)z- Microsoft SDK registry key. zMicrosoft SDKsr)r@rrr microsoft_sdkszRegistryInfo.microsoft_sdkcCstjj|jdS)z> Microsoft Windows/Platform SDK registry key. r)rrrrY)r@rrr windows_sdkszRegistryInfo.windows_sdkcCstjj|jdS)z< Microsoft .NET Framework SDK registry key. ZNETFXSDK)rrrrY)r@rrr netfx_sdkszRegistryInfo.netfx_sdkcCsdS)z< Microsoft Windows Kits Roots registry key. zWindows Kits\Installed Rootsr)r@rrrwindows_kits_rootsszRegistryInfo.windows_kits_rootsFcCs(|jjs|rdnd}tjjd|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: value rZ Wow6432NodeZSoftware Microsoft)rSrFrrr)r@rrZnode64rrr microsoftszRegistryInfo.microsoftcCstj}tj}|j}x|jD]}y||||d|}WnZttfk r|jjsy||||dd|}Wqttfk rwYqXnwYnXytj ||dSttfk rYqXqWdS)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 rTN) rKEY_READOpenKeyr^HKEYSOSErrorIOErrorrSrF QueryValueEx)r@rnamer_Zopenkeymshkeybkeyrrrlookups"   zRegistryInfo.lookupN)F)rr r rNrr r r rrarArQrTrUrVrWrXrYrZr[r\r^rirrrrrRLs"          rRc@s$eZdZdZejddZejddZejdeZd3ddZ d d Z d d Z e d dZ e ddZddZddZe ddZe ddZe ddZe ddZe ddZe dd Ze d!d"Ze d#d$Ze d%d&Ze d'd(Ze d)d*Ze d+d,Ze d-d.Zd/d0Zd4d1d2ZdS)5 SystemInfoz Microsoft Windows and Visual Studio related system inormations. Parameters ---------- registry_info: RegistryInfo "RegistryInfo" instance. vc_ver: float Required Microsoft Visual C++ version. WinDirr ProgramFileszProgramFiles(x86)NcCs"||_|jj|_|p|j|_dS)N)rirS_find_latest_available_vc_vervc_ver)r@Z registry_infororrrrAs zSystemInfo.__init__c Cs6y |jdStk r0d}tjj|YnXdS)Nrz%No Microsoft Visual C++ version foundr5)find_available_vc_vers IndexErrorr!r"r#)r@errrrrrns  z(SystemInfo._find_latest_available_vc_verc Cs6|jj}|jj|jj|jjf}g}x|jjD]}x|D]}ytj|||dtj}Wnt t fk rpw8YnXtj |\}}} xPt |D]D} y*t tj|| d} | |kr|j| Wqtk rYqXqWxPt |D]D} y(t tj|| } | |kr|j| Wqtk r YqXqWq8Wq.Wt|S)zC Find all available Microsoft Visual C++ versions. r)rmr^rVrXrWrarr`r_rbrcZ QueryInfoKeyrangefloatZ EnumValueappendr$EnumKeysorted) r@rfZvckeysZvc_versrgrrhZsubkeysvaluesrBir(rrrrps2   z!SystemInfo.find_available_vc_verscCs6d|j}tjj|j|}|jj|jjd|jp4|S)z4 Microsoft Visual Studio directory. zMicrosoft Visual Studio %0.1fz%0.1f)rorrrProgramFilesx86rmrirW)r@redefaultrrr VSInstallDir s zSystemInfo.VSInstallDircCs|j|jp|j}tjj|jjd|j}|jj |d}|rNtjj|dn|}|jj |jj d|jpl|}tjj |sd}t j j||S)z1 Microsoft Visual C++ directory. z%0.1frZVCz(Microsoft Visual C++ directory not found)r| _guess_vc_guess_vc_legacyrrrrmrXrorirVisdirr!r"r#)r@guess_vcZreg_pathZ python_vcZ default_vcrmsgrrr VCInstallDirs  zSystemInfo.VCInstallDirc Cs^|jdkrdSd}tjj|j|}ytj|d}tjj||Stttfk rXYnXdS)z* Locate Visual C for 2017 g,@Nz VC\Tools\MSVCrr5) rorrrr|listdirrbrcrq)r@r{rZ vc_exact_verrrrr}0s zSystemInfo._guess_vccCsd|j}tjj|j|S)z< Locate Visual C for versions prior to 2017 z Microsoft Visual Studio %0.1f\VC)rorrrrz)r@r{rrrr~@s zSystemInfo._guess_vc_legacycCsJ|jdkrdS|jdkrdS|jdkr*dS|jd kr8dS|jdkrFdSdS)zN Microsoft Windows SDK versions for specified MSVC++ version. g"@7.06.16.0ag$@7.17.0ag&@8.08.0ag(@8.18.1ag,@10.0N)rrr)rr)rr)rr)rr)ro)r@rrrWindowsSdkVersionGs     zSystemInfo.WindowsSdkVersioncCs|jtjj|jdS)z4 Microsoft Windows SDK last version lib)_use_last_dir_namerrr WindowsSdkDir)r@rrrWindowsSdkLastVersionWs z SystemInfo.WindowsSdkLastVersioncCsTd}x8|jD].}tjj|jjd|}|jj|d}|r Pq W| sRtjj| rtjj|jjd|j }|jj|d}|rtjj|d}| stjj| rxH|jD]>}|d|j d}d |}tjj|j |}tjj|r|}qW| stjj| r:x:|jD]0}d |}tjj|j |}tjj|r|}qW|sPtjj|j d }|S) z2 Microsoft Windows SDK directory. rzv%sinstallationfolderz%0.1frZWinSDKN.zMicrosoft SDKs\Windows Kits\%szMicrosoft SDKs\Windows\v%sZ PlatformSDK) rrrrrmrZrirrXrorfindrlr)r@sdkdirr(locr install_baseZintverdrrrr_s6     zSystemInfo.WindowsSdkDirc Cs|jdkrd}d}n&d}|jdkr&dnd}|jjd|d}d ||jd d f}g}|jd krx(|jD]}|tjj|jj ||g7}qdWx,|j D]"}|tjj|jj d ||g7}qWx |D]}|jj |d}|rPqW|S)z= Microsoft Windows SDK executable directory. g&@#r(g(@TF)r=rGzWinSDK-NetFx%dTools%srJ-g,@zv%sAr) rorSrHr?NetFxSdkVersionrrrrmr[rrZri) r@Znetfxverr)rGZfxZregpathsr(rZexecpathrrrWindowsSDKExecutablePaths$    " z#SystemInfo.WindowsSDKExecutablePathcCs.d|j}tjj|jj|}|jj|dp,dS)z0 Microsoft Visual F# directory. z%0.1f\Setup\F#rr)rorrrrmrTri)r@rrrrFSharpInstallDirs zSystemInfo.FSharpInstallDircCsF|jdkrd}nf}x(|D] }|jj|jjd|}|rPqW|pDdS)z8 Microsoft Universal CRT SDK directory. g,@1081z kitsroot%sr)rr)rormrir\)r@versr(rrrrUniversalCRTSdkDirs    zSystemInfo.UniversalCRTSdkDircCs|jtjj|jdS)z@ Microsoft Universal C Runtime SDK last version r)rrrrr)r@rrrUniversalCRTSdkLastVersions z%SystemInfo.UniversalCRTSdkLastVersioncCs|jdkrdSfSdS)z8 Microsoft .NET Framework SDK versions. g,@4.6.14.6N)rr)ro)r@rrrrs zSystemInfo.NetFxSdkVersioncCs>x4|jD]*}tjj|jj|}|jj|d}|rPqW|p)sz0SystemInfo._use_last_dir_name..Nr)reversedrrnext)r@rrZ matching_dirsr)rrrrs zSystemInfo._use_last_dir_name)N)r) rr r rNrOrPrkrlrzrArnrprQr|rr}r~rrrrrrrrrrrrrrrrrrrrjs4         &     rjc@sReZdZdZd=ddZeddZedd Zed d Zed d Z eddZ eddZ eddZ eddZ eddZeddZddZeddZeddZed d!Zed"d#Zed$d%Zed&d'Zed(d)Zed*d+Zed,d-Zed.d/Zed0d1Zed2d3Zed4d5Zd>d7d8Zd9d:Zd?d;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.0. 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}tjj |dS)Nz.No suitable Microsoft Visual C++ version found) r<rSrRrmrjsiror!r"r#)r@r)ror.rrrrrrAIs    zEnvironmentInfo.__init__cCs|jjS)z/ Microsoft Visual C++ version. )rro)r@rrrroRszEnvironmentInfo.vc_vercsVddg}jdkrDjjddd}|dg7}|dg7}|d|g7}fd d |DS) z/ Microsoft Visual Studio Tools z Common7\IDEz Common7\Toolsg,@T)rGr=z1Common7\IDE\CommonExtensions\Microsoft\TestWindowzTeam Tools\Performance ToolszTeam Tools\Performance Tools%scsg|]}tjjjj|qSr)rrrrr|)rr)r@rr fsz+EnvironmentInfo.VSTools..)rorSrH)r@paths arch_subdirr)r@rVSToolsYs   zEnvironmentInfo.VSToolscCs$tjj|jjdtjj|jjdgS)zL Microsoft Visual C++ & Microsoft Foundation Class Includes IncludezATLMFC\Include)rrrrr)r@rrr VCIncludeshszEnvironmentInfo.VCIncludescsbjdkrjjdd}njjdd}d|d|g}jdkrP|d|g7}fd d |DS) zM Microsoft Visual C++ & Microsoft Foundation Class Libraries g.@T)r=)rGzLib%sz ATLMFC\Lib%sg,@z Lib\store%scsg|]}tjjjj|qSr)rrrrr)rr)r@rrr~sz/EnvironmentInfo.VCLibraries..)rorSrI)r@rrr)r@r VCLibrariesps  zEnvironmentInfo.VCLibrariescCs"|jdkrgStjj|jjdgS)zA Microsoft Visual C++ store references Libraries g,@zLib\store\references)rorrrrr)r@rrr VCStoreRefss zEnvironmentInfo.VCStoreRefscCs|j}tjj|jdg}|jdkr&dnd}|jj|}|rT|tjj|jd|g7}|jdkrd|jjdd}|tjj|j|g7}n|jdkr|jj rd nd }|tjj|j||jj dd g7}|jj |jj kr|tjj|j||jjdd g7}n|tjj|jd g7}|S) z, Microsoft Visual C++ Tools Z VCPackagesg$@TFzBin%sg,@)rGg.@z bin\HostX86%sz bin\HostX64%s)r=Bin) rrrrrrorSrMrHrFrIrErC)r@rtoolsrKrrZhost_dirrrrVCToolss&   zEnvironmentInfo.VCToolscCst|jdkr2|jjddd}tjj|jjd|gS|jjdd}tjj|jjd}|j}tjj|d||fgSdS) z1 Microsoft Windows SDK Libraries g$@T)rGr=zLib%s)r=rz%sum%sN) rorSrIrrrrr _sdk_subdir)r@rrZlibverrrr OSLibrariess zEnvironmentInfo.OSLibrariescCs|tjj|jjd}|jdkr.|tjj|dgS|jdkr@|j}nd}tjj|d|tjj|d|tjj|d|gSd S) z/ Microsoft Windows SDK Include includeg$@glg,@rz%ssharedz%sumz%swinrtN)rrrrrror)r@rsdkverrrr OSIncludess  zEnvironmentInfo.OSIncludescCstjj|jjd}g}|jdkr*||j7}|jdkrH|tjj|dg7}|jdkr||tjj|jjdtjj|ddtjj|d dtjj|d dtjj|jjd d d |jdddg7}|S)z7 Microsoft Windows SDK Libraries Paths Z Referencesg"@g&@zCommonConfiguration\Neutralg,@Z UnionMetadataz'Windows.Foundation.UniversalApiContractz1.0.0.0z%Windows.Foundation.FoundationContractz,Windows.Networking.Connectivity.WwanContractZ ExtensionSDKszMicrosoft.VCLibsz%0.1fZCommonConfigurationZneutral)rrrrrror)r@reflibpathrrr OSLibpaths>     zEnvironmentInfo.OSLibpathcCs t|jS)z- Microsoft Windows SDK Tools )list _sdk_tools)r@rrrSdkToolsszEnvironmentInfo.SdkToolsccs|jdkr0|jdkrdnd}tjj|jj|V|jjsd|jjdd}d|}tjj|jj|V|jdksx|jdkr|jj rd }n|jjddd }d |}tjj|jj|VnL|jdkrtjj|jjd}|jjdd}|jj }tjj|d ||fV|jj r|jj Vd S)z= Microsoft Windows SDK Tools paths generator g.@g&@rzBin\x86T)r=zBin%sg$@r)rGr=zBin\NETFX 4.0 Tools%sz%s%sN) rorrrrrrSrFrHrDrr)r@bin_dirrrrrrrrs(     zEnvironmentInfo._sdk_toolscCs|jj}|rd|SdS)z6 Microsoft Windows SDK version subdir z%s\r)rr)r@ucrtverrrrrszEnvironmentInfo._sdk_subdircCs"|jdkrgStjj|jjdgS)z- Microsoft Windows SDK Setup g"@ZSetup)rorrrrr)r@rrrSdkSetup%s zEnvironmentInfo.SdkSetupcs|j}|j|jdkr0d}|j o,|j }n$|jp>|j}|jdkpR|jdk}g}|rt|fddjD7}|r|fddjD7}|S)z0 Microsoft .NET Framework Tools g$@Tr>csg|]}tjjj|qSr)rrrr)rr()rrrr@sz+EnvironmentInfo.FxTools..csg|]}tjjj|qSr)rrrr)rr()rrrrCs) rSrrorDrFrErCrr)r@rSZ include32Z include64rr)rrFxTools/s     zEnvironmentInfo.FxToolscCs>|jdks|jj rgS|jjdd}tjj|jjd|gS)z8 Microsoft .Net Framework SDK Libraries g,@T)r=zlib\um%s)rorrrSrIrrr)r@rrrrNetFxSDKLibrariesGsz!EnvironmentInfo.NetFxSDKLibrariescCs,|jdks|jj rgStjj|jjdgS)z7 Microsoft .Net Framework SDK Includes g,@z include\um)rorrrrr)r@rrrNetFxSDKIncludesRsz EnvironmentInfo.NetFxSDKIncludescCstjj|jjdgS)z> Microsoft Visual Studio Team System Database z VSTSDB\Deploy)rrrrr|)r@rrrVsTDb\szEnvironmentInfo.VsTDbcCs~|jdkrgS|jdkr0|jj}|jjdd}n |jj}d}d|j|f}tjj||g}|jdkrz|tjj||dg7}|S)z( Microsoft Build Engine g(@g.@T)rGrzMSBuild\%0.1f\bin%sZRoslyn) rorrzrSrHr|rrr)r@ base_pathrrbuildrrrMSBuildcs   zEnvironmentInfo.MSBuildcCs"|jdkrgStjj|jjdgS)z. Microsoft HTML Help Workshop g&@zHTML Help Workshop)rorrrrrz)r@rrrHTMLHelpWorkshopzs z EnvironmentInfo.HTMLHelpWorkshopcCsL|jdkrgS|jjdd}tjj|jjd}|j}tjj|d||fgS)z= Microsoft Universal C Runtime SDK Libraries g,@T)r=rz%sucrt%s) rorSrIrrrrr _ucrt_subdir)r@rrrrrr UCRTLibrariess  zEnvironmentInfo.UCRTLibrariescCs6|jdkrgStjj|jjd}tjj|d|jgS)z; Microsoft Universal C Runtime SDK Include g,@rz%sucrt)rorrrrrr)r@rrrr UCRTIncludess zEnvironmentInfo.UCRTIncludescCs|jj}|rd|SdS)zB Microsoft Universal C Runtime SDK version subdir z%s\r)rr)r@rrrrrszEnvironmentInfo._ucrt_subdircCs |jdkr|jdkrgS|jjS)z% Microsoft Visual F# g&@g(@)rorr)r@rrrFSharpszEnvironmentInfo.FSharpcCsl|jjdd}|jdkr&|jj}d}n|jjjdd}d}|jdkrHdn|j}|||j|f}tjj||S) zA Microsoft Visual C++ runtime redistribuable dll T)r=z-redist%s\Microsoft.VC%d0.CRT\vcruntime%d0.dllz\Toolsz\Redistz.onecore%s\Microsoft.VC%d0.CRT\vcruntime%d0.dllg,@) rSrIrorrr?rrr)r@rZ redist_pathZ vcruntimeZdll_verrrrVCRuntimeRedists zEnvironmentInfo.VCRuntimeRedistTcCst|jd|j|j|j|jg||jd|j|j|j|j |j g||jd|j|j|j |j g||jd|j |j|j|j|j|j|j|j|jg |d}|jdkrtjj|jr|j|d<|S)z Return environment dict. Parameters ---------- exists: bool It True, only return existing paths. rrrr)rrrrZpy_vcruntime_redist)dict _build_pathsrrrrrrrrrrrrrrrrrrrrorrrr)r@existsenvrrrr&sD   zEnvironmentInfo.return_envc Csxtjj|}tj|djtj}tj||}|rBtt tj j |n|}|sbd|j }t jj||j|} tjj| S)a 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. rz %s environment variable is empty) itertoolschain from_iterablerOrPsplitrpathseprfilterrrupperr!r"r#_unique_everseenr) r@reZspec_path_listsrZ spec_pathsZ env_pathsrZ extant_pathsrZ unique_pathsrrrrs     zEnvironmentInfo._build_pathsccsjt}|j}|dkr:xPt|j|D]}|||Vq"Wn,x*|D]"}||}||kr@|||Vq@WdS)z List unique elements, preserving order. Remember all elements ever seen. _unique_everseen('AAAABBBCCDAABBB') --> A B C D _unique_everseen('ABBCcAD', str.lower) --> A B C D N)setaddr __contains__)r@iterablerseenZseen_addelementkrrrrs   z EnvironmentInfo._unique_everseen)Nr)T)N)!rr r rNrArQrorrrrrrrrrrrrrrrrrrrrrrrr&rrrrrrr%1s:       -        -r%)r)r)!rNrr0platformrZdistutils.errorsr!Z&pkg_resources.extern.packaging.versionrZsetuptools.extern.six.movesrZmonkeyrsystemrenvironrOr ImportErrorr"r#Z_msvc9_suppress_errorsZdistutils.msvc9compilerrrr r/r3r'r<rRrjr%rrrrs>      + /& %[b