o
    LK&h                     @  s  U d Z ddlmZ ddlZddlZddlZddlZddlZddlZddl	m
Z
mZ ddlmZ ddlZe
r=ddlmZmZ e
sPe dkrPddlZddlmZ nG d	d
 d
Ze Zded< G dd dZG dd dZG dd dZG dd deZG dd dZdS )zo
Environment info about Microsoft Compilers.

>>> getfixture('windows_only')
>>> ei = EnvironmentInfo('amd64')
    )annotationsN)TYPE_CHECKING	TypedDict)unique_everseen)LiteralStringNotRequiredWindows)environc                   @  s   e Zd ZdZdZdZdZdS )winregN)__name__
__module____qualname__
HKEY_USERSHKEY_CURRENT_USERHKEY_LOCAL_MACHINEHKEY_CLASSES_ROOT r   r   B/var/www/html/venv/lib/python3.10/site-packages/setuptools/msvc.pyr
       s
    r
   zdict[str, str]r	   c                   @  sh   e Zd ZdZedd ZdddZe	dd	 Z
d
d Zdd ZddddZddddZdddZdS )PlatformInfoz
    Current and Target Architectures information.

    Parameters
    ----------
    arch: str
        Target architecture.
    processor_architecture returnNonec                 C  s   |  dd| _d S )Nx64amd64)lowerreplacearch)selfr   r   r   r   __init__5   s   zPlatformInfo.__init__c                 C  s   | j | j dd d S )zs
        Return Target CPU architecture.

        Return
        ------
        str
            Target CPU
        _   N)r   findr   r   r   r   
target_cpu8   s   
zPlatformInfo.target_cpuc                 C  
   | j dkS )z
        Return True if target CPU is x86 32 bits..

        Return
        ------
        bool
            CPU is x86 32 bits
        x86r$   r#   r   r   r   target_is_x86D      
	zPlatformInfo.target_is_x86c                 C  r%   )z
        Return True if current CPU is x86 32 bits..

        Return
        ------
        bool
            CPU is x86 32 bits
        r&   current_cpur#   r   r   r   current_is_x86O   r)   zPlatformInfo.current_is_x86Fstrc                 C  0   | j dkr	|r	dS | j dkr|rdS d| j  S )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&   r   r   \x64\r*   r   hidex86r   r   r   r   current_dirZ      
zPlatformInfo.current_dirc                 C  r.   )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&   r   r   r/   r0   r'   r1   r   r   r   
target_dirr   r4   zPlatformInfo.target_dirc                 C  s4   |rdn| j }| j|krdS |  dd| d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   r0   r    )r+   r$   r5   r   )r   forcex86currentr   r   r   	cross_dir   s   
zPlatformInfo.cross_dirNr   r   )FFr   r-   F)r   r   r   __doc__r	   getr   r+   r   propertyr$   r(   r,   r3   r5   r8   r   r   r   r   r   )   s    	

r   c                   @  s   e Zd ZdZejejejejfZ	dddZ
ed ddZed	d
 Zedd Zedd Zed ddZed ddZedd Zedd Zed ddZd!ddZdd ZdS )"RegistryInfoz
    Microsoft Visual Studio related registry information.

    Parameters
    ----------
    platform_info: PlatformInfo
        "PlatformInfo" instance.
    r   r   c                 C  s
   || _ d S N)pi)r   platform_infor   r   r   r      s   
zRegistryInfo.__init__r-   c                 C     dS )z
        Microsoft Visual Studio root registry key.

        Return
        ------
        str
            Registry key
        VisualStudior   r#   r   r   r   visualstudio      
zRegistryInfo.visualstudioc                 C     t j| jdS )z
        Microsoft Visual Studio SxS registry key.

        Return
        ------
        str
            Registry key
        SxS)ospathjoinrE   r#   r   r   r   sxs      
zRegistryInfo.sxsc                 C  rG   )z|
        Microsoft Visual C++ VC7 registry key.

        Return
        ------
        str
            Registry key
        VC7rI   rJ   rK   rL   r#   r   r   r   vc   rM   zRegistryInfo.vcc                 C  rG   )z
        Microsoft Visual Studio VS7 registry key.

        Return
        ------
        str
            Registry key
        VS7rO   r#   r   r   r   vs   rM   zRegistryInfo.vsc                 C  rC   )z
        Microsoft Visual C++ for Python registry key.

        Return
        ------
        str
            Registry key
        zDevDiv\VCForPythonr   r#   r   r   r   vc_for_python   rF   zRegistryInfo.vc_for_pythonc                 C  rC   )zq
        Microsoft SDK registry key.

        Return
        ------
        str
            Registry key
        zMicrosoft SDKsr   r#   r   r   r   microsoft_sdk   rF   zRegistryInfo.microsoft_sdkc                 C  rG   )z
        Microsoft Windows/Platform SDK registry key.

        Return
        ------
        str
            Registry key
        r   rI   rJ   rK   rT   r#   r   r   r   windows_sdk   rM   zRegistryInfo.windows_sdkc                 C  rG   )z
        Microsoft .NET Framework SDK registry key.

        Return
        ------
        str
            Registry key
        NETFXSDKrU   r#   r   r   r   	netfx_sdk
  rM   zRegistryInfo.netfx_sdkc                 C  rC   )z
        Microsoft Windows Kits Roots registry key.

        Return
        ------
        str
            Registry key
        zWindows Kits\Installed Rootsr   r#   r   r   r   windows_kits_roots  rF   zRegistryInfo.windows_kits_rootsFc                 C  s(   | j  s|r	dnd}tjd|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   Wow6432NodeSoftware	Microsoft)rA   r,   rI   rJ   rK   )r   keyr&   node64r   r   r   	microsoft"  s   zRegistryInfo.microsoftc           	      C  s   t j}t j}t j}| j}| jD ]f}d}z||||d|}W n' tyE   | j sAz||||dd|}W n ty@   Y Y qw Y qY nw z'zt 	||d W W |rZ||   S   S  tye   Y nw W |rm|| q|ru|| w w dS )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
        Nr   T)
r
   KEY_READOpenKeyCloseKeyr_   HKEYSOSErrorrA   r,   QueryValueEx)	r   r]   namekey_readopenkeyclosekeymshkeybkeyr   r   r   lookup5  sD   


zRegistryInfo.lookupNr9   r:   r;   )r   r   r   r<   r
   r   r   r   r   rc   r   r>   rE   rL   rP   rR   rS   rT   rV   rX   rY   r_   rm   r   r   r   r   r?      s8    







r?   c                   @  sJ  e Zd ZdZeddZeddZedeZd=d>d	d
Z	dd Z
dd Zd?ddZedd Zedd Zedd Zdd Zdd Zed@ddZedd  ZedAd"d#Zed$d% Zed&d' Zed(d) Zed*d+ Zed,d- Zed.d/ Zed0d1 Zed2d3 ZedBd5d6ZedBd7d8Z dBd9d:Z!edCd;d<Z"dS )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   ProgramFileszProgramFiles(x86)Nr   r   c                 C  s2   || _ | j j| _|  | _|p|   | _| _d S r@   )rirA   find_programdata_vs_versknown_vs_paths_find_latest_available_vs_vervs_vervc_ver)r   registry_inforv   r   r   r   r   q  s   

zSystemInfo.__init__c                 C  s>   |   }|s| jstjdt|}|| j t|d S )zm
        Find the latest VC version

        Return
        ------
        float
            version
        z%No Microsoft Visual C++ version found)find_reg_vs_versrs   	distutilserrorsDistutilsPlatformErrorsetupdatesorted)r   reg_vc_versvc_versr   r   r   rt   z  s   	
z(SystemInfo._find_latest_available_vs_verc                 C  s^  | j j}| j j| j j| j jf}g }t| j j|D ]\}}zt	|||dtj
}W n	 ty3   Y qw |l t|\}}}	t|D ]*}
tt tt||
d }||vr^|| W d   n1 shw   Y  qCt|D ](}
tt tt||
}||vr|| W d   n1 sw   Y  qrW d   n1 sw   Y  qt|S )z
        Find Microsoft Visual Studio versions available in registry.

        Return
        ------
        list of float
            Versions
        r   N)rq   r_   rP   rS   rR   	itertoolsproductrc   r
   ra   r`   rd   QueryInfoKeyrange
contextlibsuppress
ValueErrorfloat	EnumValueappendEnumKeyr   )r   rj   vckeysvs_versrk   r]   rl   subkeysvaluesr    iverr   r   r   ry     s>   	

zSystemInfo.find_reg_vs_versdict[float, str]c           	   
   C  s   i }d}zt |}W n ty   | Y S w |D ]J}z=t j||d}t|ddd}t|}W d   n1 s;w   Y  |d }t t j|d ||| |d	 < W q tt	fyc   Y qw |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.jsonrtzutf-8)encodingNinstallationPathVC\Tools\MSVCinstallationVersion)
rI   listdirrd   rJ   rK   openjsonload_as_float_versionKeyError)	r   vs_versionsinstances_dirhashed_namesrf   
state_path
state_filestatevs_pathr   r   r   rr     s*   
z#SystemInfo.find_programdata_vs_versc                 C  s   t d| ddd S )z
        Return a string version as a simplified float version (major.minor)

        Parameters
        ----------
        version: str
            Version.

        Return
        ------
        float
            version
        .N   )r   rK   split)versionr   r   r   r     s   zSystemInfo._as_float_versionc                 C  s6   t j| jd| jd}| j| jj| jdp|S )zp
        Microsoft Visual Studio directory.

        Return
        ------
        str
            path
        Microsoft Visual Studio 0.1f)rI   rJ   rK   ProgramFilesx86ru   rq   rm   rR   )r   defaultr   r   r   VSInstallDir  s   zSystemInfo.VSInstallDirc                 C  s0   |   p|  }tj|sd}tj||S )zm
        Microsoft Visual C++ directory.

        Return
        ------
        str
            path
        z(Microsoft Visual C++ directory not found)	_guess_vc_guess_vc_legacyrI   rJ   isdirrz   r{   r|   )r   rJ   msgr   r   r   VCInstallDir  s
   
zSystemInfo.VCInstallDirc              	   C  s   | j dkrdS z| j| j  }W n ty   | j}Y nw tj|d}zt|d }| || _	tj||W S  t
tfyD   Y dS w )zl
        Locate Visual C++ for VS2017+.

        Return
        ------
        str
            path
              ,@r   r   rx   )ru   rs   r   r   rI   rJ   rK   r   r   rv   rd   
IndexError)r   vs_dirguess_vcrv   r   r   r   r     s   
	
zSystemInfo._guess_vcc                 C  st   t j| jd| jdd}t j| jj| jd}| j|d}|r*t j|dn|}| j| jj| jdp9|S )z{
        Locate Visual C++ for versions prior to 2017.

        Return
        ------
        str
            path
        r   r   z\VC
installdirVC)	rI   rJ   rK   r   ru   rq   rS   rm   rP   )r   r   reg_path	python_vc
default_vcr   r   r   r   *  s   	zSystemInfo._guess_vc_legacytuple[LiteralString, ...]c                 C  sJ   | j dkrdS | j dkrdS | j dkrdS | j dkrdS | j d	kr#d
S dS )z
        Microsoft Windows SDK versions for specified MSVC++ version.

        Return
        ------
        tuple of str
            versions
              "@)z7.0z6.1z6.0a      $@)z7.1z7.0a      &@)z8.0z8.0a      (@)8.1z8.1ar   )z10.0r   r   ru   r#   r   r   r   WindowsSdkVersion@  s   





zSystemInfo.WindowsSdkVersionc                 C     |  tj| jdS )zt
        Microsoft Windows SDK last version.

        Return
        ------
        str
            version
        lib)_use_last_dir_namerI   rJ   rK   WindowsSdkDirr#   r   r   r   WindowsSdkLastVersionV     
z SystemInfo.WindowsSdkLastVersion
str | Nonec                 C  s<  d}| j D ]}tj| jjd| }| j|d}|r nq|r'tj|sCtj| jj| j	d}| j|d}|rCtj|d}|rKtj|so| j D ] }|d|
d }d	| }tj| j|}tj|rn|}qN|rwtj|s| j D ]}d
| }tj| j|}tj|r|}qz|stj| jd}|S )zn
        Microsoft Windows SDK directory.

        Return
        ------
        str
            path
        r   vinstallationfolderr   r   WinSDKNr   zMicrosoft SDKs\Windows Kits\zMicrosoft SDKs\Windows\vPlatformSDK)r   rI   rJ   rK   rq   rV   rm   r   rS   rv   rfindrp   r   )r   sdkdirr   locrJ   install_baseintverdr   r   r   r   b  s<   





zSystemInfo.WindowsSdkDirc           	      C  s   | j dkr
d}d}nd}| j dkrdnd}| jjd|dd	d
}d| d| }g }| j dkrC| jD ]}|tj| jj	||g7 }q3| j
D ]}|tj| jjd| d|g7 }qF|D ]}| j|d}|rk|  S q\dS )zy
        Microsoft Windows SDK executable directory.

        Return
        ------
        str
            path
        r   #   r   (   r   TF)r   r2   r0   -zWinSDK-NetFxToolsr   r   Ar   N)ru   rA   r3   r   NetFxSdkVersionrI   rJ   rK   rq   rX   r   rV   rm   )	r   netfxverr   r2   fxregpathsr   rJ   execpathr   r   r   WindowsSDKExecutablePath  s&   



$z#SystemInfo.WindowsSDKExecutablePathc                 C  s.   t j| jj| jdd}| j|dpdS )zl
        Microsoft Visual F# directory.

        Return
        ------
        str
            path
        r   z	\Setup\F#
productdirr   )rI   rJ   rK   rq   rE   ru   rm   )r   rJ   r   r   r   FSharpInstallDir  s   
zSystemInfo.FSharpInstallDirc                 C  sH   | j dkrdnd}|D ]}| j| jjd| }|r!|pd  S qdS )zt
        Microsoft Universal CRT SDK directory.

        Return
        ------
        str
            path
        r   )1081r   kitsrootr   N)ru   rq   rm   rY   )r   versr   r   r   r   r   UniversalCRTSdkDir  s   zSystemInfo.UniversalCRTSdkDirc                 C  r   )z
        Microsoft Universal C Runtime SDK last version.

        Return
        ------
        str
            version
        r   )r   rI   rJ   rK   r   r#   r   r   r   UniversalCRTSdkLastVersion  r   z%SystemInfo.UniversalCRTSdkLastVersionc                 C  s   | j dkrdS dS )z
        Microsoft .NET Framework SDK versions.

        Return
        ------
        tuple of str
            versions
        r   )	z4.7.2z4.7.1z4.7z4.6.2z4.6.1z4.6z4.5.2z4.5.1z4.5r   r   r#   r   r   r   r     s
   
zSystemInfo.NetFxSdkVersionc                 C  s>   d}| j D ]}tj| jj|}| j|d}|r |S q|S )zu
        Microsoft .NET Framework SDK directory.

        Return
        ------
        str
            path
        r   kitsinstallationfolder)r   rI   rJ   rK   rq   rX   rm   )r   r   r   r   r   r   r   NetFxSdkDir  s   

zSystemInfo.NetFxSdkDirc                 C  &   t j| jd}| j| jjdp|S )zw
        Microsoft .NET Framework 32bit directory.

        Return
        ------
        str
            path
        zMicrosoft.NET\Frameworkframeworkdir32rI   rJ   rK   ro   rq   rm   rP   r   guess_fwr   r   r   FrameworkDir32     zSystemInfo.FrameworkDir32c                 C  r   )zw
        Microsoft .NET Framework 64bit directory.

        Return
        ------
        str
            path
        zMicrosoft.NET\Framework64frameworkdir64r   r   r   r   r   FrameworkDir64  r   zSystemInfo.FrameworkDir64tuple[str, ...]c                 C  
   |  dS )z
        Microsoft .NET Framework 32bit versions.

        Return
        ------
        tuple of str
            versions
            _find_dot_net_versionsr#   r   r   r   FrameworkVersion32#     

zSystemInfo.FrameworkVersion32c                 C  r   )z
        Microsoft .NET Framework 64bit versions.

        Return
        ------
        tuple of str
            versions
        @   r   r#   r   r   r   FrameworkVersion64/  r   zSystemInfo.FrameworkVersion64c                 C  s   | j | j jd| }t| d| }|p| |dpd}| jdkr'|dfS | jdkr>| dd	 d
kr:ddfS |dfS | jdkrEdS | jdkrLdS dS )z
        Find Microsoft .NET Framework versions.

        Parameters
        ----------
        bits: int
            Platform number of bits: 32 or 64.

        Return
        ------
        tuple of str
            versions
        frameworkverFrameworkDirr   r   r   zv4.0r   Nr   v4z
v4.0.30319v3.5r   )r   
v2.0.50727g       @)zv3.0r  r   )rq   rm   rP   getattrr   ru   r   )r   bitsreg_verdot_net_dirr   r   r   r   r   ;  s   

$

z!SystemInfo._find_dot_net_versionsc                   s,    fddt t D }t|dpdS )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
        c                 3  s4    | ]}t jt j |r|r|V  qd S r@   )rI   rJ   r   rK   
startswith).0dir_namerJ   prefixr   r   	<genexpr>j  s    
z0SystemInfo._use_last_dir_name.<locals>.<genexpr>Nr   )reversedrI   r   next)rJ   r
  matching_dirsr   r	  r   r   Y  s   zSystemInfo._use_last_dir_namer@   r9   )r   r   )r   r   r   r   )r   r   )r   )#r   r   r   r<   r	   r=   ro   rp   r   r   rt   ry   rr   staticmethodr   r>   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   rn   _  s\    	
*



*
$







rn   c                   @  s6   e Zd ZU ded< ded< ded< ded< ded< dS )	_EnvironmentDictr-   includer   libpathrJ   zNotRequired[str | None]py_vcruntime_redistN)r   r   r   __annotations__r   r   r   r   r  s  s   
 r  c                   @  sZ  e Zd ZdZdCdDddZedd	 Zed
d Zedd Zedd Z	edd Z
edd Zedd Zedd Zedd Zedd Zedd Zdd Zed d! Zed"d# Zed$d% Zed&d' Zed(d) Zed*d+ Zed,d- Zed.d/ Zed0d1 Zed2d3 Zed4d5 Zed6d7 ZedEd9d:ZdFdGd?d@ZdAdB Z dS )H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.
    Nr   r   r   c                 C  sB   t || _t| j| _t| j|| _| j|k rd}tj	|d S )Nz.No suitable Microsoft Visual C++ version found)
r   rA   r?   rq   rn   sirv   rz   r{   r|   )r   r   rv   
vc_min_vererrr   r   r   r     s   

zEnvironmentInfo.__init__c                 C     | j jS )zk
        Microsoft Visual Studio.

        Return
        ------
        float
            version
        )r  ru   r#   r   r   r   ru        
zEnvironmentInfo.vs_verc                 C  r  )zp
        Microsoft Visual C++ version.

        Return
        ------
        float
            version
        )r  rv   r#   r   r   r   rv     r  zEnvironmentInfo.vc_verc                   sX   ddg} j dkr# jjddd}|dg7 }|dg7 }|d| g7 } fdd	|D S )
zu
        Microsoft Visual Studio Tools.

        Return
        ------
        list of str
            paths
        zCommon7\IDEzCommon7\Toolsr   Tr2   r   z1Common7\IDE\CommonExtensions\Microsoft\TestWindowzTeam Tools\Performance Toolsc                      g | ]}t j jj|qS r   rI   rJ   rK   r  r   r  rJ   r#   r   r   
<listcomp>      z+EnvironmentInfo.VSTools.<locals>.<listcomp>)ru   rA   r3   )r   pathsarch_subdirr   r#   r   VSTools  s   



zEnvironmentInfo.VSToolsc                 C  s$   t j| jjdt j| jjdgS )z
        Microsoft Visual C++ & Microsoft Foundation Class Includes.

        Return
        ------
        list of str
            paths
        IncludezATLMFC\IncluderI   rJ   rK   r  r   r#   r   r   r   
VCIncludes  s   zEnvironmentInfo.VCIncludesc                   sh    j dkr jjdd}n jjdd}d| d| g} j dkr+|d| g7 } fd	d
|D S )z
        Microsoft Visual C++ & Microsoft Foundation Class Libraries.

        Return
        ------
        list of str
            paths
              .@Tr   r2   Libz
ATLMFC\Libr   z	Lib\storec                   r  r   r&  r  r#   r   r   r     r!  z/EnvironmentInfo.VCLibraries.<locals>.<listcomp>)ru   rA   r5   )r   r#  r"  r   r#   r   VCLibraries  s   


zEnvironmentInfo.VCLibrariesc                 C  "   | j dk rg S tj| jjdgS )z
        Microsoft Visual C++ store references Libraries.

        Return
        ------
        list of str
            paths
        r   zLib\store\references)ru   rI   rJ   rK   r  r   r#   r   r   r   VCStoreRefs  s   

zEnvironmentInfo.VCStoreRefsc                 C  s8  | j }tj|jdg}| jdkrdnd}| j|}|r+|tj|jd| g7 }| jdkrGd| jjdd }|tj|j|g7 }|S | jdkr| jj	
d	d
 }tjdd| d}|tj|j|| jjdd g7 }| jj	| jjkr|tj|j|| jjdd g7 }|S |tj|jdg7 }|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
        
VCPackagesr   TFBinr   r*  r(  r   r   binHostz%sr)  )r  rI   rJ   rK   r   ru   rA   r8   r3   r+   r   upperr5   r$   )r   r  toolsr6   r#  rJ   host_idhost_dirr   r   r   VCTools  s2   

	zEnvironmentInfo.VCToolsc                 C  st   | j dkr| jjddd}tj| jjd| gS | jjdd}tj| jjd}| j}tj|| d| gS )zw
        Microsoft Windows SDK Libraries.

        Return
        ------
        list of str
            paths
        r   Tr  r+  r)  r   um)	ru   rA   r5   rI   rJ   rK   r  r   _sdk_subdir)r   r#  r   libverr   r   r   OSLibraries-  s   

zEnvironmentInfo.OSLibrariesc                 C  s~   t j| jjd}| jdkr|t j|dgS | jdkr | j}nd}t j|| dt j|| dt j|| dgS )	zu
        Microsoft Windows SDK Include.

        Return
        ------
        list of str
            paths
        r  r   glr   r   sharedr8  winrt)rI   rJ   rK   r  r   ru   r9  )r   r  sdkverr   r   r   
OSIncludesA  s   


zEnvironmentInfo.OSIncludesc                 C  s   t j| jjd}g }| jdkr|| j7 }| jdkr$|t j|dg7 }| jdkr[||t j| jjdt j|ddt j|d	dt j|d
dt j| jjdd| jddddg7 }|S )z}
        Microsoft Windows SDK Libraries Paths.

        Return
        ------
        list of str
            paths
        
Referencesr   r   zCommonConfiguration\Neutralr   UnionMetadataz'Windows.Foundation.UniversalApiContractz1.0.0.0z%Windows.Foundation.FoundationContractz,Windows.Networking.Connectivity.WwanContractExtensionSDKszMicrosoft.VCLibsr   CommonConfigurationneutral)rI   rJ   rK   r  r   ru   r;  )r   refr  r   r   r   	OSLibpath[  s4   




zEnvironmentInfo.OSLibpathc                 C  s   t |  S )zs
        Microsoft Windows SDK Tools.

        Return
        ------
        list of str
            paths
        )list
_sdk_toolsr#   r   r   r   SdkTools  s   
zEnvironmentInfo.SdkToolsc                 c  s   | j dk r| j dkrdnd}tj| jj|V  | j s4| jjdd}d| }tj| jj|V  | j dv rY| j	 rAd}n| jjddd	}d
| }tj| jj|V  n%| j dkr~tj| jjd}| jjdd}| jj
}tj|| | V  | jjr| jjV  dS dS )z
        Microsoft Windows SDK Tools paths generator.

        Return
        ------
        generator of str
            paths
        r(  r   r0  zBin\x86Tr)  )r   r   r   r  zBin\NETFX 4.0 ToolsN)ru   rI   rJ   rK   r  r   rA   r,   r3   r(   r   r   )r   bin_dirr#  rJ   r?  r   r   r   rI    s,   
	





zEnvironmentInfo._sdk_toolsc                 C     | j j}|r| dS dS )zu
        Microsoft Windows SDK version subdir.

        Return
        ------
        str
            subdir
        r0   r   )r  r   r   ucrtverr   r   r   r9       
zEnvironmentInfo._sdk_subdirc                 C  s"   | j dkrg S tj| jjdgS )zs
        Microsoft Windows SDK Setup.

        Return
        ------
        list of str
            paths
        r   Setup)ru   rI   rJ   rK   r  r   r#   r   r   r   SdkSetup     

zEnvironmentInfo.SdkSetupc                   s   | j }| j | jdkrd}|  o|  }n| p| }|jdkp)|jdk}g }|r:| fdd jD 7 }|rH| fdd jD 7 }|S )zv
        Microsoft .NET Framework Tools.

        Return
        ------
        list of str
            paths
        r   Tr   c                      g | ]
}t j j|qS r   )rI   rJ   rK   r   r  r   r  r   r   r         z+EnvironmentInfo.FxTools.<locals>.<listcomp>c                   rS  r   )rI   rJ   rK   r   rT  rU  r   r   r     rV  )	rA   r  ru   r(   r,   r+   r$   r   r   )r   rA   	include32	include64r4  r   rU  r   FxTools  s"   

zEnvironmentInfo.FxToolsc                 C  s>   | j dk s	| jjsg S | jjdd}tj| jjd| gS )z~
        Microsoft .Net Framework SDK Libraries.

        Return
        ------
        list of str
            paths
        r   Tr)  zlib\um)ru   r  r   rA   r5   rI   rJ   rK   )r   r#  r   r   r   NetFxSDKLibraries  s   
z!EnvironmentInfo.NetFxSDKLibrariesc                 C  s*   | j dk s	| jjsg S tj| jjdgS )z}
        Microsoft .Net Framework SDK Includes.

        Return
        ------
        list of str
            paths
        r   z
include\um)ru   r  r   rI   rJ   rK   r#   r   r   r   NetFxSDKIncludes  s   
z EnvironmentInfo.NetFxSDKIncludesc                 C  s   t j| jjdgS )z
        Microsoft Visual Studio Team System Database.

        Return
        ------
        list of str
            paths
        zVSTSDB\Deployr  r#   r   r   r   VsTDb  s   
zEnvironmentInfo.VsTDbc                 C  s   | j dk rg S | j dk r| jj}| jjdd}n| jj}d}d| j dd| }tj||g}| j dkr@|tj||d	g7 }|S )
zn
        Microsoft Build Engine.

        Return
        ------
        list of str
            paths
        r   r(  Tr*  r   zMSBuild\r   z\binRoslyn)	ru   r  r   rA   r3   r   rI   rJ   rK   )r   	base_pathr#  rJ   buildr   r   r   MSBuild  s   



zEnvironmentInfo.MSBuildc                 C  r-  )zt
        Microsoft HTML Help Workshop.

        Return
        ------
        list of str
            paths
        r   zHTML Help Workshop)ru   rI   rJ   rK   r  r   r#   r   r   r   HTMLHelpWorkshop4  rR  z EnvironmentInfo.HTMLHelpWorkshopc                 C  sN   | j dk rg S | jjdd}tj| jjd}| j}tj|| d| gS )z
        Microsoft Universal C Runtime SDK Libraries.

        Return
        ------
        list of str
            paths
        r   Tr)  r   ucrt)	ru   rA   r5   rI   rJ   rK   r  r   _ucrt_subdir)r   r#  r   rN  r   r   r   UCRTLibrariesC  s   

zEnvironmentInfo.UCRTLibrariesc                 C  s8   | j dk rg S tj| jjd}tj|| j dgS )z
        Microsoft Universal C Runtime SDK Include.

        Return
        ------
        list of str
            paths
        r   r  rb  )ru   rI   rJ   rK   r  r   rc  )r   r  r   r   r   UCRTIncludesU  s   

zEnvironmentInfo.UCRTIncludesc                 C  rL  )z
        Microsoft Universal C Runtime SDK version subdir.

        Return
        ------
        str
            subdir
        r0   r   )r  r   rM  r   r   r   rc  e  rO  zEnvironmentInfo._ucrt_subdirc                 C  s$   d| j   krdkrg S  | jjgS )zk
        Microsoft Visual F#.

        Return
        ------
        list of str
            paths
        r   r   )ru   r  r   r#   r   r   r   FSharpr  s   

zEnvironmentInfo.FSharpr   c                   s   d| j  d| jjddd g }| jj}tj|	dd}tj
|r>tj|t|d }||tj|d	g7 }|tj|d
g7 }d| j d  ddt| jd  df} fddt||D }tttjj|dS )z{
        Microsoft Visual C++ runtime redistributable dll.

        Returns the first suitable path found or None.
        	vcruntimez0.dllTr)  r0   z\Toolsz\Redistrx   onecoreredistzMicrosoft.VC
   z.CRTc                 3  s&    | ]\}}t j| |V  qd S r@   )rI   rJ   rK   )r  r
  crt_dirr#  rg  r   r   r    s
    
z2EnvironmentInfo.VCRuntimeRedist.<locals>.<genexpr>N)rv   rA   r5   stripr  r   rI   rJ   dirnamer   r   rK   r   intru   r   r   r  filterisfile)r   prefixes
tools_pathredist_pathcrt_dirscandidate_pathsr   rl  r   VCRuntimeRedist  s    
zEnvironmentInfo.VCRuntimeRedistTexistsboolr  c                 C  s   t | d| j| j| j| jg|| d| j| j| j| j	| j
g|| d| j| j| j| jg|| d| j| j| j| j| j| j| j| j| jg	|d}| jdkrU| jrU| j|d< |S )z
        Return environment dict.

        Parameters
        ----------
        exists: bool
            It True, only return existing paths.

        Return
        ------
        dict
            environment
        r  r   r  rJ   )r  r   r  rJ      r  )r  _build_pathsr'  r@  re  r[  r,  r;  rY  rd  rZ  r.  rG  r7  r$  r\  rJ  rQ  r`  ra  rf  ru   rw  )r   rx  envr   r   r   
return_env  sV   
+
zEnvironmentInfo.return_envc           
      C  sx   t j|}t|dtj}t ||}|r!tt	tj
j|n|}|s2|  d}tj|t|}	tj|	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
        r   z environment variable is empty)r   chainfrom_iterabler	   r=   r   rI   pathseprH  rp  rJ   r   r3  rz   r{   r|   r   rK   )
r   rf   spec_path_listsrx  
spec_paths	env_pathsr"  extant_pathsr   unique_pathsr   r   r   r{    s   zEnvironmentInfo._build_paths)Nr   r9   r  )T)rx  ry  r   r  )!r   r   r   r<   r   r>   ru   rv   r$  r'  r,  r.  r7  r;  r@  rG  rJ  rI  r9  rQ  rY  rZ  r[  r\  r`  ra  rd  re  rc  rf  rw  r}  r{  r   r   r   r   r  {  sl    	






2


'
#











"=r  )r<   
__future__r   r   r   r   rI   os.pathplatformtypingr   r   more_itertoolsr   distutils.errorsrz   typing_extensionsr   r   systemr
   r	   dictr  r   r?   rn   r  r  r   r   r   r   <module>   s8    y >    