Viewing File: /opt/alt/python35/lib64/python3.5/distutils/__pycache__/_msvccompiler.cpython-35.pyc



YfO@s*dZddlZddlZddlZddlZddlmZmZmZm	Z	m
Z
ddlmZm
Z
ddlmZddlmZddlZddlmZdd	Zd
dZddd
ZddddiZddddddiZedgZGddde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)DistutilsExecErrorDistutilsPlatformErrorCompileErrorLibError	LinkError)	CCompilergen_lib_options)log)get_platform)countc$Csy)tjtjddtjtjB}Wn#tk
rNtjdd	SYnX|d}d}xtD]}ytj	||\}}}Wntk
rPYnX|rl|tj
krltjj
|rlytt|}Wnttfk
rwlYnX|dkrl||krl||}}qlW|sBtjdd
Stjj|d}	tjj|	s}tjd|	dSd}
tj|}|rtjj||j|}
tjj|
stjd|
d}
|	|
fSWdQRXdS)Nz'Software\Microsoft\VisualStudio\SxS\VC7accesszVisual C++ is not registeredrz$No suitable Visual C++ version foundz
vcvarsall.batz%s cannot be found)NN)NN)NN)winregZ	OpenKeyExHKEY_LOCAL_MACHINEZKEY_READZKEY_WOW64_32KEYOSErrorr	debugrZ	EnumValueZREG_SZospathisdirintfloat
ValueError	TypeErrorjoinisfile _VCVARS_PLAT_TO_VCRUNTIME_REDISTgetformat)	plat_speckeyZbest_versionZbest_dirivZvc_dirZvtversion	vcvarsall	vcruntimeZvcruntime_specr%</opt/alt/python35/lib64/python3.5/distutils/_msvccompiler.py_find_vcvarsallsN

	
'
r'cCstjdr)ddtjjDSt|\}}|sMtdy7tjdj||dtj	j
ddd	}WnPtjk
r}z-tj
|jtd
j|jWYdd}~XnXdddd
|jDD}|r
||d<|S)NZDISTUTILS_USE_SDKcSs%i|]\}}||jqSr%)lower).0rvaluer%r%r&
<dictcomp>Ns	z_get_vc_env.<locals>.<dictcomp>zUnable to find vcvarsall.batzcmd /u /c "{}" {} && setstderrzutf-16leerrorsreplacezError executing {}cSs4i|]*\}}}|r|r||jqSr%)r()r)r_r*r%r%r&r+as	css|]}|jdVqdS)=N)	partition)r)liner%r%r&	<genexpr>dsz_get_vc_env.<locals>.<genexpr>py_vcruntime_redist)rgetenvenvironitemsr'r
subprocessZcheck_outputrZSTDOUTdecodeZCalledProcessErrorr	erroroutputcmd
splitlines)rr#r$outexcenvr%r%r&_get_vc_envLs(		"	
rAcCsm|s!tjdjtj}xE|D]=}tjjtjj||}tjj|r(|Sq(W|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)rr5splitpathseprrabspathr)Zexepathspfnr%r%r&	_find_exels	
!rHwin32Zx86z	win-amd64Z	x86_amd64z1redist\x86\Microsoft.VC{0}0.CRT\vcruntime{0}0.dllamd64z1redist\x64\Microsoft.VC{0}0.CRT\vcruntime{0}0.dllzvcruntime140.dllcsmeZdZdZdZiZdgZdddgZdgZdgZ	eeee	Z
d	Zd
ZdZ
dZd
ZZdZdddddZdddZddddZdddddddddZdddddZdddddddddddd
ZddZfd d!Zd"d#Zd$d%Zd&d'Zdd(d)ZS)*MSVCCompilerzwConcrete class that implements an interface to Microsoft Visual C++,
       as defined by the CCompiler abstract class.Zmsvcz.cz.ccz.cppz.cxxz.rcz.mcz.resz.objz.libz.dllz%s%sz.exercCs,tj||||d|_d|_dS)NF)r__init__	plat_nameinitialized)selfverboseZdry_runZforcer%r%r&rLs	zMSVCCompiler.__init__NcCs;|jstd|dkr+t}|tkrRtdjttt|}t|}|sztd|jdd|_	|j	j
tj}t
d||_t
d||_t
d||_t
d	||_t
d
||_t
d||_|jdd|_x9|jd
dj
tjD]}|rD|j|qDWx9|jddj
tjD]}|r|j|qWd|_dddddg|_|jj|jrdndddddddg|_dddg}|js|jd%ddddg}|d&|_|d'|_|d(|_|d)|_||_ ||_!t"j#df|jt"j#d#f|jt"j#d$f|jt"j$df|jt"j$d#f|jt"j$d$f|jt"j%df|j t"j%d#f|j t"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.rzcl.exezlink.exezlib.exezrc.exezmc.exezmt.exer4includelibz/nologoz/Oxz/W3z/GLz/DNDEBUGz/MDz/MTz/Odz/MDdz/Ziz/D_DEBUGz/INCREMENTAL:NOz/LTCG/nodefaultlib:libucrt.libucrt.libz/DEBUG:FULL/MANIFEST:EMBED,ID=1/DLL/MANIFEST:EMBED,ID=2/MANIFESTUAC:NOFT)rTrU)rV)rV)rWrXrY)rWrXrY)'rNAssertionErrorr
PLAT_TO_VCVARSrrtuplerAr_pathsrBrrCrHcclinkerrSrcmcZmt_vcruntime_redistZadd_include_dirZadd_library_dirZpreprocess_optionscompile_optionsappendcompile_options_debugextendZldflags_exeZldflags_exe_debugZldflags_sharedZldflags_shared_debugZldflags_staticZldflags_static_debugrZ
EXECUTABLEZ
SHARED_OBJECTZSHARED_LIBRARY_ldflags)rOrMrZvc_envrEdirldflagsZ
ldflags_debugr%r%r&
initializesb		
%%		
zMSVCCompiler.initializerQcsvfddjDfddjjDpHdfdd}tt||S)Ncsi|]}j|qSr%)
obj_extension)r)ext)rOr%r&r+s	z1MSVCCompiler.object_filenames.<locals>.<dictcomp>csi|]}j|qSr%)
res_extension)r)rl)rOr%r&r+s	rQcstjj|\}}r3tjj|}nItjj|\}}|jtjjtjjfr||dd}ytjj||SWn't	k
rt
dj|YnXdS)NzDon't know how to compile {})rrsplitextbasename
splitdrive
startswithsepaltseprLookupErrorrr)rFbaserlr/)ext_map
output_dir	strip_dirr%r&
make_out_paths!
z4MSVCCompiler.object_filenames.<locals>.make_out_path)src_extensions_rc_extensions_mc_extensionslistmap)rOZsource_filenamesryrxrzr%)rwrxrOryr&object_filenames
s
&zMSVCCompiler.object_filenamesc	Cs?|js|j|j||||||}	|	\}}
}}}|pOg}
|
jd|rx|
j|jn|
j|jd}x|
D]}y||\}}Wntk
rwYnX|rtj	j
|}||jkrd|}n||jkrd|}d}n||j
kr|}d|}y%|j|jg|||gWqtk
r}zt|WYdd}~XqXqn||jkrtj	j|}tj	j|}y|j|jd|d||gtj	jtj	j|\}}tj	j||d	}|j|jd||gWqtk
r}zt|WYdd}~XqXqntd
j|||jg|
|}|r|jd|j||jd||j|y|j|Wqtk
r6}zt|WYdd}~XqXqW|
S)
Nz/cFz/Tcz/TpTz/foz-hz-rz.rcz"Don't know how to compile {} to {}z/EHscz/Fo)rNrjZ_setup_compilerdrfrercKeyErrorrrrD
_c_extensions_cpp_extensionsr|spawnr`rrr}dirnamerarorprrr^)rOZsourcesrxZmacrosZinclude_dirsr
extra_preargsextra_postargsZdependsZcompile_infoobjectsZpp_optsZbuildZcompile_optsZadd_cpp_optsobjsrcrlZ	input_optZ
output_optmsgZh_dirZrc_dirrvr/Zrc_fileargsr%r%r&compile+sn	





	
%"$!	


#zMSVCCompiler.compilec	Cs|js|j|j||\}}|j|d|}|j||r|d|g}|riy:tjd|jdj||j	|jg|Wqt
k
r}zt|WYdd}~XqXntjd|dS)Nrxz/OUT:zExecuting "%s" %s zskipping %s (up-to-date))rNrj_fix_object_argslibrary_filename
_need_linkr	rrSrrrr)	rOrZoutput_libnamerxrtarget_langoutput_filenameZlib_argsrr%r%r&create_static_libs	
	"zMSVCCompiler.create_static_libcCsX|js|j|j||\}}|j|||}|\}}}|rl|jdt|t||||}|dk	rtjj	||}|j
||rD|j||	f}dd|pgD}||||d|g}tjj|d}|dk	rrtjj
tjj|\}}tjj	||j|}|jd||
r|
|dd<|r|j|tjjtjj|}|j|yGtjd|jdj	||j|jg||j|WqTtk
r@}zt|WYdd}~XqTXntjd	|dS)
Nz5I don't know what to do with 'runtime_library_dirs': cSsg|]}d|qS)z/EXPORT:r%)r)Zsymr%r%r&
<listcomp>s	z%MSVCCompiler.link.<locals>.<listcomp>z/OUT:rz/IMPLIB:zExecuting "%s" %srzskipping %s (up-to-date))rNrjrZ
_fix_lib_argswarnstrrrrrrrgrrorprrdrfrDZmkpathr	rr_r_copy_vcruntimerr)rOZtarget_descrrrxZ	librariesZlibrary_dirsZruntime_library_dirsZexport_symbolsrrrZ
build_temprZ
fixed_argsZlib_optsriZexport_optsZld_argsZdll_nameZdll_extZimplib_filerr%r%r&linksN	
					

"zMSVCCompiler.linkcCs|j}|s#tjj|r'dStjj|jtkrIdStjd|t	j
||}tj|tj
dS)NzCopying "%s")rbrrrrpr(
_BUNDLED_DLLSr	rshutilcopychmodstatS_IWRITE)rOrxr$r%r%r&rs	zMSVCCompiler._copy_vcruntimecsHtjd}z$|jtjd<tj|SWd|tjd<XdS)Nr)rr5r]r6superr)rOr<Zold_path)	__class__r%r&rs
zMSVCCompiler.spawncCsd|S)Nz	/LIBPATH:r%)rOrhr%r%r&library_dir_optionszMSVCCompiler.library_dir_optioncCstddS)Nz:don't know how to set runtime library search path for MSVC)r)rOrhr%r%r&runtime_library_dir_optionsz'MSVCCompiler.runtime_library_dir_optioncCs
|j|S)N)r)rOrSr%r%r&library_optionszMSVCCompiler.library_optioncCs|r|d|g}n	|g}xW|D]K}xB|D]:}tjj||j|}tjj|r6|Sq6Wq)WdSdS)NZ_d)rrrrr)rOdirsrSrZ	try_namesrhnameZlibfiler%r%r&find_library_files	

zMSVCCompiler.find_library_file)__name__
__module____qualname____doc__Z
compiler_typeZexecutablesrrr|r}r{rmrkZstatic_lib_extensionZshared_lib_extensionZstatic_lib_formatZshared_lib_formatZ
exe_extensionrLrjrrrrrrrrrrr%r%)rr&rKsN			
T[9rK)rrrrr8Zdistutils.errorsrrrrrZdistutils.ccompilerrrZ	distutilsr	Zdistutils.utilr
r	itertoolsrr'rArHr[r	frozensetrrKr%r%r%r&<module>s((. 
Back to Directory File Manager