Your IP : 3.16.130.96


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

U

e5dRN�@s�dZddlZddlZddlZddlZddlZddlmZmZm	Z	m
Z
mZddlm
Z
mZddlmZddlmZddlmZdd	�Zd
d�Zdd
ddd�Zdd�Zdd�Zddd�Zddddd�ZGdd�de
�ZdS)adistutils._msvccompiler

Contains MSVCCompiler, an implementation of the abstract CCompiler class
for Microsoft Visual Studio 2015.

The module is compatible with VS 2015 and later. You can find legacy support
for older versions in distutils.msvc9compiler and distutils.msvccompiler.
�N)�DistutilsExecError�DistutilsPlatformError�CompileError�LibError�	LinkError)�	CCompiler�gen_lib_options)�log)�get_platform)�countcCsztjtjdtjtjBd�}Wn tk
r>t�d�YdSXd}d}|��t�D]�}zt�	||�\}}}Wntk
r�Yq�YnX|rT|tj
krTtj�
|�rTztt|��}Wnttfk
r�YqTYnX|dkrT||krT||}}qTW5QRX||fS)Nz'Software\Microsoft\VisualStudio\SxS\VC7)�accesszVisual C++ is not registered�NNr�)�winregZ	OpenKeyEx�HKEY_LOCAL_MACHINEZKEY_READZKEY_WOW64_32KEY�OSErrorr	�debugrZ	EnumValueZREG_SZ�os�path�isdir�int�float�
ValueError�	TypeError)�key�best_version�best_dir�i�vZvc_dirZvt�version�r �//usr/lib64/python3.8/distutils/_msvccompiler.py�_find_vc2015s2
�



r"c
Cs�ddl}tj�d�ptj�d�}|s(dSz8tjtj�|ddd�d	d
ddd
dddg	ddd���}Wntj	t
tfk
r~YdSXtj�|ddd�}tj�|�r�d|fSdS)aJReturns "15, path" based on the result of invoking vswhere.exe
    If no install is found, returns "None, None"

    The version is returned to avoid unnecessarily changing the function
    result. It may be ignored when the path is not None.

    If vswhere.exe is not available, by definition, VS 2017 is not
    installed.
    rNzProgramFiles(x86)ZProgramFilesr
zMicrosoft Visual StudioZ	Installerzvswhere.exez-latestz-prereleasez	-requiresz1Microsoft.VisualStudio.Component.VC.Tools.x86.x64z	-propertyZinstallationPathz	-products�*�mbcs�strict)�encoding�errorsZVCZ	AuxiliaryZBuild�)
�jsonr�environ�get�
subprocess�check_outputr�join�strip�CalledProcessErrorr�UnicodeDecodeErrorr)r)�rootrr r r!�_find_vc2017:s2
��r3�x86Zx64ZarmZarm64)r4�	x86_amd64�x86_arm�	x86_arm64cCs\t�\}}|st�\}}|s*t�d�dStj�|d�}tj�|�sTt�d|�dS|dfS)Nz$No suitable Visual C++ version foundr
z
vcvarsall.batz%s cannot be found)r3r"r	rrrr.�isfile)�	plat_spec�_rr�	vcvarsallr r r!�_find_vcvarsallcs


r<c
Cs�t�d�rdd�tj��D�St|�\}}|s6td��z&tjd�||�tj	d�j
ddd	�}Wn@tjk
r�}z t�
|j�td
�|j���W5d}~XYnXdd�dd
�|��D�D�}|S)NZDISTUTILS_USE_SDKcSsi|]\}}|��|�qSr ��lower)�.0r�valuer r r!�
<dictcomp>ws�z_get_vc_env.<locals>.<dictcomp>zUnable to find vcvarsall.batzcmd /u /c "{}" {} && set)�stderrzutf-16le�replace)r'zError executing {}cSs$i|]\}}}|r|r|��|�qSr r=)r?rr:r@r r r!rA�s
�css|]}|�d�VqdS)�=N)�	partition)r?�liner r r!�	<genexpr>�sz_get_vc_env.<locals>.<genexpr>)r�getenvr*�itemsr<rr,r-�formatZSTDOUT�decoder0r	�error�output�cmd�
splitlines)r9r;r:�out�exc�envr r r!�_get_vc_envus0
�
��
��rScCsN|st�d��tj�}|D].}tj�tj�|�|�}tj�|�r|Sq|S)atReturn path to an MSVC executable program.

    Tries to find the program in several places: first, one of the
    MSVC program search paths from the registry; next, the directories
    in the PATH environment variable.  If any of those work, return an
    absolute path that is known to exist.  If none of them work, just
    return the original program name, 'exe'.
    r)rrH�split�pathseprr.�abspathr8)Zexe�paths�p�fnr r r!�	_find_exe�s	
rZr5r6r7)Zwin32z	win-amd64z	win-arm32z	win-arm64c
s�eZdZdZdZiZdgZdddgZdgZdgZ	eeee	Z
d	Zd
ZdZ
dZd
ZZdZd(dd�Zd)dd�Zd*dd�Zd+dd�Zd,dd�Zd-dd�Z�fdd�Zd d!�Zd"d#�Zd$d%�Zd.d&d'�Z�ZS)/�MSVCCompilerzwConcrete class that implements an interface to Microsoft Visual C++,
       as defined by the CCompiler abstract class.Zmsvcz.cz.ccz.cppz.cxx�.rcz.mcz.resz.objz.libz.dllz%s%sz.exercCs t�||||�d|_d|_dS)NF)r�__init__�	plat_name�initialized)�self�verboseZdry_runZforcer r r!r]�szMSVCCompiler.__init__NcCs
|jrtd��|dkrt�}|tkr6td�tt����t|}t|�}|sRtd��|�dd�|_	|j	�
tj�}t
d|�|_t
d|�|_t
d|�|_t
d	|�|_t
d
|�|_t
d|�|_|�dd��
tj�D]}|r�|�|�tj��q�|�d
d��
tj�D]}|r�|�|�tj��q�d|_ddddddg|_ddddddg|_dddg}ddddg}|d!�|_|d"�|_|d#�|_|d$�|_|�|_|�|_ t!j"df|jt!j"df|jt!j"d f|jt!j#df|jt!j#df|jt!j#d f|jt!j$df|jt!j$df|jt!j$d f|j i	|_%d |_dS)%Nzdon't init multiple timesz--plat-name must be one of {}z7Unable to find a compatible Visual Studio installation.r�zcl.exezlink.exezlib.exezrc.exezmc.exezmt.exeZinclude�libz/nologoz/Oxz/W3z/GLz/DNDEBUGz/MDz/Odz/MDdz/Ziz/D_DEBUGz/INCREMENTAL:NOz/LTCGz/DEBUG:FULL�/MANIFEST:EMBED,ID=1�/DLL�/MANIFEST:EMBED,ID=2�/MANIFESTUAC:NOFT)rd)rd)rerfrg)rerfrg)&r_�AssertionErrorr
�PLAT_TO_VCVARSrrJ�tuplerSr+�_pathsrTrrUrZ�cc�linkerrc�rc�mcZmtZadd_include_dir�rstrip�sepZadd_library_dirZpreprocess_options�compile_options�compile_options_debugZldflags_exeZldflags_exe_debugZldflags_sharedZldflags_shared_debugZldflags_staticZldflags_static_debugrZ
EXECUTABLEZ
SHARED_OBJECTZSHARED_LIBRARY�_ldflags)r`r^r9Zvc_envrW�dir�ldflagsZ
ldflags_debugr r r!�
initialize�s������



�zMSVCCompiler.initializerbcsT�fdd��jD��fdd��j�jD����p4d����fdd�}tt||��S)Ncsi|]}|�j�qSr )�
obj_extension�r?�ext�r`r r!rA&sz1MSVCCompiler.object_filenames.<locals>.<dictcomp>csi|]}|�j�qSr )�
res_extensionryr{r r!rA'srbcs�tj�|�\}}�r"tj�|�}n2tj�|�\}}|�tjjtjjf�rT|dd�}ztj��|�|�WSt	k
r�t
d�|���YnXdS)N�zDon't know how to compile {})rr�splitext�basename�
splitdrive�
startswithrq�altsepr.�LookupErrorrrJ)rX�baserzr:)�ext_map�
output_dir�	strip_dirr r!�
make_out_path,sz4MSVCCompiler.object_filenames.<locals>.make_out_path)�src_extensions�_rc_extensions�_mc_extensions�list�map)r`Zsource_filenamesr�r�r�r )r�r�r`r�r!�object_filenames!s�zMSVCCompiler.object_filenamesc	Cs�|js|��|�||||||�}	|	\}}
}}}|p6g}
|
�d�|rT|
�|j�n|
�|j�d}|
D�]}z||\}}Wntk
r�YqhYnX|r�tj	�
|�}||jkr�d|}�nD||jkr�d|}d}�n*||j
k�r@|}d|}z|�|jg|||g�Wqhtk
�r:}zt|��W5d}~XYqhXqhn�||jk�r�tj	�|�}tj	�|�}z\|�|jd|d||g�tj	�tj	�|��\}}tj	�||d	�}|�|jd||g�Wqhtk
�r�}zt|��W5d}~XYqhXqhntd
�||���|jg|
|}|�r"|�d�|�|�|�d|�|�|�z|�|�Wqhtk
�r~}zt|��W5d}~XYqhXqh|
S)
Nz/cFz/Tcz/TpTz/foz-hz-rr\z"Don't know how to compile {} to {}z/EHscz/Fo)r_rwZ_setup_compile�append�extendrsrr�KeyErrorrrrV�
_c_extensions�_cpp_extensionsr��spawnrnrrr��dirnameror~rr.rJrl)r`Zsourcesr�ZmacrosZinclude_dirsr�
extra_preargs�extra_postargsZdependsZcompile_info�objectsZpp_optsZbuildZcompile_optsZadd_cpp_opts�obj�srcrzZ	input_optZ
output_opt�msgZh_dirZrc_dirr�r:Zrc_file�argsr r r!�compileBsx
�




�


zMSVCCompiler.compilec	
Cs�|js|��|�||�\}}|j||d�}|�||�r�|d|g}|rJz,t�d|jd�|��|�	|jg|�Wq�t
k
r�}zt|��W5d}~XYq�Xnt�d|�dS)N)r��/OUT:�Executing "%s" %s� �skipping %s (up-to-date))r_rw�_fix_object_args�library_filename�
_need_linkr	rrcr.r�rr)	r`r�Zoutput_libnamer�r�target_lang�output_filenameZlib_argsr�r r r!�create_static_lib�s�zMSVCCompiler.create_static_libc
Cs�|js|��|�||�\}}|�|||�}|\}}}|rL|�dt|��t||||�}|dk	rptj�	||�}|�
||��r�|j||	f}dd�|p�gD�}||||d|g}tj�|d�}|dk	�rtj�
tj�|��\}}tj�	||�|��}|�d|�|
�r|
|dd�<|�r.|�|�tj�tj�|��}|�|�z,t�d|jd�	|��|�|jg|�Wn,tk
�r�}zt|��W5d}~XYnXnt�d	|�dS)
Nz5I don't know what to do with 'runtime_library_dirs': cSsg|]}d|�qS)z/EXPORT:r )r?Zsymr r r!�
<listcomp>�sz%MSVCCompiler.link.<locals>.<listcomp>r�rz/IMPLIB:r�r�r�)r_rwr�Z
_fix_lib_args�warn�strrrrr.r�rtr�r~rr�r�r�rVZmkpathr	rrmr�rr)r`Ztarget_descr�r�r�Z	librariesZlibrary_dirsZruntime_library_dirsZexport_symbolsrr�r�Z
build_tempr�Z
fixed_argsZlib_optsrvZexport_optsZld_argsZdll_nameZdll_extZimplib_filer�r r r!�link�s`�
��
��

��

zMSVCCompiler.linkc	s8t�d�}z|jtjd<t��|�W�S|tjd<XdS)Nr)rrHr*rk�superr�)r`rNZold_path��	__class__r r!r��s

zMSVCCompiler.spawncCsd|S)Nz	/LIBPATH:r �r`rur r r!�library_dir_optionszMSVCCompiler.library_dir_optioncCstd��dS)Nz:don't know how to set runtime library search path for MSVC)rr�r r r!�runtime_library_dir_option
s�z'MSVCCompiler.runtime_library_dir_optioncCs
|�|�S)N)r�)r`rcr r r!�library_optionszMSVCCompiler.library_optioncCs\|r|d|g}n|g}|D]:}|D]0}tj�||�|��}tj�|�r$|Sq$qdS)NZ_d)rrr.r�r8)r`�dirsrcrZ	try_namesru�nameZlibfiler r r!�find_library_fileszMSVCCompiler.find_library_file)rrr)N)rrb)NNNrNNN)NrN)
NNNNNrNNNN)r)�__name__�
__module__�__qualname__�__doc__Z
compiler_typeZexecutablesr�r�r�r�r�r|rxZstatic_lib_extensionZshared_lib_extensionZstatic_lib_formatZshared_lib_formatZ
exe_extensionr]rwr�r�r�r�r�r�r�r�r��
__classcell__r r r�r!r[�sf
��

P�
"�
]�
�
Er[)N)r�rZshutil�statr,rZdistutils.errorsrrrrrZdistutils.ccompilerrrZ	distutilsr	Zdistutils.utilr
�	itertoolsrr"r3ZPLAT_SPEC_TO_RUNTIMEr<rSrZrir[r r r r!�<module>s4#�
�

?>