Your IP : 3.142.36.215


Current Path : /lib64/python3.8/distutils/__pycache__/
Upload File :
Current File : //lib64/python3.8/distutils/__pycache__/msvc9compiler.cpython-38.opt-2.pyc

U

e5d/w�@sNddlZddlZddlZddlZddlmZmZmZmZm	Z	ddl
mZmZm
Z
ddlmZddlmZddlZejZejZejZejZejejejejfZej dko�ej!dkZ"e"r�dZ#d	Z$d
Z%ndZ#dZ$d
Z%ddd�Z&Gdd�d�Z'Gdd�d�Z(dd�Z)dd�Z*dd�Z+dd�Z,d#dd�Z-e)�Z.e.dk�r:ed e.��Gd!d"�d"e�Z/dS)$�N)�DistutilsExecError�DistutilsPlatformError�CompileError�LibError�	LinkError)�	CCompiler�gen_preprocess_options�gen_lib_options)�log)�get_platform�win32lz1Software\Wow6432Node\Microsoft\VisualStudio\%0.1fz5Software\Wow6432Node\Microsoft\Microsoft SDKs\Windowsz,Software\Wow6432Node\Microsoft\.NETFrameworkz%Software\Microsoft\VisualStudio\%0.1fz)Software\Microsoft\Microsoft SDKs\Windowsz Software\Microsoft\.NETFramework�x86Zamd64�rz	win-amd64c@sLeZdZdd�Zee�Zdd�Zee�Zdd�Zee�Zdd�Zee�Zd	S)
�RegcCs:tD](}|�||�}|r||kr||Sqt|��dS�N)�HKEYS�read_values�KeyError)�cls�path�key�base�d�r�//usr/lib64/python3.8/distutils/msvc9compiler.py�	get_value@s
z
Reg.get_valuecCsnzt||�}Wntk
r$YdSXg}d}zt||�}Wntk
rTYqjYnX|�|�|d7}q.|S�Nr�)�RegOpenKeyEx�RegError�
RegEnumKey�append)rrr�handle�L�i�krrr�	read_keysHs


z
Reg.read_keysc	Cs�zt||�}Wntk
r$YdSXi}d}zt||�\}}}Wntk
rZYq�YnX|��}|�|�||�|�<|d7}q.|Sr)rr�RegEnumValue�lower�convert_mbcs)	rrrr"rr$�name�value�typerrrrZs

zReg.read_valuescCs:t|dd�}|dk	r6z|d�}Wntk
r4YnX|S)N�decode�mbcs)�getattr�UnicodeError)�sZdecrrrr)pszReg.convert_mbcsN)	�__name__�
__module__�__qualname__r�classmethodr&rr)�staticmethodrrrrr<src@s,eZdZdd�Zdd�Zdd�Zdd�Zd	S)
�
MacroExpandercCsi|_t||_|�|�dSr)�macros�VS_BASE�vsbase�load_macros)�self�versionrrr�__init__|s
zMacroExpander.__init__cCst�||�|jd|<dS)Nz$(%s))rrr8)r<Zmacrorrrrr�	set_macro�szMacroExpander.set_macroc	Cs|�d|jdd�|�d|jdd�|�dtd�z$|dkrP|�d	td
�ntd
��Wntk
rvtd��YnX|dkr�|�d
|jd�|�dtd�nbd}tD]X}zt||�}Wntk
r�Yq�YnXt	|d�}t
�|d||f�}|d|jd<q�dS)NZVCInstallDirz	\Setup\VC�
productdirZVSInstallDirz	\Setup\VSZFrameworkDirZinstallroot� @ZFrameworkSDKDirzsdkinstallrootv2.0aPython was built with Visual Studio 2008;
extensions must be built with a compiler than can generate compatible binaries.
Visual Studio 2008 was not found on this system. If you have Cygwin installed,
you can try compiling with MingW32, by passing "-c mingw32" to setup.py.g"@ZFrameworkVersionzclr versionZ
WindowsSdkDirZcurrentinstallfolderz.Software\Microsoft\NET Framework Setup\Productrz%s\%sr=z$(FrameworkVersion))
r?r:�NET_BASErr�WINSDK_BASErrrr rrr8)r<r=�pr�hrrrrrr;�s2��


zMacroExpander.load_macroscCs$|j��D]\}}|�||�}q
|Sr)r8�items�replace)r<r1r%�vrrr�sub�szMacroExpander.subN)r2r3r4r>r?r;rIrrrrr7zsr7cCs�d}tj�|�}|dkrdS|t|�}tj|d��dd�\}}t|dd��d}|dkrf|d7}t|dd	��d
}|dkr�d}|dkr�||SdS)NzMSC v.����� r����
��g$@r)�sysr=�find�len�split�int)�prefixr$r1�restZmajorVersionZminorVersionrrr�get_build_version�srXcCs0g}|D]"}tj�|�}||kr|�|�q|Sr)�osr�normpathr!)�pathsZ
reduced_pathsrDZnprrr�normalize_and_reduce_paths�sr\cCs<|�tj�}g}|D]}||kr|�|�qtj�|�}|Sr)rTrY�pathsepr!�join)ZvariableZoldListZnewListr$ZnewVariablerrr�removeDuplicates�sr_cCst|}zt�d|d�}Wn"tk
r>t�d�d}YnX|rPtj�|�s�d|}tj	�
|d�}|r�tj�|�r�tj�|tjtjd�}tj�
|�}tj�|�s�t�d|�dSnt�d|�|s�t�d�dStj�|d	�}tj�|�r�|St�d
�dS)Nz%s\Setup\VCr@z%Unable to find productdir in registryzVS%0.f0COMNTOOLSZVCz%s is not a valid directoryz Env var %s is not set or invalidzNo productdir foundz
vcvarsall.bat�Unable to find vcvarsall.bat)r9rrrr
�debugrYr�isdir�environ�getr^�pardir�abspath�isfile)r=r:r@ZtoolskeyZtoolsdir�	vcvarsallrrr�find_vcvarsall�s4
�



ricCs8t|�}ddddh}i}|dkr(td��t�d||�tjd||ftjtjd�}z�|�
�\}}|��d	krzt|�d
���|�d
�}|�
d�D]d}t�|�}d|kr�q�|��}|�
dd
�\}	}
|	��}	|	|kr�|
�tj�r�|
dd�}
t|
�||	<q�W5|j��|j	��Xt|�t|�k�r4ttt|������|S)N�include�libZlibpathrr`z'Calling 'vcvarsall.bat %s' (version=%s)z
"%s" %s & set)�stdout�stderrrr.�
�=rrJ)rirr
ra�
subprocess�Popen�PIPErl�closermZcommunicate�waitr-rTrr)�stripr(�endswithrYr]r_rS�
ValueError�str�list�keys)r=ZarchrhZinteresting�result�popenrlrm�linerr+rrr�query_vcvarsall�s>�


r~rAz(VC %0.1f is not supported by this modulec
@s�eZdZdZiZdgZdddgZdgZdgZeeeeZ	dZ
d	Zd
ZdZ
dZZd
Zd-dd�Zd.dd�Zd/dd�Zd0dd�Zd1dd�Zd2dd�Zdd�Zdd �Zd!d"�Zd#d$�Zd%d&�Zd'd(�Zd3d)d*�Zd+d,�ZdS)4�MSVCCompilerZmsvcz.cz.ccz.cppz.cxx�.rcz.mcz.resz.objz.libz.dllz%s%sz.exercCs8t�||||�t|_d|_g|_d|_d|_d|_dS)NzSoftware\Microsoft\VisualStudioF)	rr>�VERSION�_MSVCCompiler__versionZ_MSVCCompiler__root�_MSVCCompiler__paths�	plat_name�_MSVCCompiler__arch�initialized)r<�verboseZdry_runZforcerrrr>IszMSVCCompiler.__init__NcCs|dkrt�}d}||kr(td|f��dtjkrfdtjkrf|�d�rfd|_d|_d|_d|_d	|_	n�|t�ksx|d
kr�t
|}nt
t�dt
|}tt|�}|d�
tj�|_|d
tjd
<|dtjd<t|j�dkr�td|j��|�d�|_|�d�|_|�d�|_|�d�|_|�d	�|_	z(tjd�
d�D]}|j�|��q:Wntk
�rfYnXt|j�|_d�|j�tjd<d|_|jdk�r�dddddg|_ddddddg|_n&ddddddg|_dddddddg|_dddg|_|jdk�rddd d!g|_dg|_d"|_dS)#Nrz--plat-name must be one of %sZDISTUTILS_USE_SDKZMSSdkzcl.exezlink.exezlib.exezrc.exezmc.exer�_rrkrjrzxPython was built with %s, and extensions need to be built with the same version of the compiler, but it isn't installed.�;r
z/nologoz/Oxz/MDz/W3z/DNDEBUGz/Odz/MDdz/Z7z/D_DEBUGz/GS-z/DLLz/INCREMENTAL:NO�z/INCREMENTAL:noz/DEBUGT)rrrYrc�find_exe�cc�linkerrk�rc�mc�PLAT_TO_VCVARSr~r�rTr]r�rSZ_MSVCCompiler__productr!rr\r^Zpreprocess_optionsr��compile_options�compile_options_debug�ldflags_sharedr��ldflags_shared_debugZldflags_staticr�)r<r�Zok_platsZ	plat_specZvc_envrDrrr�
initializeTs~�
�
���
�
��zMSVCCompiler.initialize�cCs�|dkrd}g}|D]�}tj�|�\}}tj�|�d}|tj�|�d�}||jkrbtd|��|rrtj�|�}||jkr�|�	tj�
|||j��q||jkr�|�	tj�
|||j��q|�	tj�
|||j
��q|S)Nr�rzDon't know how to compile %s)rYr�splitext�
splitdrive�isabs�src_extensionsr�basename�_rc_extensionsr!r^�
res_extension�_mc_extensions�
obj_extension)r<Zsource_filenamesZ	strip_dir�
output_dirZ	obj_namesZsrc_namer�extrrr�object_filenames�s.

�
��zMSVCCompiler.object_filenamesc	Csp|js|��|�||||||�}	|	\}}
}}}|p6g}
|
�d�|rT|
�|j�n|
�|j�|
D�]}z||\}}Wntk
r�YqdYnX|r�tj	�
|�}||jkr�d|}�nT||jkr�d|}�n>||j
k�r<|}d|}z"|�|jg||g|g�Wqdtk
�r6}zt|��W5d}~XYqdXqdn�||jk�r�tj	�|�}tj	�|�}zl|�|jgd|d|g|g�tj	�tj	�|��\}}tj	�||d�}|�|jgd|g|g�Wqdtk
�r�}zt|��W5d}~XYqdXqdntd||f��d	|}z&|�|jg|
|||g|�Wqdtk
�rh}zt|��W5d}~XYqdXqd|
S)
Nz/cz/Tcz/Tpz/foz-hz-rr�z"Don't know how to compile %s to %sz/Fo)r�r�Z_setup_compiler!�extendr�r�rrYrrf�
_c_extensions�_cpp_extensionsr��spawnr�rrr��dirnamer�r�r�r^r�)r<Zsourcesr�r8Zinclude_dirsra�
extra_preargs�extra_postargsZdependsZcompile_info�objectsZpp_optsZbuildZcompile_opts�obj�srcr�Z	input_optZ
output_opt�msgZh_dirZrc_dirrr�Zrc_filerrr�compile�s�
�




��


��
��
���
zMSVCCompiler.compilec	
Cs�|js|��|�||�\}}|j||d�}|�||�r�|d|g}|rJz|�|jg|�Wq�tk
r�}zt|��W5d}~XYq�Xnt	�
d|�dS)N)r��/OUT:�skipping %s (up-to-date))r�r��_fix_object_args�library_filename�
_need_linkr�rkrrr
ra)	r<r�Zoutput_libnamer�ra�target_lang�output_filenameZlib_argsr�rrr�create_static_libs�zMSVCCompiler.create_static_libc
CsT|js|��|�||�\}}|�|||�}|\}}}|rL|�dt|��t||||�}|dk	rptj�	||�}|�
||��rD|tjkr�|	r�|j
dd�}q�|jdd�}n|	r�|j
}n|j}g}|p�gD]}|�d|�q�||||d|g}tj�|d�}|dk	�rLtj�tj�|��\}}tj�	||�|��}|�d|�|�|||�|
�rl|
|dd�<|�r||�|�|�tj�|��z|�|jg|�Wn,tk
�r�}zt|��W5d}~XYnX|�||�}|dk	�rP|\}}d||f}z|�dd	d
||g�Wn,tk
�r@}zt|��W5d}~XYnXnt�d|�dS)Nz5I don't know what to do with 'runtime_library_dirs': rz/EXPORT:r�rz/IMPLIB:z-outputresource:%s;%szmt.exez-nologoz	-manifestr�)r�r�r�Z
_fix_lib_args�warnrxr	rYrr^r�r�
EXECUTABLEr�r�r!r�r�r�r��manifest_setup_ldargsr�Zmkpathr�r�rr�manifest_get_embed_infor
ra)r<�target_descr�r�r�Z	librariesZlibrary_dirsZruntime_library_dirsZexport_symbolsrar�r��
build_tempr�Z
fixed_argsZlib_optsZldflagsZexport_optsZsym�ld_argsZdll_nameZdll_extZimplib_filer�ZmfinfoZ
mffilename�mfidZout_argrrr�link6s��
��

��

��


�
zMSVCCompiler.linkcCs,tj�|tj�|�d�}|�d|�dS)Nz	.manifest�/MANIFESTFILE:)rYrr^r�r!)r<r�r�r��
temp_manifestrrrr��s
�z"MSVCCompiler.manifest_setup_ldargscCs^|D]"}|�d�r|�dd�d}q,qdS|tjkr<d}nd}|�|�}|dkrVdS||fS)Nr��:rrO)�
startswithrTrr��_remove_visual_c_ref)r<r�r��argr�r�rrrr��s


z$MSVCCompiler.manifest_get_embed_infocCs�z�t|�}z|��}W5|��Xt�dtj�}t�|d|�}d}t�|d|�}t�dtj�}t�||�dkrtWdSt|d�}z|�|�|W�WS|��XWnt	k
r�YnXdS)NzU<assemblyIdentity.*?name=("|')Microsoft\.VC\d{2}\.CRT("|').*?(/>|</assemblyIdentity>)r�z*<dependentAssembly>\s*</dependentAssembly>zI<assemblyIdentity.*?name=(?:"|')(.+?)(?:"|').*?(?:/>|</assemblyIdentity>)�w)
�openrs�read�rer��DOTALLrI�search�write�OSError)r<Z
manifest_fileZ
manifest_fZmanifest_buf�patternrrrr��s2	
��


z!MSVCCompiler._remove_visual_c_refcCsd|S)Nz	/LIBPATH:r�r<�dirrrr�library_dir_option�szMSVCCompiler.library_dir_optioncCstd��dS)Nz<don't know how to set runtime library search path for MSVC++)rr�rrr�runtime_library_dir_option�s�z'MSVCCompiler.runtime_library_dir_optioncCs
|�|�Sr)r�)r<rkrrr�library_option�szMSVCCompiler.library_optioncCs\|r|d|g}n|g}|D]:}|D]0}tj�||�|��}tj�|�r$|Sq$qdS)NZ_d)rYrr^r��exists)r<�dirsrkraZ	try_namesr�r*Zlibfilerrr�find_library_file�szMSVCCompiler.find_library_filecCsz|jD].}tj�tj�|�|�}tj�|�r|Sqtjd�d�D].}tj�tj�|�|�}tj�|�rF|SqF|S)N�Pathr�)r�rYrr^rfrgrcrT)r<ZexerD�fnrrrr�s	


zMSVCCompiler.find_exe)rrr)N)rr�)NNNrNNN)NrN)
NNNNNrNNNN)r)r2r3r4Z
compiler_typeZexecutablesr�r�r�r�r�r�r�Zstatic_lib_extensionZshared_lib_extensionZstatic_lib_formatZshared_lib_formatZ
exe_extensionr>r�r�r�r�r�r�r�r�r�r�r�r�r�rrrrr+sj
��

W�
 �
X�
�
_+
r)r
)0rYrprQr�Zdistutils.errorsrrrrrZdistutils.ccompilerrrr	Z	distutilsr
Zdistutils.utilr�winregZ	OpenKeyExrZEnumKeyr Z	EnumValuer'�errorrZ
HKEY_USERS�HKEY_CURRENT_USER�HKEY_LOCAL_MACHINEZHKEY_CLASSES_ROOTr�platform�maxsizeZNATIVE_WIN64r9rCrBr�rr7rXr\r_rir~r�rrrrr�<module>sN��>.#
)


?>