<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0-alpha1/dist/css/bootstrap.min.css" rel="stylesheet"
        integrity="sha384-GLhlTQ8iRABdZLl6O3oVMWSktQOp6b7In1Zl3/Jr59b6EGGoI1aFkw7cmDA6j6gD" crossorigin="anonymous">
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.3.0/css/all.min.css"
        integrity="sha512-SzlrxWUlpfuzQ+pcUCosxcglQRNAq/DZjVsC0lE40xsADsfeQoEypE+enwcOiGjk/bSuGGKHEyjSoQ1zVisanQ=="
        crossorigin="anonymous" referrerpolicy="no-referrer" />
</head>
</html>

Re                 @   s  d  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 d d l	 m
 Z
 d d l m Z e j   d k r d d l	 m Z e j Z n Gd	 d
   d
  Z e   Z e e j j f Z y d d l m Z Wn e k
 r Yn Xd d   Z d d d  Z d d   Z d d   Z d d d  Z Gd d   d  Z Gd d   d  Z Gd d   d  Z Gd d   d  Z  d S) 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_unpatchedWindows)winregc               @   s(   e  Z d  Z d Z d Z d Z d Z d S)r   N)__name__
__module____qualname__
HKEY_USERSHKEY_CURRENT_USERHKEY_LOCAL_MACHINEHKEY_CLASSES_ROOT r   r   /builddir/build/BUILDROOT/alt-python35-setuptools-36.3.0-4.el8.x86_64/opt/alt/python35/lib/python3.5/site-packages/setuptools/msvc.pyr   (   s   r   )Regc             C   s   d } | d |  f } y t  j | d  } WnS t k
 r y& | d |  f } t  j | d  } Wn t k
 r| d } Yn XYn X| r t j j j j | d  } t j j |  r | St t  |   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_valueKeyErrorospathjoinisfiler   msvc9_find_vcvarsall)versionZVC_BASEkey
productdir	vcvarsallr   r   r   r   ?   s    r   x86c             O   s   y# t  t  } | |  | | |  SWn) t j j k
 r= Yn t k
 rN Yn Xy t | |   j   SWn> t j j k
 r } z t | |  |    WYd d } ~ Xn Xd S)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)	r   msvc9_query_vcvarsall	distutilserrorsDistutilsPlatformError
ValueErrorEnvironmentInfo
return_env_augment_exception)verarchargskwargsorigexcr   r   r   r    j   s    r    c             C   s   y t  t  |   SWn t j j k
 r. Yn Xy t |  d d j   SWn; t j j k
 r } z t | d    WYd d } ~ Xn Xd S)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
    
vc_min_verg      ,@N)r   msvc14_get_vc_envr!   r"   r#   r%   r&   r'   )Z	plat_specr-   r   r   r   r/      s    r/   c              O   s_   d t  j k rL d d l } t | j  t d  k  rL | j j j |  |   St t	  |  |   S)z
    Patched "distutils._msvccompiler.gen_lib_options" for fix
    compatibility between "numpy.distutils" and "distutils._msvccompiler"
    (for Numpy < 1.11.2)
    znumpy.distutilsr   Nz1.11.2)
sysmodulesnumpyr   __version__r!   Z	ccompilerZgen_lib_optionsr   msvc14_gen_lib_options)r*   r+   npr   r   r   r4      s
    r4   r   c             C   s   |  j  d } d | j   k s1 d | j   k r d } | j t     } d } | d k r | j   j d  d k r | d	 7} | | d
 7} q | d 7} n= | d k r | d 7} | | d 7} n | d k r | d 7} | f |  _  d S)zl
    Add details to the exception message to help guide the user
    as to what action will resolve it.
    r   r   zvisual cz0Microsoft Visual C++ {version:0.1f} is required.z-www.microsoft.com/download/details.aspx?id=%dg      "@Zia64r   z* 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*   lowerformatlocalsfind)r-   r   r)   messagetmplZ
msdownloadr   r   r   r'      s     $


r'   c               @   s   e  Z d  Z d Z e j d d  j   Z 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 informations.

    Parameters
    ----------
    arch: str
        Target architecture.
    Zprocessor_architecturer   c             C   s   | j    j d d  |  _ d  S)Nx64amd64)r7   replacer)   )selfr)   r   r   r   __init__   s    zPlatformInfo.__init__c             C   s!   |  j  |  j  j d  d d   S)N_r   )r)   r:   )rA   r   r   r   
target_cpu   s    zPlatformInfo.target_cpuc             C   s   |  j  d k S)Nr   )rD   )rA   r   r   r   target_is_x86  s    zPlatformInfo.target_is_x86c             C   s   |  j  d k S)Nr   )current_cpu)rA   r   r   r   current_is_x86  s    zPlatformInfo.current_is_x86Fc             C   s=   |  j  d k r | r d S|  j  d k r2 | r2 d Sd |  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
        ------
        subfolder: str
            '	arget', or '' (see hidex86 parameter)
        r   r   r?   z\x64z\%s)rF   )rA   hidex86r>   r   r   r   current_dir	  s    zPlatformInfo.current_dirc             C   s=   |  j  d k r | r d S|  j  d k r2 | r2 d Sd |  j  S)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)
        r   r   r?   z\x64z\%s)rD   )rA   rH   r>   r   r   r   
target_dir  s    zPlatformInfo.target_dirc             C   sB   | r d n |  j  } |  j | k r( d S|  j   j d d |  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.
        r   r   \z\%s_)rF   rD   rJ   r@   )rA   forcex86currentr   r   r   	cross_dir5  s    zPlatformInfo.cross_dirN)r   r	   r
   __doc__safe_envgetr7   rF   rB   propertyrD   rE   rG   rI   rJ   rN   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   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 d  Z d d   Z d S)RegistryInfoz
    Microsoft Visual Studio related registry informations.

    Parameters
    ----------
    platform_info: PlatformInfo
        "PlatformInfo" instance.
    c             C   s   | |  _  d  S)N)pi)rA   Zplatform_infor   r   r   rB   Z  s    zRegistryInfo.__init__c             C   s   d S)z<
        Microsoft Visual Studio root registry key.
        ZVisualStudior   )rA   r   r   r   visualstudio]  s    zRegistryInfo.visualstudioc             C   s   t  j j |  j d  S)z;
        Microsoft Visual Studio SxS registry key.
        ZSxS)r   r   r   rU   )rA   r   r   r   sxsd  s    zRegistryInfo.sxsc             C   s   t  j j |  j d  S)z8
        Microsoft Visual C++ VC7 registry key.
        ZVC7)r   r   r   rV   )rA   r   r   r   vck  s    zRegistryInfo.vcc             C   s   t  j j |  j d  S)z;
        Microsoft Visual Studio VS7 registry key.
        ZVS7)r   r   r   rV   )rA   r   r   r   vsr  s    zRegistryInfo.vsc             C   s   d S)z?
        Microsoft Visual C++ for Python registry key.
        zDevDiv\VCForPythonr   )rA   r   r   r   vc_for_pythony  s    zRegistryInfo.vc_for_pythonc             C   s   d S)z-
        Microsoft SDK registry key.
        zMicrosoft SDKsr   )rA   r   r   r   microsoft_sdk  s    zRegistryInfo.microsoft_sdkc             C   s   t  j j |  j d  S)z>
        Microsoft Windows/Platform SDK registry key.
        r   )r   r   r   rZ   )rA   r   r   r   windows_sdk  s    zRegistryInfo.windows_sdkc             C   s   t  j j |  j d  S)z<
        Microsoft .NET Framework SDK registry key.
        ZNETFXSDK)r   r   r   rZ   )rA   r   r   r   	netfx_sdk  s    zRegistryInfo.netfx_sdkc             C   s   d S)z<
        Microsoft Windows Kits Roots registry key.
        zWindows Kits\Installed Rootsr   )rA   r   r   r   windows_kits_roots  s    zRegistryInfo.windows_kits_rootsFc             C   s:   |  j  j   s | r d n d } t j 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: value
        r   ZWow6432NodeZSoftware	Microsoft)rT   rG   r   r   r   )rA   r   r   Znode64r   r   r   	microsoft  s    !zRegistryInfo.microsoftc             C   s   t  j } t  j } |  j } x |  j D] } y | | | |  d |  } Wnm t t f k
 r |  j j   s y" | | | | d  d |  } Wq t t f k
 r w% Yq Xn w% Yn Xy t  j	 | |  d SWq% t t f k
 r Yq% Xq% Wd 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
        r   TN)
r   KEY_READOpenKeyr_   HKEYSOSErrorIOErrorrT   rG   QueryValueEx)rA   r   namer`   Zopenkeymshkeybkeyr   r   r   lookup  s"    			"zRegistryInfo.lookupN)r   r	   r
   rO   r   r   r   r   r   rb   rB   rR   rU   rV   rW   rX   rY   rZ   r[   r\   r]   r_   rj   r   r   r   r   rS   L  s"   rS   c               @   s  e  Z d  Z d Z e j d d  Z e j d d  Z e j d e  Z d d d  Z	 d	 d
   Z
 d d   Z e d d    Z e d d    Z 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 d% d&    Z e d' d(    Z e d) d*    Z e d+ d,    Z e d- d.    Z d/ d0   Z d d1 d2  Z d S)3
SystemInfoz
    Microsoft Windows and Visual Studio related system inormations.

    Parameters
    ----------
    registry_info: RegistryInfo
        "RegistryInfo" instance.
    vc_ver: float
        Required Microsoft Visual C++ version.
    WinDirr   ProgramFileszProgramFiles(x86)Nc             C   s1   | |  _  |  j  j |  _ | p' |  j   |  _ d  S)N)rirT   _find_latest_available_vc_vervc_ver)rA   Zregistry_inforp   r   r   r   rB     s    	zSystemInfo.__init__c             C   sC   y |  j    d SWn* t k
 r> d } t j j |   Yn Xd  S)Nr   z%No Microsoft Visual C++ version foundr6   )find_available_vc_vers
IndexErrorr!   r"   r#   )rA   errr   r   r   ro     s
    z(SystemInfo._find_latest_available_vc_verc             C   s  |  j  j } |  j  j |  j  j |  j  j f } g  } xF|  j  j D]8} x/| D]'} y% t j | | |  d t j  } Wn t	 t
 f k
 r wM Yn Xt j |  \ } } }	 xb t |  D]T }
 y9 t t j | |
  d  } | | k r | j |  Wq t k
 rYq Xq Wx^ t |  D]P }
 y5 t t j | |
   } | | k rZ| j |  Wq t k
 roYq Xq WqM Wq@ Wt |  S)zC
        Find all available Microsoft Visual C++ versions.
        r   )rn   r_   rW   rY   rX   rb   r   ra   r`   rc   rd   ZQueryInfoKeyrangefloatZ	EnumValueappendr$   EnumKeysorted)rA   rg   ZvckeysZvc_versrh   r   ri   ZsubkeysvaluesrC   ir(   r   r   r   rq     s2    !%	z!SystemInfo.find_available_vc_versc             C   sK   d |  j  } t j j |  j |  } |  j j |  j j d |  j   pJ | S)z4
        Microsoft Visual Studio directory.
        zMicrosoft Visual Studio %0.1fz%0.1f)rp   r   r   r   ProgramFilesx86rn   rj   rX   )rA   rf   defaultr   r   r   VSInstallDir  s    zSystemInfo.VSInstallDirc             C   s   |  j  |  j   p |  j   } t j j |  j j d |  j  } |  j j	 | d  } | rq t j j | d  n | } |  j j	 |  j j
 d |  j  p | } t j j |  s d } t j j |   | S)z1
        Microsoft Visual C++ directory.
        z%0.1fr   ZVCz(Microsoft Visual C++ directory not found)r}   	_guess_vc_guess_vc_legacyr   r   r   rn   rY   rp   rj   rW   isdirr!   r"   r#   )rA   guess_vcZreg_pathZ	python_vcZ
default_vcr   msgr   r   r   VCInstallDir  s    "!(zSystemInfo.VCInstallDirc             C   s}   |  j  d k r d Sd } t j j |  j |  } y* t j |  d } t j j | |  SWn t t t f k
 rx Yn Xd S)z*
        Locate Visual C for 2017
        g      ,@NzVC\Tools\MSVCr   r6   )	rp   r   r   r   r}   listdirrc   rd   rr   )rA   r|   r   Zvc_exact_verr   r   r   r~   0  s    zSystemInfo._guess_vcc             C   s#   d |  j  } t j j |  j |  S)z<
        Locate Visual C for versions prior to 2017
        z Microsoft Visual Studio %0.1f\VC)rp   r   r   r   r{   )rA   r|   r   r   r   r   @  s    zSystemInfo._guess_vc_legacyc             C   sc   |  j  d k r d S|  j  d k r& d S|  j  d k r9 d S|  j  d k rL d S|  j  d k r_ d Sd S)zN
        Microsoft Windows SDK versions for specified MSVC++ version.
        g      "@7.06.16.0ag      $@7.17.0ag      &@8.08.0ag      (@8.18.1ag      ,@10.0N)r   r   r   )r   r   )r   r   )r   r   )r   r   )rp   )rA   r   r   r   WindowsSdkVersionG  s    zSystemInfo.WindowsSdkVersionc             C   s   |  j  t j j |  j d   S)z4
        Microsoft Windows SDK last version
        lib)_use_last_dir_namer   r   r   WindowsSdkDir)rA   r   r   r   WindowsSdkLastVersionW  s    z SystemInfo.WindowsSdkLastVersionc             C   s  d } xL |  j  D]A } t j j |  j j d |  } |  j j | d  } | r Pq W| so t j j |  r t j j |  j j d |  j	  } |  j j | d  } | r t j j | d  } | s t j j |  rBxd |  j  D]Y } | d | j
 d   } d	 | } t j j |  j |  } t j j |  r | } q W| s\t j j |  rxK |  j  D]@ } d
 | } t j j |  j |  } t j j |  rf| } qfW| st j j |  j d  } | S)z2
        Microsoft Windows SDK directory.
        r   zv%sinstallationfolderz%0.1fr   ZWinSDKN.zMicrosoft SDKs\Windows Kits\%szMicrosoft SDKs\Windows\v%sZPlatformSDK)r   r   r   r   rn   r[   rj   r   rY   rp   rfindrm   r   )rA   sdkdirr(   locr   install_baseZintverdr   r   r   r   _  s6    "



zSystemInfo.WindowsSdkDirc       	      C   s2  |  j  d k r d } d } n< d } |  j  d k r9 d n d } |  j j d d d	 |  } d
 | | j d d  f } g  } |  j  d k r x6 |  j D]+ } | t j j |  j j	 | |  g 7} q Wx: |  j
 D]/ } | t j j |  j j d | |  g 7} q Wx* | D]" } |  j j | d  } | rPqW| S)z=
        Microsoft Windows SDK executable directory.
        g      &@#   r   (   g      (@TFr>   rH   zWinSDK-NetFx%dTools%srK   -g      ,@zv%sAr   )rp   rT   rI   r@   NetFxSdkVersionr   r   r   rn   r\   r   r[   rj   )	rA   Znetfxverr)   rH   ZfxZregpathsr(   r   Zexecpathr   r   r   WindowsSDKExecutablePath  s$    	)-z#SystemInfo.WindowsSDKExecutablePathc             C   sA   d |  j  } t j j |  j j |  } |  j j | d  p@ d S)z0
        Microsoft Visual F# directory.
        z%0.1f\Setup\F#r   r   )rp   r   r   r   rn   rU   rj   )rA   r   r   r   r   FSharpInstallDir  s    zSystemInfo.FSharpInstallDirc             C   s_   |  j  d k r d } n f  } x4 | D], } |  j j |  j j d |  } | r% Pq% W| p^ d S)z8
        Microsoft Universal CRT SDK directory.
        g      ,@1081z
kitsroot%sr   )r   r   )rp   rn   rj   r]   )rA   versr(   r   r   r   r   UniversalCRTSdkDir  s    	zSystemInfo.UniversalCRTSdkDirc             C   s   |  j  t j j |  j d   S)z@
        Microsoft Universal C Runtime SDK last version
        r   )r   r   r   r   r   )rA   r   r   r   UniversalCRTSdkLastVersion  s    z%SystemInfo.UniversalCRTSdkLastVersionc             C   s   |  j  d k r d Sf  Sd S)z8
        Microsoft .NET Framework SDK versions.
        g      ,@4.6.14.6N)r   r   )rp   )rA   r   r   r   r     s    zSystemInfo.NetFxSdkVersionc             C   sU   xH |  j  D]= } t j j |  j j |  } |  j j | d  } | r
 Pq
 W| pT d S)z9
        Microsoft .NET Framework SDK directory.
        Zkitsinstallationfolderr   )r   r   r   r   rn   r\   rj   )rA   r(   r   r   r   r   r   NetFxSdkDir  s    zSystemInfo.NetFxSdkDirc             C   s7   t  j j |  j d  } |  j j |  j j d  p6 | S)z;
        Microsoft .NET Framework 32bit directory.
        zMicrosoft.NET\FrameworkZframeworkdir32)r   r   r   rl   rn   rj   rW   )rA   guess_fwr   r   r   FrameworkDir32  s    zSystemInfo.FrameworkDir32c             C   s7   t  j j |  j d  } |  j j |  j j d  p6 | S)z;
        Microsoft .NET Framework 64bit directory.
        zMicrosoft.NET\Framework64Zframeworkdir64)r   r   r   rl   rn   rj   rW   )rA   r   r   r   r   FrameworkDir64  s    zSystemInfo.FrameworkDir64c             C   s   |  j  d  S)z:
        Microsoft .NET Framework 32bit versions.
            )_find_dot_net_versions)rA   r   r   r   FrameworkVersion32  s    zSystemInfo.FrameworkVersion32c             C   s   |  j  d  S)z:
        Microsoft .NET Framework 64bit versions.
        @   )r   )rA   r   r   r   FrameworkVersion64  s    zSystemInfo.FrameworkVersion64c             C   s   |  j  j |  j  j d |  } t |  d |  } | pM |  j | d  pM d } |  j d k rn | d f } nU |  j d k r | j   d d	  d
 k r d n | d f } n |  j d k r d } |  j d k r d } | S)z
        Find Microsoft .NET Framework versions.

        Parameters
        ----------
        bits: int
            Platform number of bits: 32 or 64.
        zframeworkver%dzFrameworkDir%dvr   g      (@zv4.0g      $@N   Zv4z
v4.0.30319v3.5g      "@
v2.0.50727g       @v3.0)r   r   )r   r   )rn   rj   rW   getattrr   rp   r7   )rA   bitsZreg_verZdot_net_dirr(   Zframeworkverr   r   r   r     s    
%z!SystemInfo._find_dot_net_versionsc                s>      f d d   t  t j     D } t | d  p= d S)z
        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 startings by this prefix
        c             3   sE   |  ]; } t  j j t  j j   |   r | j   r | Vq d  S)N)r   r   r   r   
startswith).0dir_name)r   prefixr   r   	<genexpr>)  s   !z0SystemInfo._use_last_dir_name.<locals>.<genexpr>Nr   )reversedr   r   next)rA   r   r   Zmatching_dirsr   )r   r   r   r     s    zSystemInfo._use_last_dir_name) r   r	   r
   rO   rP   rQ   rl   rm   r{   rB   ro   rq   rR   r}   r   r~   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   rk     s4   
&	rk   c               @   s  e  Z d  Z d Z d d 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 d, d-    Z e d. d/    Z e d0 d1    Z e d2 d3    Z e d4 d5    Z d6 d7 d8  Z d9 d:   Z d d; d<  Z  d S)=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.
    Nr   c             C   sa   t  |  |  _ t |  j  |  _ t |  j |  |  _ |  j | k  r] d } t j j	 |   d  S)Nz.No suitable Microsoft Visual C++ version found)
r=   rT   rS   rn   rk   sirp   r!   r"   r#   )rA   r)   rp   r.   rs   r   r   r   rB   I  s    zEnvironmentInfo.__init__c             C   s
   |  j  j S)z/
        Microsoft Visual C++ version.
        )r   rp   )rA   r   r   r   rp   R  s    zEnvironmentInfo.vc_verc                sx   d d g }   j  d k ra   j j d d d d  } | d g 7} | d g 7} | d	 | g 7}   f d
 d   | D S)z/
        Microsoft Visual Studio Tools
        zCommon7\IDEzCommon7\Toolsg      ,@rH   Tr>   z1Common7\IDE\CommonExtensions\Microsoft\TestWindowzTeam Tools\Performance ToolszTeam Tools\Performance Tools%sc                s+   g  |  ]! } t  j j   j j |   q Sr   )r   r   r   r   r}   )r   r   )rA   r   r   
<listcomp>f  s   	 z+EnvironmentInfo.VSTools.<locals>.<listcomp>)rp   rT   rI   )rA   pathsarch_subdirr   )rA   r   VSToolsY  s    zEnvironmentInfo.VSToolsc             C   s4   t  j j |  j j d  t  j j |  j j d  g S)zL
        Microsoft Visual C++ & Microsoft Foundation Class Includes
        IncludezATLMFC\Include)r   r   r   r   r   )rA   r   r   r   
VCIncludesh  s    zEnvironmentInfo.VCIncludesc                s     j  d k r'   j j d d  } n   j j d d  } d | d | g }   j  d k rp | d | g 7}   f d	 d
   | D S)zM
        Microsoft Visual C++ & Microsoft Foundation Class Libraries
        g      .@r>   TrH   zLib%szATLMFC\Lib%sg      ,@zLib\store%sc                s+   g  |  ]! } t  j j   j j |   q Sr   )r   r   r   r   r   )r   r   )rA   r   r   r   ~  s   	 z/EnvironmentInfo.VCLibraries.<locals>.<listcomp>)rp   rT   rJ   )rA   r   r   r   )rA   r   VCLibrariesp  s    zEnvironmentInfo.VCLibrariesc             C   s/   |  j  d k  r g  St j j |  j j d  g S)zA
        Microsoft Visual C++ store references Libraries
        g      ,@zLib\store\references)rp   r   r   r   r   r   )rA   r   r   r   VCStoreRefs  s    zEnvironmentInfo.VCStoreRefsc             C   s  |  j  } t j j | j d  g } |  j d k r9 d n d } |  j j |  } | rz | t j j | j d |  g 7} |  j d k r d |  j j d d  } | t j j | j |  g 7} n |  j d k rm|  j j	   r d	 n d
 } | t j j | j | |  j j
 d d   g 7} |  j j |  j j k r| t j j | j | |  j j d d   g 7} n | t j j | j d  g 7} | S)z,
        Microsoft Visual C++ Tools
        Z
VCPackagesg      $@TFzBin%sg      ,@rH   g      .@zbin\HostX86%szbin\HostX64%sr>   Bin)r   r   r   r   r   rp   rT   rN   rI   rG   rJ   rF   rD   )rA   r   toolsrL   r   r   Zhost_dirr   r   r   VCTools  s&    	#"&)zEnvironmentInfo.VCToolsc             C   s   |  j  d k rJ |  j j d d d d  } t j j |  j j d |  g S|  j j d d  } t j j |  j j d  } |  j } t j j | d | | f  g Sd S)	z1
        Microsoft Windows SDK Libraries
        g      $@rH   Tr>   zLib%sr   z%sum%sN)	rp   rT   rJ   r   r   r   r   r   _sdk_subdir)rA   r   r   Zlibverr   r   r   OSLibraries  s     	zEnvironmentInfo.OSLibrariesc             C   s   t  j j |  j j d  } |  j d k rC | t  j j | d  g S|  j d k r^ |  j } n d } t  j j | d |  t  j j | d |  t  j j | d |  g Sd	 S)
z/
        Microsoft Windows SDK Include
        includeg      $@glg      ,@r   z%ssharedz%sumz%swinrtN)r   r   r   r   r   rp   r   )rA   r   sdkverr   r   r   
OSIncludes  s    zEnvironmentInfo.OSIncludesc             C   s  t  j j |  j j d  } g  } |  j d k r= | |  j 7} |  j d k rh | t  j j | d  g 7} |  j d k r	| | t  j j |  j j d  t  j j | d d  t  j j | d	 d  t  j j | d
 d  t  j j |  j j d d d |  j d d d  g 7} | S)z7
        Microsoft Windows SDK Libraries Paths
        Z
Referencesg      "@g      &@zCommonConfiguration\Neutralg      ,@ZUnionMetadataz'Windows.Foundation.UniversalApiContractz1.0.0.0z%Windows.Foundation.FoundationContractz,Windows.Networking.Connectivity.WwanContractZExtensionSDKszMicrosoft.VCLibsz%0.1fZCommonConfigurationZneutral)r   r   r   r   r   rp   r   )rA   reflibpathr   r   r   	OSLibpath  s>    					
zEnvironmentInfo.OSLibpathc             C   s   t  |  j    S)z-
        Microsoft Windows SDK Tools
        )list
_sdk_tools)rA   r   r   r   SdkTools  s    zEnvironmentInfo.SdkToolsc             c   s  |  j  d k  rD |  j  d k r$ d n d } t j j |  j j |  V|  j j   s |  j j d d  } d | } t j j |  j j |  V|  j  d k s |  j  d k r|  j j	   r d	 } n |  j j d
 d d d  } d | } t j j |  j j |  Vni |  j  d k rmt j j |  j j d  } |  j j d d  } |  j j
 } t j j | d | | f  V|  j j r|  j j Vd S)z=
        Microsoft Windows SDK Tools paths generator
        g      .@g      &@r   zBin\x86r>   TzBin%sg      $@r   rH   zBin\NETFX 4.0 Tools%sz%s%sN)rp   r   r   r   r   r   rT   rG   rI   rE   r   r   )rA   bin_dirr   r   r   r   r   r   r     s(    
	
zEnvironmentInfo._sdk_toolsc             C   s   |  j  j } | r d | Sd S)z6
        Microsoft Windows SDK version subdir
        z%s\r   )r   r   )rA   ucrtverr   r   r   r     s    zEnvironmentInfo._sdk_subdirc             C   s/   |  j  d k r g  St j j |  j j d  g S)z-
        Microsoft Windows SDK Setup
        g      "@ZSetup)rp   r   r   r   r   r   )rA   r   r   r   SdkSetup%  s    zEnvironmentInfo.SdkSetupc                s   |  j  } |  j   |  j d k rD d } | j   o> | j   } n6 | j   pY | j   } | j d k pw | j d k } g  } | r |   f d d     j D 7} | r |   f d d     j D 7} | S)z0
        Microsoft .NET Framework Tools
        g      $@Tr?   c                s(   g  |  ] } t  j j   j |   q Sr   )r   r   r   r   )r   r(   )r   r   r   r   @  s   	z+EnvironmentInfo.FxTools.<locals>.<listcomp>c                s(   g  |  ] } t  j j   j |   q Sr   )r   r   r   r   )r   r(   )r   r   r   r   C  s   	)	rT   r   rp   rE   rG   rF   rD   r   r   )rA   rT   Z	include32Z	include64r   r   )r   r   FxTools/  s    		zEnvironmentInfo.FxToolsc             C   sU   |  j  d k  s |  j j r  g  S|  j j d d  } t j j |  j j d |  g S)z8
        Microsoft .Net Framework SDK Libraries
        g      ,@r>   Tzlib\um%s)rp   r   r   rT   rJ   r   r   r   )rA   r   r   r   r   NetFxSDKLibrariesG  s    z!EnvironmentInfo.NetFxSDKLibrariesc             C   s<   |  j  d k  s |  j j r  g  St j j |  j j d  g S)z7
        Microsoft .Net Framework SDK Includes
        g      ,@z
include\um)rp   r   r   r   r   r   )rA   r   r   r   NetFxSDKIncludesR  s    z EnvironmentInfo.NetFxSDKIncludesc             C   s   t  j j |  j j d  g S)z>
        Microsoft Visual Studio Team System Database
        zVSTSDB\Deploy)r   r   r   r   r}   )rA   r   r   r   VsTDb\  s    zEnvironmentInfo.VsTDbc             C   s   |  j  d k  r g  S|  j  d k  rF |  j j } |  j j d d  } n |  j j } d } d |  j  | f } t j j | |  g } |  j  d k r | t j j | | d  g 7} | S)z(
        Microsoft Build Engine
        g      (@g      .@rH   Tr   zMSBuild\%0.1f\bin%sZRoslyn)	rp   r   r{   rT   rI   r}   r   r   r   )rA   	base_pathr   r   buildr   r   r   MSBuildc  s    zEnvironmentInfo.MSBuildc             C   s/   |  j  d k  r g  St j j |  j j d  g S)z.
        Microsoft HTML Help Workshop
        g      &@zHTML Help Workshop)rp   r   r   r   r   r{   )rA   r   r   r   HTMLHelpWorkshopz  s    z EnvironmentInfo.HTMLHelpWorkshopc             C   sl   |  j  d k  r g  S|  j j d d  } t j j |  j j d  } |  j } t j j | d | | f  g S)z=
        Microsoft Universal C Runtime SDK Libraries
        g      ,@r>   Tr   z%sucrt%s)	rp   rT   rJ   r   r   r   r   r   _ucrt_subdir)rA   r   r   r   r   r   r   UCRTLibraries  s    	zEnvironmentInfo.UCRTLibrariesc             C   sK   |  j  d k  r g  St j j |  j j d  } t j j | d |  j  g S)z;
        Microsoft Universal C Runtime SDK Include
        g      ,@r   z%sucrt)rp   r   r   r   r   r   r   )rA   r   r   r   r   UCRTIncludes  s    zEnvironmentInfo.UCRTIncludesc             C   s   |  j  j } | r d | Sd S)zB
        Microsoft Universal C Runtime SDK version subdir
        z%s\r   )r   r   )rA   r   r   r   r   r     s    zEnvironmentInfo._ucrt_subdirc             C   s,   |  j  d k  r" |  j  d k r" g  S|  j j S)z%
        Microsoft Visual F#
        g      &@g      (@)rp   r   r   )rA   r   r   r   FSharp  s    zEnvironmentInfo.FSharpc             C   s   |  j  j d d  } |  j d k  r9 |  j j } d } n |  j j j d d  } d } |  j d k rl d n |  j } | | |  j | f } t j j | |  S)	zA
        Microsoft Visual C++ runtime redistribuable dll
        r>   T   z-redist%s\Microsoft.VC%d0.CRT\vcruntime%d0.dllz\Toolsz\Redistz.onecore%s\Microsoft.VC%d0.CRT\vcruntime%d0.dllg      ,@)	rT   rJ   rp   r   r   r@   r   r   r   )rA   r   Zredist_pathZ	vcruntimeZdll_verr   r   r   VCRuntimeRedist  s    	zEnvironmentInfo.VCRuntimeRedistTc             C   s  t  d |  j d |  j |  j |  j |  j g |  d |  j d |  j |  j |  j |  j	 |  j
 g |  d |  j d |  j |  j |  j |  j g |  d |  j d |  j |  j |  j |  j |  j |  j |  j |  j |  j g	 |   } |  j d k rt j j |  j  r|  j | d <| S)z
        Return environment dict.

        Parameters
        ----------
        exists: bool
            It True, only return existing paths.
        r   r   r   r      Zpy_vcruntime_redist)dict_build_pathsr   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   rp   r   r   r   r   )rA   existsenvr   r   r   r&     sD    												$zEnvironmentInfo.return_envc       
      C   s   t  j j |  } t j | d  j t j  } t  j | |  } | rc t t	 t j
 j |   n | } | s d | j   } t j j |   |  j |  }	 t j j |	  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.
        r   z %s environment variable is empty)	itertoolschainfrom_iterablerP   rQ   splitr   pathsepr   filterr   r   upperr!   r"   r#   _unique_everseenr   )
rA   rf   Zspec_path_listsr   Z
spec_pathsZ	env_pathsr   Zextant_pathsr   Zunique_pathsr   r   r   r     s    	'zEnvironmentInfo._build_pathsc             c   s   t    } | j } | d k rM xd t | j |  D] } | |  | Vq1 Wn8 x5 | D]- } | |  } | | k rT | |  | VqT Wd S)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)setaddr   __contains__)rA   iterabler   seenZseen_addelementkr   r   r   r     s    			

z EnvironmentInfo._unique_everseen)!r   r	   r
   rO   rB   rR   rp   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r&   r   r   r   r   r   r   r%   1  s:   		 -



-r%   )!rO   r   r0   platformr   distutils.errorsr!   Z&pkg_resources.extern.packaging.versionr   Zsetuptools.extern.six.movesr   Zmonkeyr   systemr   environrP   r   ImportErrorr"   r#   Z_msvc9_suppress_errorsZdistutils.msvc9compilerr   r   r    r/   r4   r'   r=   rS   rk   r%   r   r   r   r   <module>   s:   	+/&%[ a