Your IP : 18.191.72.220


Current Path : /opt/alt/python310/lib64/python3.10/distutils/__pycache__/
Upload File :
Current File : //opt/alt/python310/lib64/python3.10/distutils/__pycache__/msvc9compiler.cpython-310.opt-2.pyc

o

6��f�v�@sJ	ddlZddlZddlZddlZddlmZmZmZmZm	Z	ddl
mZmZddl
mZddlmZddlZejZejZejZejZejejejejfZejdkoVej dkZ!e!r`dZ"d	Z#d
Z$ndZ"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-dkr�ed e-��Gd!d"�d"e�Z.dS)$�N)�DistutilsExecError�DistutilsPlatformError�CompileError�LibError�	LinkError)�	CCompiler�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�rz	win-amd64c@sNeZdZ	dd�Zee�Zdd�Zee�Zdd�Zee�Zdd�Zee�Zd	S)
�RegcCs6tD]}|�||�}|r||vr||Sqt|���N)�HKEYS�read_values�KeyError)�cls�path�key�base�d�r�>/opt/alt/python310/lib64/python3.10/distutils/msvc9compiler.py�	get_value?s�z
Reg.get_valuecCsh	zt||�}Wn
tyYdSwg}d}	zt||�}Wn
ty)Y|Sw|�|�|d7}q�NrT�)�RegOpenKeyEx�RegError�
RegEnumKey�append)rrr�handle�L�i�krrr�	read_keysGs$��
�z
Reg.read_keysc	Cs�	zt||�}Wn
tyYdSwi}d}	z
t||�\}}}Wn
ty,Y|Sw|��}|�|�||�|�<|d7}qr)rr�RegEnumValue�lower�convert_mbcs)	rrrr!rr#�name�value�typerrrrYs&���zReg.read_valuescCs<t|dd�}|durz|d�}W|StyY|Sw|S)N�decode�mbcs)�getattr�UnicodeError)�sZdecrrrr(os
��zReg.convert_mbcsN)	�__name__�
__module__�__qualname__r�classmethodr%rr(�staticmethodrrrrr;src@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))rrr7)r;Zmacrorrrrr�	set_macro�szMacroExpander.set_macroc	Cs�|�d|jdd�|�d|jdd�|�dtd�z|dkr(|�d	td
�ntd
��Wnty8td��w|dkrN|�d
|jd�|�dtd�dSd}tD])}zt||�}Wn	tydYqRwt	|d�}t
�|d||f�}|d|jd<qRdS)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>r9�NET_BASErr�WINSDK_BASErrrrrrr7)r;r<�pr�hrrrrrr:�s:�����
�zMacroExpander.load_macroscCs$|j��D]
\}}|�||�}q|Sr)r7�items�replace)r;r0r$�vrrr�sub�szMacroExpander.subN)r1r2r3r=r>r:rHrrrrr6ys
r6cCs�	d}tj�|�}|dkrdS|t|�}tj|d��dd�\}}t|dd��d}|dkr4|d7}t|dd	��d
}|dkrDd}|dkrL||SdS)NzMSC v.����� r����
��g$@r)�sysr<�find�len�split�int)�prefixr#r0�restZmajorVersionZminorVersionrrr�get_build_version�s rWcCs2	g}|D]}tj�|�}||vr|�|�q|Sr)�osr�normpathr )�pathsZ
reduced_pathsrCZnprrr�normalize_and_reduce_paths�s
�r[cCs>	|�tj�}g}|D]}||vr|�|�qtj�|�}|Sr)rSrX�pathsepr �join)ZvariableZoldListZnewListr#ZnewVariablerrr�removeDuplicates�s
�r^cCs	t|}z
t�d|d�}Wntyt�d�d}Ynw|r(tj�|�scd|}tj	�
|d�}|r\tj�|�r\tj�|tjtjd�}tj�
|�}tj�|�s[t�d|�dSnt�d|�|slt�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)r8rrrr	�debugrXr�isdir�environ�getr]�pardir�abspath�isfile)r<r9r?ZtoolskeyZtoolsdir�	vcvarsallrrr�find_vcvarsall�s:
�
��

rhcCsH	t|�}hd�}i}|durtd��t�d||�tjd||ftjtjd�}z\|��\}}|��dkr<t|�	d���|�	d�}|�
d�D]2}t�|�}d	|vrRqF|�
�}|�
d	d
�\}	}
|	��}	|	|vrx|
�tj�rr|
dd�}
t|
�||	<qFW|j��|j��n|j��|j��wt|�t|�kr�ttt|������|S)N>Zlibpath�includer�libr_z'Calling 'vcvarsall.bat %s' (version=%s)z
"%s" %s & set)�stdout�stderrrr-�
�=rrI)rhrr	r`�
subprocess�Popen�PIPEZcommunicate�waitr,rSrr(�stripr'�endswithrXr\r^rk�closerlrR�
ValueError�str�list�keys)r<ZarchrgZinteresting�result�popenrkrl�linerr*rrr�query_vcvarsall�sH�

��


�r}r@z(VC %0.1f is not supported by this modulec@s�eZdZ	dZiZdgZgd�ZdgZdgZeeeeZ	dZ
dZdZd	Z
d
ZZdZd+d
d�Zd,dd�Z		d-dd�Z		d.dd�Z			d/dd�Z										d0dd�Zdd�Zdd�Zdd �Zd!d"�Zd#d$�Zd%d&�Zd1d'd(�Zd)d*�ZdS)2�MSVCCompilerZmsvcz.c)z.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=Hs
zMSVCCompiler.__init__NcCs�|durt�}d}||vrtd|f��dtjvr3dtjvr3|�d�r3d|_d|_d|_d|_d	|_	na|t�ks<|d
krAt
|}nt
t�dt
|}tt|�}|d�
tj�|_|d
tjd
<|dtjd<t|j�dkrvtd|j��|�d�|_|�d�|_|�d�|_|�d�|_|�d	�|_	ztjd�
d�D]}|j�|�q�Wn	ty�Ynwt|j�|_d�|j�tjd<d|_|jdkr�gd�|_gd�|_n
gd�|_gd�|_gd�|_|jdkr�gd�|_dg|_d|_dS)Nr
z--plat-name must be one of %sZDISTUTILS_USE_SDKZMSSdkzcl.exezlink.exezlib.exezrc.exezmc.exer�_rrjrirzxPython was built with %s, and extensions need to be built with the same version of the compiler, but it isn't installed.�;r)�/nologo�/Ox�/MD�/W3�/DNDEBUG)r��/Od�/MDdr��/Z7�/D_DEBUG)r�r�r�r��/GS-r�)r�r�r�r�r�r�r�)�/DLLr�z/INCREMENTAL:NO�)r�r�z/INCREMENTAL:noz/DEBUGr�T)r
rrXrb�find_exe�cc�linkerrj�rc�mc�PLAT_TO_VCVARSr}r�rSr\r�rRZ_MSVCCompiler__productr rr[r]Zpreprocess_optionsr��compile_options�compile_options_debug�ldflags_sharedr��ldflags_shared_debugZldflags_staticr�)r;r�Zok_platsZ	plat_specZvc_envrCrrr�
initializeSsf�
�
���







zMSVCCompiler.initialize�cCs�|durd}g}|D]b}tj�|�\}}tj�|�d}|tj�|�d�}||jvr1td|��|r9tj�|�}||jvrL|�	tj�
|||j��q
||jvr_|�	tj�
|||j��q
|�	tj�
|||j
��q
|S)Nr�rzDon't know how to compile %s)rXr�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	Cs8|js|��|�||||||�}	|	\}}
}}}|pg}
|
�d�|r*|
�|j�n|
�|j�|
D]�}z||\}}Wn	tyEYq2w|rNtj	�
|�}||jvrXd|}n�||jvrbd|}n�||j
vr�|}d|}z|�|jg||g|g�Wnty�}zt|��d}~wwq2||jvr�tj	�|�}tj	�|�}z6|�|jgd|d|g|g�tj	�tj	�|��\}}tj	�||d�}|�|jgd|g|g�Wnty�}zt|��d}~wwq2td||f��d	|}z|�|jg|
|||g|�Wq2t�y}zt|��d}~ww|
S)
Nz/cz/Tcz/Tpz/foz-hz-rrz"Don't know how to compile %s to %sz/Fo)r�r�Z_setup_compiler �extendr�r�rrXrre�
_c_extensions�_cpp_extensionsr��spawnr�rrr��dirnamer�r�r�r]r�)r;Zsourcesr�r7Zinclude_dirsr`�
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�}|�||�rC|d|g}|r&	z|�|jg|�WdStyB}zt|��d}~wwt	�
d|�dS)N)r��/OUT:�skipping %s (up-to-date))r�r��_fix_object_args�library_filename�
_need_linkr�rjrrr	r`)	r;r�Zoutput_libnamer�r`�target_lang�output_filenameZlib_argsr�rrr�create_static_libs"���zMSVCCompiler.create_static_libc
Cs<|js|��|�||�\}}|�|||�}|\}}}|r&|�dt|��t||||�}|dur8tj�	||�}|�
||��r|tjkrV|	rN|j
dd�}n|jdd�}n	|	r\|j
}n|j}g}|pdgD]	}|�d|�qe||||d|g}tj�|d�}|dur�tj�tj�|��\}}tj�	||�|��}|�d|�|�|||�|
r�|
|dd�<|r�|�|�|�tj�|��z|�|jg|�Wnty�}zt|��d}~ww|�||�}|du�r|\}}d||f}z
|�dd	d
||g�WdSt�y}zt|��d}~wwdSt�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�warnrwrrXrr]r�r�
EXECUTABLEr�r�r r�r�r�r��manifest_setup_ldargsr�Zmkpathr�r�rr�manifest_get_embed_infor	r`)r;�target_descr�r�r�Z	librariesZlibrary_dirsZruntime_library_dirsZexport_symbolsr`r�r��
build_tempr�Z
fixed_argsZlib_optsZldflagsZexport_optsZsym�ld_argsZdll_nameZdll_extZimplib_filer�ZmfinfoZ
mffilename�mfidZout_argrrr�link5s��
��

��
��
��

����	zMSVCCompiler.linkcCs,tj�|tj�|�d�}|�d|�dS)Nz	.manifest�/MANIFESTFILE:)rXrr]r�r )r;r�r�r��
temp_manifestrrrr��s
�z"MSVCCompiler.manifest_setup_ldargscCs^|D]}|�d�r|�dd�d}nqdS|tjkrd}nd}|�|�}|dur+dS||fS)Nr��:rrN)�
startswithrSrr��_remove_visual_c_ref)r;r�r��argr�r�rrrr��s
�

z$MSVCCompiler.manifest_get_embed_infocCs�zUt|�}z
|��}W|��n|��wt�dtj�}t�|d|�}d}t�|d|�}t�dtj�}t�||�dur>WdSt|d�}z
|�|�|W|��WS|��wt	y_YdSw)NzU<assemblyIdentity.*?name=("|')Microsoft\.VC\d{2}\.CRT("|').*?(/>|</assemblyIdentity>)r�z*<dependentAssembly>\s*</dependentAssembly>zI<assemblyIdentity.*?name=(?:"|')(.+?)(?:"|').*?(?:/>|</assemblyIdentity>)�w)
�open�readru�rer��DOTALLrH�search�write�OSError)r;Z
manifest_fileZ
manifest_fZmanifest_buf�patternrrrr��s4	
��

�z!MSVCCompiler._remove_visual_c_refcCsd|S)Nz	/LIBPATH:r�r;�dirrrr�library_dir_option�szMSVCCompiler.library_dir_optioncCstd��)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;rjrrr�library_option�s
zMSVCCompiler.library_optioncCs\|r	|d|g}n|g}|D]}|D]}tj�||�|��}tj�|�r*|SqqdS)NZ_d)rXrr]r��exists)r;�dirsrjr`Z	try_namesr�r)Zlibfilerrr�find_library_file�s��zMSVCCompiler.find_library_filecCs|	|jD]}tj�tj�|�|�}tj�|�r|Sqtjd�d�D]}tj�tj�|�|�}tj�|�r;|Sq$|S)NZPathr�)r�rXrr]rerfrbrS)r;ZexerC�fnrrrr�s
��zMSVCCompiler.find_exe)rrrr)rr�)NNNrNNN)NrN)
NNNNNrNNNN)r)r1r2r3Z
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~*sd��

W
� 
�X
�
�_+
r~)r)/rXrorPr�Zdistutils.errorsrrrrrZdistutils.ccompilerrrZ	distutilsr	Zdistutils.utilr
�winregZ	OpenKeyExrZEnumKeyrZ	EnumValuer&�errorrZ
HKEY_USERS�HKEY_CURRENT_USER�HKEY_LOCAL_MACHINEZHKEY_CLASSES_ROOTr�platform�maxsizeZNATIVE_WIN64r8rBrAr�rr6rWr[r^rhr}r�r~rrrr�<module>sR��>.
#)

?>