509318396
Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­
<!DOCTYPE html>
<html>
3

  \\  ã               @   s‚  d dl Z d dlZd dlmZmZmZmZmZ d dlm	Z	m
Z
mZ d dlmZ dZy,d dlZdZeZejZejZejZejZW nh ek
rä   y4d dlZd dlZdZeZejZejZejZejZW n ek
rÞ   ejdƒ Y nX Y nX erþejejejej fZ!dd	„ Z"d
d„ Z#dd„ Z$G dd„ dƒZ%dd„ Z&dd„ Z'dd„ Z(G dd„ de	ƒZ)e&ƒ dk�r~ej*dƒ e)Z+d dl,m)Z) d dl,m%Z% dS )é    N)ÚDistutilsExecErrorÚDistutilsPlatformErrorÚCompileErrorÚLibErrorÚ	LinkError)Ú	CCompilerÚgen_preprocess_optionsÚgen_lib_options)ÚlogFTz�Warning: Can't read registry to find the necessary compiler setting
Make sure that Python modules winreg, win32api or win32con are installed.c             C   sn   yt | |ƒ}W n tk
r"   d S X g }d}x<yt||ƒ}W n tk
rR   P Y nX |j|ƒ |d7 }q.W |S )Nr   é   )ÚRegOpenKeyExÚRegErrorÚ
RegEnumKeyÚappend)ÚbaseÚkeyÚhandleÚLÚiÚk© r   ú./usr/lib64/python3.6/distutils/msvccompiler.pyÚ	read_keys7   s    
r   c             C   s‚   yt | |ƒ}W n tk
r"   d S X i }d}xPyt||ƒ\}}}W n tk
rX   P Y nX |jƒ }t|ƒ|t|ƒ< |d7 }q.W |S )Nr   r   )r   r   ÚRegEnumValueÚlowerÚconvert_mbcs)r   r   r   Údr   ÚnameÚvalueÚtyper   r   r   Úread_valuesH   s    r    c             C   s:   t | dd ƒ}|d k	r6y|dƒ} W n tk
r4   Y nX | S )NÚdecodeÚmbcs)ÚgetattrÚUnicodeError)ÚsZdecr   r   r   r   ]   s    r   c               @   s,   e Zd Zdd„ Zdd„ Zdd„ Zdd„ Zd	S )
ÚMacroExpanderc             C   s   i | _ | j|ƒ d S )N)ÚmacrosÚload_macros)ÚselfÚversionr   r   r   Ú__init__g   s    zMacroExpander.__init__c             C   s4   x.t D ]&}t||ƒ}|r|| | jd| < P qW d S )Nz$(%s))ÚHKEYSr    r'   )r)   ZmacroÚpathr   r   r   r   r   r   Ú	set_macrok   s
    

zMacroExpander.set_macroc       
      C   sú   d| }| j d|d dƒ | j d|d dƒ d}| j d|d	ƒ y*|d
krX| j d|dƒ n| j d|dƒ W n* tk
r’ } ztdƒ‚W Y d d }~X nX d}x\tD ]T}yt||ƒ}W n tk
rÆ   wžY nX t|dƒ}t|d||f ƒ}	|	d | jd< qžW d S )Nz%Software\Microsoft\VisualStudio\%0.1fZVCInstallDirz	\Setup\VCZ
productdirZVSInstallDirz	\Setup\VSz Software\Microsoft\.NETFrameworkZFrameworkDirZinstallrootg      @ZFrameworkSDKDirzsdkinstallrootv1.1Zsdkinstallroota  Python was built with Visual Studio 2003;
extensions must be built with a compiler than can generate compatible binaries.
Visual Studio 2003 was not found on this system. If you have Cygwin installed,
you can try compiling with MingW32, by passing "-c mingw32" to setup.py.z.Software\Microsoft\NET Framework Setup\Productr   z%s\%sr*   z$(FrameworkVersion))	r.   ÚKeyErrorr   r,   r   r   r   r    r'   )
r)   r*   ZvsbaseZnetÚexcÚpr   Úhr   r   r   r   r   r(   r   s*    

zMacroExpander.load_macrosc             C   s(   x"| j jƒ D ]\}}|j||ƒ}qW |S )N)r'   ÚitemsÚreplace)r)   r%   r   Úvr   r   r   ÚsubŽ   s    zMacroExpander.subN)Ú__name__Ú
__module__Ú__qualname__r+   r.   r(   r6   r   r   r   r   r&   f   s   r&   c              C   sš   d} t jj| ƒ}|d
krdS |t| ƒ }t j|d … jddƒ\}}t|d d… ƒd }|dkrf|d7 }t|dd… ƒd }|dkr†d	}|dkr–|| S d S )NzMSC v.r   é   ú é   é   é   g      $@r   éÿÿÿÿéþÿÿÿ)Úsysr*   ÚfindÚlenÚsplitÚint)Úprefixr   r%   ÚrestZmajorVersionZminorVersionr   r   r   Úget_build_version“   s    rH   c              C   s@   d} t jj| ƒ}|dkrdS t jjd|ƒ}t j|t| ƒ |… S )Nz bit (r   ÚIntelú)r?   )rA   r*   rB   rC   )rF   r   Újr   r   r   Úget_build_architecture¬   s    rL   c             C   s4   g }x*| D ]"}t jj|ƒ}||kr
|j|ƒ q
W |S )N)Úosr-   Únormpathr   )ÚpathsZreduced_pathsr1   Znpr   r   r   Únormalize_and_reduce_paths¹   s    
rP   c            
   @   sÒ   e Zd ZdZi ZdgZdddgZdgZdgZee e e Z	dZ
d	Zd
ZdZd ZZdZd,dd„Zdd„ Zd-dd„Zd.dd„Zd/dd„Zd0dd„Zdd„ Zdd „ Zd!d"„ Zd1d#d$„Zd%d&„ Zd2d(d)„Zd*d+„ ZdS )3ÚMSVCCompilerZmsvcz.cz.ccz.cppz.cxxz.rcz.mcz.resz.objz.libz.dllz%s%sz.exer   c             C   sv   t j| |||ƒ tƒ | _tƒ | _| jdkr\| jdkrHd| _t| jƒ| _nd| _d| j | _	nd| jd  | _	d| _
d S )	NrI   é   zSoftware\Microsoft\VisualStudiozSoftware\Microsoft\DevstudiozVisual Studio version %szMicrosoft SDK compiler %sr:   F)r   r+   rH   Ú_MSVCCompiler__versionrL   Ú_MSVCCompiler__archÚ_MSVCCompiler__rootr&   Ú_MSVCCompiler__macrosÚ_MSVCCompiler__productÚinitialized)r)   ÚverboseZdry_runZforcer   r   r   r+   æ   s    

zMSVCCompiler.__init__c             C   sÄ  g | _ dtjkrDdtjkrD| jdƒrDd| _d| _d| _d| _d| _nx| j	dƒ| _ t
| j ƒd	krltd
| j ƒ‚| jdƒ| _| jdƒ| _| jdƒ| _| jdƒ| _| jdƒ| _| jdƒ | jdƒ y*x$tjd jdƒD ]}| j j|ƒ qÐW W n tk
rú   Y nX t| j ƒ| _ dj| j ƒtjd< d | _| jdk�rTddddddg| _dddddddg| _n&ddddddg| _dddddddg| _dddg| _| jdk�r¢ddddg| _ndddddg| _dg| _d | _d S )!NZDISTUTILS_USE_SDKZMSSdkzcl.exezlink.exezlib.exezrc.exezmc.exer-   r   zxPython was built with %s, and extensions need to be built with the same version of the compiler, but it isn't installed.ÚlibÚincludeú;rI   z/nologoz/Oxz/MDz/W3z/GXz/DNDEBUGz/Odz/MDdz/Z7z/D_DEBUGz/GS-z/DLLz/INCREMENTAL:NOrR   z/INCREMENTAL:noz/DEBUGz	/pdb:NoneT)Ú_MSVCCompiler__pathsrM   ÚenvironÚfind_exeÚccÚlinkerrZ   ÚrcÚmcÚget_msvc_pathsrC   r   rW   Úset_path_env_varrD   r   r/   rP   ÚjoinZpreprocess_optionsrT   Úcompile_optionsÚcompile_options_debugÚldflags_sharedrS   Úldflags_shared_debugZldflags_staticrX   )r)   r1   r   r   r   Ú
initializeø   sR    







zMSVCCompiler.initializeÚ c             C   sâ   |d krd}g }xÌ|D ]Ä}t jj|ƒ\}}t jj|ƒd }|t jj|ƒd … }|| jkrdtd| ƒ‚|rtt jj|ƒ}|| jkrš|j	t jj
||| j ƒƒ q|| jkrÀ|j	t jj
||| j ƒƒ q|j	t jj
||| j ƒƒ qW |S )Nrl   r   zDon't know how to compile %s)rM   r-   ÚsplitextÚ
splitdriveÚisabsÚsrc_extensionsr   ÚbasenameÚ_rc_extensionsr   rf   Úres_extensionÚ_mc_extensionsÚobj_extension)r)   Zsource_filenamesZ	strip_dirÚ
output_dirZ	obj_namesZsrc_namer   Úextr   r   r   Úobject_filenames8  s(     



zMSVCCompiler.object_filenamesNc	             C   st  | j s| jƒ  | j||||||ƒ}	|	\}}
}}}|p6g }|jdƒ |rT|j| jƒ n|j| jƒ �x|
D �]}y|| \}}W n tk
r”   whY nX |r¦tj	j
|ƒ}|| jkr¼d| }�nT|| jkrÒd| }�n>|| jk�r>|}d| }y"| j| jg| |g |g ƒ W qh tk
�r8 } zt|ƒ‚W Y d d }~X qhX qhnÒ|| jk�r tj	j|ƒ}tj	j|ƒ}yl| j| jgd|d|g |g ƒ tj	jtj	j|ƒƒ\}}tj	j||d ƒ}| j| jgd| g |g ƒ W qh tk
�rú } zt|ƒ‚W Y d d }~X qhX qhntd||f ƒ‚d	| }y&| j| jg| | ||g | ƒ W qh tk
�rj } zt|ƒ‚W Y d d }~X qhX qhW |
S )
Nz/cz/Tcz/Tpz/foz-hz-rz.rcz"Don't know how to compile %s to %sz/Fo)rX   rk   Z_setup_compiler   Úextendrh   rg   r/   rM   r-   ÚabspathÚ_c_extensionsÚ_cpp_extensionsrr   Úspawnrb   r   r   rt   Údirnamerc   rm   rq   rf   r`   )r)   Zsourcesrv   r'   Zinclude_dirsÚdebugÚextra_preargsÚextra_postargsZdependsZcompile_infoÚobjectsZpp_optsZbuildZcompile_optsÚobjÚsrcrw   Z	input_optZ
output_optÚmsgZh_dirZrc_dirr   Ú_Zrc_filer   r   r   ÚcompileW  sj    




zMSVCCompiler.compilec       	      C   sž   | j s| jƒ  | j||ƒ\}}| j||d�}| j||ƒrŽ|d| g }|rJy| j| jg| ƒ W qš tk
rŠ } zt|ƒ‚W Y d d }~X qšX nt	j
d|ƒ d S )N)rv   z/OUT:zskipping %s (up-to-date))rX   rk   Ú_fix_object_argsÚlibrary_filenameÚ
_need_linkr}   rZ   r   r   r
   r   )	r)   r‚   Zoutput_libnamerv   r   Útarget_langÚoutput_filenameZlib_argsr…   r   r   r   Úcreate_static_lib¬  s    zMSVCCompiler.create_static_libc             C   sÖ  | j s| jƒ  | j||ƒ\}}| j|||ƒ}|\}}}|rL| jdt|ƒ ƒ t| |||ƒ}|d k	rptjj	||ƒ}| j
||ƒ�rÆ|tjkr¬|	rœ| jdd … }q¾| jdd … }n|	r¸| j}n| j}g }x|pÊg D ]}|jd| ƒ qÌW || | | d| g }|d k	�rLtjjtjj|ƒƒ\}}tjj	tjj|d ƒ| j|ƒƒ}|jd| ƒ |
�r^|
|d d…< |�rn|j|ƒ | jtjj|ƒƒ y| j| jg| ƒ W n, tk
�rÂ } zt|ƒ‚W Y d d }~X nX ntjd|ƒ d S )Nz5I don't know what to do with 'runtime_library_dirs': r   z/EXPORT:z/OUT:r   z/IMPLIB:zskipping %s (up-to-date))rX   rk   rˆ   Z_fix_lib_argsÚwarnÚstrr	   rM   r-   rf   rŠ   r   Z
EXECUTABLErj   ri   r   rm   rq   r~   r‰   ry   Zmkpathr}   ra   r   r   r
   r   )r)   Ztarget_descr‚   rŒ   rv   Z	librariesZlibrary_dirsZruntime_library_dirsZexport_symbolsr   r€   r�   Z
build_tempr‹   Z
fixed_argsZlib_optsZldflagsZexport_optsZsymZld_argsZdll_nameZdll_extZimplib_filer…   r   r   r   ÚlinkÅ  sV    



zMSVCCompiler.linkc             C   s   d| S )Nz	/LIBPATH:r   )r)   Údirr   r   r   Úlibrary_dir_option  s    zMSVCCompiler.library_dir_optionc             C   s   t dƒ‚d S )Nz<don't know how to set runtime library search path for MSVC++)r   )r)   r‘   r   r   r   Úruntime_library_dir_option  s    z'MSVCCompiler.runtime_library_dir_optionc             C   s
   | j |ƒS )N)r‰   )r)   rZ   r   r   r   Úlibrary_option  s    zMSVCCompiler.library_optionc             C   s`   |r|d |g}n|g}xB|D ]6}x0|D ](}t jj|| j|ƒƒ}t jj|ƒr(|S q(W qW d S d S )NZ_d)rM   r-   rf   r‰   Úexists)r)   ÚdirsrZ   r   Z	try_namesr‘   r   Zlibfiler   r   r   Úfind_library_file#  s    

zMSVCCompiler.find_library_filec             C   sz   x4| j D ]*}tjjtjj|ƒ|ƒ}tjj|ƒr|S qW x>tjd jdƒD ]*}tjjtjj|ƒ|ƒ}tjj|ƒrH|S qHW |S )NZPathr\   )r]   rM   r-   rf   rz   Úisfiler^   rD   )r)   Zexer1   Úfnr   r   r   r_   5  s    	zMSVCCompiler.find_exeÚx86c             C   sÀ   t sg S |d }| jdkr,d| j| jf }nd| j|f }xHtD ]@}t||ƒ}|r@| jdkrr| jj|| ƒjdƒS || jdƒS q@W | jdkr¼x,tD ]$}t|d| j ƒd k	r”| jdƒ P q”W g S )	Nz dirsrR   z6%s\%0.1f\VC\VC_OBJECTS_PLATFORM_INFO\Win32\Directoriesz?%s\6.0\Build System\Components\Platforms\Win32 (%s)\Directoriesr\   r:   z%s\6.0z´It seems you have Visual Studio 6 installed, but the expected registry settings are not present.
You must at least run the Visual Studio GUI once so that these entries are created.)	Ú_can_read_regrS   rU   r,   r    rV   r6   rD   rŽ   )r)   r-   Úplatformr   r   r   r   r   r   rd   K  s(    






zMSVCCompiler.get_msvc_pathsc             C   s6   |dkr| j dƒ}n
| j |ƒ}|r2dj|ƒtj|< d S )NrZ   Zlibraryr\   )rd   rf   rM   r^   )r)   r   r1   r   r   r   re   o  s
    
zMSVCCompiler.set_path_env_var)r   r   r   )r   rl   )NNNr   NNN)Nr   N)
NNNNNr   NNNN)r   )rš   )r7   r8   r9   Zcompiler_typeZexecutablesr{   r|   rr   rt   rp   rs   ru   Zstatic_lib_extensionZshared_lib_extensionZstatic_lib_formatZshared_lib_formatZexe_extensionr+   rk   rx   r‡   r�   r�   r’   r“   r”   r—   r_   rd   re   r   r   r   r   rQ   È   sN   

B 
 
V  
         
F

$rQ   g       @z3Importing new compiler from distutils.msvc9compiler)rQ   )r&   )-rA   rM   Zdistutils.errorsr   r   r   r   r   Zdistutils.ccompilerr   r   r	   Z	distutilsr
   r›   ÚwinregZhkey_modZ	OpenKeyExr   ZEnumKeyr   Z	EnumValuer   Úerrorr   ÚImportErrorZwin32apiZwin32conÚinfoZ
HKEY_USERSÚHKEY_CURRENT_USERÚHKEY_LOCAL_MACHINEZHKEY_CLASSES_ROOTr,   r   r    r   r&   rH   rL   rP   rQ   r   ZOldMSVCCompilerZdistutils.msvc9compilerr   r   r   r   Ú<module>   s\   


	-   9
