o nh@sUdZddlmZddlZddlZddlZddlZddlZddlZddl m Z m Z ddl m Z ddlZe r=ddlmZmZe sPedkrPddlZddlmZnGd d d ZeZd ed <Gd ddZGdddZGdddZGddde ZGdddZdS)zo Environment info about Microsoft Compilers. >>> getfixture('windows_only') >>> ei = EnvironmentInfo('amd64') ) annotationsN) TYPE_CHECKING TypedDict)unique_everseen) LiteralString NotRequiredWindows)environc@seZdZdZdZdZdZdS)winregN)__name__ __module__ __qualname__ HKEY_USERSHKEY_CURRENT_USERHKEY_LOCAL_MACHINEHKEY_CLASSES_ROOTrrR/opt/prometheus-monitoring-scripts/lib/python3.10/site-packages/setuptools/msvc.pyr s r zdict[str, str]r c@sheZdZdZeddZdddZe dd Z d d Z d d Z ddddZ ddddZdddZdS) PlatformInfoz Current and Target Architectures information. Parameters ---------- arch: str Target architecture. processor_architecturereturnNonecCs|dd|_dS)Nx64amd64)lowerreplacearch)selfrrrr__init__5szPlatformInfo.__init__cCs|j|jdddS)zs Return Target CPU architecture. Return ------ str Target CPU _N)rfindrrrr target_cpu8s zPlatformInfo.target_cpucC |jdkS)z Return True if target CPU is x86 32 bits.. Return ------ bool CPU is x86 32 bits x86r$r#rrr target_is_x86D zPlatformInfo.target_is_x86cCr%)z Return True if current CPU is x86 32 bits.. Return ------ bool CPU is x86 32 bits r& current_cpur#rrrcurrent_is_x86Or)zPlatformInfo.current_is_x86FstrcC0|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&rr\x64\r*rhidex86rrrr current_dirZ 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&rrr/r0r'r1rrr target_dirrr4zPlatformInfo.target_dircCs4|rdn|j}|j|krdS|dd|dS)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&rr0r )r+r$r5r)rforcex86currentrrr cross_dirs  zPlatformInfo.cross_dirNrr)FFrr-F)r r r __doc__r getrr+rpropertyr$r(r,r3r5r8rrrrr)s    rc@seZdZdZejejejejfZ dddZ e d ddZ e d d Z e d d Ze d dZe d ddZe d ddZe ddZe ddZe d ddZd!ddZddZdS)" RegistryInfoz Microsoft Visual Studio related registry information. Parameters ---------- platform_info: PlatformInfo "PlatformInfo" instance. rrcCs ||_dSN)pi)r platform_inforrrrs zRegistryInfo.__init__r-cCdS)z Microsoft Visual Studio root registry key. Return ------ str Registry key VisualStudiorr#rrr visualstudio zRegistryInfo.visualstudiocCtj|jdS)z Microsoft Visual Studio SxS registry key. Return ------ str Registry key SxS)ospathjoinrEr#rrrsxs zRegistryInfo.sxscCrG)z| Microsoft Visual C++ VC7 registry key. Return ------ str Registry key VC7rIrJrKrLr#rrrvcrMzRegistryInfo.vccCrG)z Microsoft Visual Studio VS7 registry key. Return ------ str Registry key VS7rOr#rrrvsrMzRegistryInfo.vscCrC)z Microsoft Visual C++ for Python registry key. Return ------ str Registry key zDevDiv\VCForPythonrr#rrr vc_for_pythonrFzRegistryInfo.vc_for_pythoncCrC)zq Microsoft SDK registry key. Return ------ str Registry key zMicrosoft SDKsrr#rrr microsoft_sdkrFzRegistryInfo.microsoft_sdkcCrG)z Microsoft Windows/Platform SDK registry key. Return ------ str Registry key rrIrJrKrTr#rrr windows_sdkrMzRegistryInfo.windows_sdkcCrG)z Microsoft .NET Framework SDK registry key. Return ------ str Registry key NETFXSDKrUr#rrr netfx_sdk rMzRegistryInfo.netfx_sdkcCrC)z Microsoft Windows Kits Roots registry key. Return ------ str Registry key zWindows Kits\Installed Rootsrr#rrrwindows_kits_rootsrFzRegistryInfo.windows_kits_rootsFcCs(|js|r dnd}tjd|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)rAr,rIrJrK)rkeyr&node64rrr microsoft"szRegistryInfo.microsoftc Cstj}tj}tj}|j}|jD]f}d}z ||||d|}Wn'tyE|jsAz ||||dd|}Wn ty@YYqwYqYnwz'zt ||dWW|rZ||SStyeYnwW|rm||q|ru||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) r KEY_READOpenKeyCloseKeyr_HKEYSOSErrorrAr, QueryValueEx) rr]namekey_readopenkeyclosekeymshkeybkeyrrrlookup5sD      zRegistryInfo.lookupNr9r:r;)r r r r<r rrrrrcrr>rErLrPrRrSrTrVrXrYr_rmrrrrr?s8            r?c@sJeZdZdZeddZeddZedeZd=d>d d Z d d Z d dZ d?ddZ e ddZeddZeddZddZddZed@ddZedd ZedAd"d#Zed$d%Zed&d'Zed(d)Zed*d+Zed,d-Zed.d/Zed0d1Zed2d3ZedBd5d6ZedBd7d8Z dBd9d:Z!e dCd;d<Z"dS)D SystemInfoz Microsoft Windows and Visual Studio related system information. Parameters ---------- registry_info: RegistryInfo "RegistryInfo" instance. vc_ver: float Required Microsoft Visual C++ version. WinDirr ProgramFileszProgramFiles(x86)NrrcCs2||_|jj|_||_|p||_|_dSr@)rirAfind_programdata_vs_versknown_vs_paths_find_latest_available_vs_vervs_vervc_ver)r registry_inforvrrrrqs  zSystemInfo.__init__cCs>|}|s|jstjdt|}||jt|dS)zm Find the latest VC version Return ------ float version z%No Microsoft Visual C++ version found)find_reg_vs_versrs distutilserrorsDistutilsPlatformErrorsetupdatesorted)r reg_vc_versvc_versrrrrtzs   z(SystemInfo._find_latest_available_vs_verc Cs^|jj}|jj|jj|jjf}g}t|jj|D]\}}z t |||dtj }Wn t y3Yqw|lt |\}}} t |D]*} tttt|| d} | |vr^|| Wdn1shwYqCt |D](} tttt|| } | |vr|| Wdn1swYqrWdn1swYqt|S)z Find Microsoft Visual Studio versions available in registry. Return ------ list of float Versions rN)rqr_rPrSrR itertoolsproductrcr rar`rd QueryInfoKeyrange contextlibsuppress ValueErrorfloat EnumValueappendEnumKeyr) rrjvckeysvs_versrkr]rlsubkeysvaluesr iverrrrrys>         zSystemInfo.find_reg_vs_versdict[float, str]c Csi}d}zt|}Wn ty|YSw|D]J}z=tj||d}t|ddd }t|}Wdn1s;wY|d}ttj|d||||d <Wqtt fycYqw|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)encodingNinstallationPath VC\Tools\MSVCinstallationVersion) rIlistdirrdrJrKopenjsonload_as_float_versionKeyError) r vs_versions instances_dir hashed_namesrf state_path state_filestatevs_pathrrrrrs*   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)rrKsplit)versionrrrrszSystemInfo._as_float_versioncCs6tj|jd|jd}|j|jj|jdp|S)zp Microsoft Visual Studio directory. Return ------ str path Microsoft Visual Studio 0.1f)rIrJrKProgramFilesx86rurqrmrR)rdefaultrrr VSInstallDirs zSystemInfo.VSInstallDircCs0|p|}tj|sd}tj||S)zm Microsoft Visual C++ directory. Return ------ str path z(Microsoft Visual C++ directory not found) _guess_vc_guess_vc_legacyrIrJisdirrzr{r|)rrJmsgrrr VCInstallDirs   zSystemInfo.VCInstallDirc Cs|jdkrdSz|j|j}Wn ty|j}Ynwtj|d}zt|d}|||_ tj||WSt t fyDYdSw)zl Locate Visual C++ for VS2017+. Return ------ str path ,@rrrx) rursrrrIrJrKrrrvrd IndexError)rvs_dirguess_vcrvrrrr s    zSystemInfo._guess_vccCsttj|jd|jdd}tj|jj|jd}|j|d}|r*tj|dn|}|j|jj|jdp9|S)z{ Locate Visual C++ for versions prior to 2017. Return ------ str path rrz\VC installdirVC) rIrJrKrrurqrSrmrP)rrreg_path python_vc default_vcrrrr*s zSystemInfo._guess_vc_legacytuple[LiteralString, ...]cCsJ|jdkrdS|jdkrdS|jdkrdS|jdkrdS|jd kr#d Sd S) z Microsoft Windows SDK versions for specified MSVC++ version. Return ------ tuple of str versions "@)z7.0z6.1z6.0a$@)z7.1z7.0a&@)z8.0z8.0a(@)8.1z8.1ar)z10.0rrrur#rrrWindowsSdkVersion@s     zSystemInfo.WindowsSdkVersioncC|tj|jdS)zt Microsoft Windows SDK last version. Return ------ str version lib)_use_last_dir_namerIrJrK WindowsSdkDirr#rrrWindowsSdkLastVersionV z SystemInfo.WindowsSdkLastVersion str | NonecCs<d}|jD]}tj|jjd|}|j|d}|rnq|r'tj|sCtj|jj|j d}|j|d}|rCtj|d}|rKtj|so|jD] }|d| d}d |}tj|j |}tj|rn|}qN|rwtj|s|jD]}d |}tj|j |}tj|r|}qz|stj|j d }|S) zn Microsoft Windows SDK directory. Return ------ str path rvinstallationfolderrrWinSDKNrzMicrosoft SDKs\Windows Kits\zMicrosoft SDKs\Windows\v PlatformSDK) rrIrJrKrqrVrmrrSrvrfindrpr)rsdkdirrlocrJ install_baseintverdrrrrbs<       zSystemInfo.WindowsSdkDirc Cs|jdkr d}d}nd}|jdkrdnd}|jjd|dd d }d |d |}g}|jd krC|jD]}|tj|jj ||g7}q3|j D]}|tj|jj d|d|g7}qF|D]}|j |d}|rk|Sq\dS)zy Microsoft Windows SDK executable directory. Return ------ str path r#r(rTF)rr2r0-z WinSDK-NetFxToolsrrArN) rurAr3rNetFxSdkVersionrIrJrKrqrXrrVrm) rnetfxverrr2fxregpathsrrJexecpathrrrWindowsSDKExecutablePaths&    $z#SystemInfo.WindowsSDKExecutablePathcCs.tj|jj|jdd}|j|dpdS)zl Microsoft Visual F# directory. Return ------ str path rz \Setup\F# productdirr)rIrJrKrqrErurm)rrJrrrFSharpInstallDirs zSystemInfo.FSharpInstallDircCsH|jdkrdnd}|D]}|j|jjd|}|r!|pdSq dS)zt Microsoft Universal CRT SDK directory. Return ------ str path r)1081rkitsrootrN)rurqrmrY)rversrrrrrUniversalCRTSdkDirs  zSystemInfo.UniversalCRTSdkDircCr)z Microsoft Universal C Runtime SDK last version. Return ------ str version r)rrIrJrKrr#rrrUniversalCRTSdkLastVersionrz%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.5rrr#rrrrs zSystemInfo.NetFxSdkVersioncCs>d}|jD]}tj|jj|}|j|d}|r|Sq|S)zu Microsoft .NET Framework SDK directory. Return ------ str path rkitsinstallationfolder)rrIrJrKrqrXrm)rrrrrrr NetFxSdkDirs zSystemInfo.NetFxSdkDircC&tj|jd}|j|jjdp|S)zw Microsoft .NET Framework 32bit directory. Return ------ str path zMicrosoft.NET\Frameworkframeworkdir32rIrJrKrorqrmrPrguess_fwrrrFrameworkDir32 zSystemInfo.FrameworkDir32cCr)zw Microsoft .NET Framework 64bit directory. Return ------ str path zMicrosoft.NET\Framework64frameworkdir64rrrrrFrameworkDir64rzSystemInfo.FrameworkDir64tuple[str, ...]cC |dS)z Microsoft .NET Framework 32bit versions. Return ------ tuple of str versions _find_dot_net_versionsr#rrrFrameworkVersion32# zSystemInfo.FrameworkVersion32cCr)z Microsoft .NET Framework 64bit versions. Return ------ tuple of str versions @rr#rrrFrameworkVersion64/rzSystemInfo.FrameworkVersion64cCs|j|jjd|}t|d|}|p||dpd}|jdkr'|dfS|jdkr>|dd d kr:d d fS|d fS|jd krEdS|jdkrLdSdS)z Find Microsoft .NET Framework versions. Parameters ---------- bits: int Platform number of bits: 32 or 64. Return ------ tuple of str versions frameworkver FrameworkDirrrrzv4.0rNrv4z v4.0.30319v3.5r)r v2.0.50727g @)zv3.0rr)rqrmrPgetattrrrur)rbitsreg_ver dot_net_dirrrrrr;s  $  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 c3s4|]}tjtj|r|r|VqdSr@)rIrJrrK startswith).0dir_namerJprefixrr js z0SystemInfo._use_last_dir_name..Nr)reversedrIrnext)rJr  matching_dirsrr rrYs  zSystemInfo._use_last_dir_namer@r9)rr)rrrr)rr)r)#r r r r<r r=rorprrrtryrr staticmethodrr>rrrrrrrrrrrrrrrrrrrrrrrrn_s\     *      * $          rnc@s6eZdZUded<ded<ded<ded<ded<dS) _EnvironmentDictr-includerlibpathrJzNotRequired[str | None]py_vcruntime_redistN)r r r __annotations__rrrrrss  rc@sZeZdZdZdCdDddZedd Zed d Zed d ZeddZ eddZ eddZ eddZ eddZ eddZeddZeddZddZed d!Zed"d#Zed$d%Zed&d'Zed(d)Zed*d+Zed,d-Zed.d/Zed0d1Zed2d3Zed4d5Zed6d7ZedEd9d:ZdFdGd?d@ZdAdBZ dS)HEnvironmentInfoaY 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. NrrrcCsBt||_t|j|_t|j||_|j|krd}tj |dS)Nz.No suitable Microsoft Visual C++ version found) rrAr?rqrnsirvrzr{r|)rrrv vc_min_vererrrrrrs    zEnvironmentInfo.__init__cC|jjS)zk Microsoft Visual Studio. Return ------ float version )rrur#rrrru zEnvironmentInfo.vs_vercCr)zp Microsoft Visual C++ version. Return ------ float version )rrvr#rrrrvrzEnvironmentInfo.vc_vercsXddg}jdkr#jjddd}|dg7}|dg7}|d|g7}fdd |DS) zu Microsoft Visual Studio Tools. Return ------ list of str paths z Common7\IDEz Common7\ToolsrTr2rz1Common7\IDE\CommonExtensions\Microsoft\TestWindowzTeam Tools\Performance Toolscg|] }tjjj|qSrrIrJrKrrrrJr#rr z+EnvironmentInfo.VSTools..)rurAr3)rpaths arch_subdirrr#rVSToolss   zEnvironmentInfo.VSToolscCs$tj|jjdtj|jjdgS)z Microsoft Visual C++ & Microsoft Foundation Class Includes. Return ------ list of str paths IncludezATLMFC\IncluderIrJrKrrr#rrr VCIncludess zEnvironmentInfo.VCIncludescshjdkr jjdd}njjdd}d|d|g}jdkr+|d|g7}fd d |DS) z Microsoft Visual C++ & Microsoft Foundation Class Libraries. Return ------ list of str paths .@Trr2Libz ATLMFC\Librz Lib\storecrrr&rr#rrr r!z/EnvironmentInfo.VCLibraries..)rurAr5)rr#r"rr#r VCLibrariess  zEnvironmentInfo.VCLibrariescC"|jdkrgStj|jjdgS)z Microsoft Visual C++ store references Libraries. Return ------ list of str paths rzLib\store\references)rurIrJrKrrr#rrr VCStoreRefss zEnvironmentInfo.VCStoreRefscCs8|j}tj|jdg}|jdkrdnd}|j|}|r+|tj|jd|g7}|jdkrGd|jjdd}|tj|j|g7}|S|jdkr|jj d d  }tjd d |d }|tj|j||jj ddg7}|jj |jj kr|tj|j||jjddg7}|S|tj|jdg7}|S)a Microsoft Visual C++ Tools. Return ------ list of str paths When host CPU is ARM, the tools should be found for ARM. >>> getfixture('windows_only') >>> mp = getfixture('monkeypatch') >>> mp.setattr(PlatformInfo, 'current_cpu', 'arm64') >>> ei = EnvironmentInfo(arch='irrelevant') >>> paths = ei.VCTools >>> any('HostARM64' in path for path in paths) True VCPackagesrTFBinrr*r(rrbinHostz%sr))rrIrJrKrrurAr8r3r+rupperr5r$)rrtoolsr6r#rJhost_idhost_dirrrrVCToolss2    zEnvironmentInfo.VCToolscCst|jdkr|jjddd}tj|jjd|gS|jjdd}tj|jjd}|j}tj||d|gS)zw Microsoft Windows SDK Libraries. Return ------ list of str paths rTrr+r)rum) rurAr5rIrJrKrr _sdk_subdir)rr#rlibverrrr OSLibraries-s zEnvironmentInfo.OSLibrariescCs~tj|jjd}|jdkr|tj|dgS|jdkr |j}nd}tj||dtj||dtj||dgS) zu Microsoft Windows SDK Include. Return ------ list of str paths rrglrrsharedr8winrt)rIrJrKrrrur9)rrsdkverrrr OSIncludesAs  zEnvironmentInfo.OSIncludescCstj|jjd}g}|jdkr||j7}|jdkr$|tj|dg7}|jdkr[||tj|jjdtj|ddtj|d dtj|d dtj|jjd d |jd dddg7}|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.VCLibsrCommonConfigurationneutral)rIrJrKrrrur;)rrefrrrr OSLibpath[s4     zEnvironmentInfo.OSLibpathcCs t|S)zs Microsoft Windows SDK Tools. Return ------ list of str paths )list _sdk_toolsr#rrrSdkToolss zEnvironmentInfo.SdkToolsccs|jdkr|jdkr dnd}tj|jj|V|js4|jjdd}d|}tj|jj|V|jdvrY|j rAd}n|jjddd }d |}tj|jj|Vn%|jdkr~tj|jjd}|jjdd}|jj }tj|||V|jj r|jj Vd Sd S) z Microsoft Windows SDK Tools paths generator. Return ------ generator of str paths r(rr0zBin\x86Tr))rrrrzBin\NETFX 4.0 ToolsN) rurIrJrKrrrAr,r3r(rr)rbin_dirr#rJr?rrrrIs,       zEnvironmentInfo._sdk_toolscC|jj}|r |dSdS)zu Microsoft Windows SDK version subdir. Return ------ str subdir r0r)rrrucrtverrrrr9 zEnvironmentInfo._sdk_subdircCs"|jdkrgStj|jjdgS)zs Microsoft Windows SDK Setup. Return ------ list of str paths rSetup)rurIrJrKrrr#rrrSdkSetup zEnvironmentInfo.SdkSetupcs|j}|j|jdkrd}| o| }n|p|}|jdkp)|jdk}g}|r:|fddjD7}|rH|fddjD7}|S)zv Microsoft .NET Framework Tools. Return ------ list of str paths rTrcg|] }tjj|qSr)rIrJrKrrrrrrr z+EnvironmentInfo.FxTools..crSr)rIrJrKrrTrUrrr rV) rArrur(r,r+r$rr)rrA include32 include64r4rrUrFxToolss"    zEnvironmentInfo.FxToolscCs>|jdks |jjs gS|jjdd}tj|jjd|gS)z~ Microsoft .Net Framework SDK Libraries. Return ------ list of str paths rTr)zlib\um)rurrrAr5rIrJrK)rr#rrrNetFxSDKLibrariess z!EnvironmentInfo.NetFxSDKLibrariescCs*|jdks |jjs gStj|jjdgS)z} Microsoft .Net Framework SDK Includes. Return ------ list of str paths rz include\um)rurrrIrJrKr#rrrNetFxSDKIncludess z EnvironmentInfo.NetFxSDKIncludescCstj|jjdgS)z Microsoft Visual Studio Team System Database. Return ------ list of str paths z VSTSDB\Deployrr#rrrVsTDb s zEnvironmentInfo.VsTDbcCs|jdkrgS|jdkr|jj}|jjdd}n|jj}d}d|jdd|}tj||g}|jdkr@|tj||d g7}|S) zn Microsoft Build Engine. Return ------ list of str paths rr(Tr*rzMSBuild\rz\binRoslyn) rurrrAr3rrIrJrK)r base_pathr#rJbuildrrrMSBuilds   zEnvironmentInfo.MSBuildcCr-)zt Microsoft HTML Help Workshop. Return ------ list of str paths rzHTML Help Workshop)rurIrJrKrrr#rrrHTMLHelpWorkshop4rRz EnvironmentInfo.HTMLHelpWorkshopcCsN|jdkrgS|jjdd}tj|jjd}|j}tj||d|gS)z Microsoft Universal C Runtime SDK Libraries. Return ------ list of str paths rTr)rucrt) rurAr5rIrJrKrr _ucrt_subdir)rr#rrNrrr UCRTLibrariesCs zEnvironmentInfo.UCRTLibrariescCs8|jdkrgStj|jjd}tj||jdgS)z Microsoft Universal C Runtime SDK Include. Return ------ list of str paths rrrb)rurIrJrKrrrc)rrrrr UCRTIncludesUs zEnvironmentInfo.UCRTIncludescCrL)z Microsoft Universal C Runtime SDK version subdir. Return ------ str subdir r0r)rrrMrrrrcerOzEnvironmentInfo._ucrt_subdircCs$d|jkr dkr gS|jjgS)zk Microsoft Visual F#. Return ------ list of str paths rr)rurrr#rrrFSharprs  zEnvironmentInfo.FSharprcsd|jd|jjdddg}|jj}tj| dd}tj |r>tj |t |d}||tj |d g7}|tj |d g7}d |jd d d t |jd d f}fddt||D}tttjj|dS)z{ Microsoft Visual C++ runtime redistributable dll. Returns the first suitable path found or None. vcruntimez0.dllTr)r0z\Toolsz\Redistrxonecoreredistz Microsoft.VC z.CRTc3s&|]\}}tj||VqdSr@)rIrJrK)rr crt_dirr#rgrrr s  z2EnvironmentInfo.VCRuntimeRedist..N)rvrAr5striprrrIrJdirnamerrrKrintrurrr filterisfile)rprefixes tools_path redist_pathcrt_dirscandidate_pathsrrlrVCRuntimeRedists    zEnvironmentInfo.VCRuntimeRedistTexistsboolrcCst|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}|jdkrU|jrU|j|d<|S)z Return environment dict. Parameters ---------- exists: bool It True, only return existing paths. Return ------ dict environment rrrrJ)rrrrJr)r _build_pathsr'r@rer[r,r;rYrdrZr.rGr7r$r\rJrQr`rarfrurw)rrxenvrrr return_envsV   + zEnvironmentInfo.return_envc Csxtj|}t|dtj}t||}|r!tt tj j |n|}|s2| d}t j|t|} tj| 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 environment variable is empty)rchain from_iterabler r=rrIpathseprHrprJrr3rzr{r|rrK) rrfspec_path_listsrx spec_paths env_pathsr" extant_pathsr unique_pathsrrrr{s    zEnvironmentInfo._build_paths)Nrr9r)T)rxryrr)!r r r r<rr>rurvr$r'r,r.r7r;r@rGrJrIr9rQrYrZr[r\r`rardrercrfrwr}r{rrrrr{sl        2   '  #              " =r)r< __future__rrrrrIos.pathplatformtypingrrmore_itertoolsrdistutils.errorsrztyping_extensionsrrsystemr r dictrrr?rnrrrrrrs8  y>