Plan 9 from Bell Labs’s /usr/web/sources/contrib/stallion/root/sys/lib/python2.7/distutils/msvc9compiler.pyc

Copyright © 2021 Plan 9 Foundation.
Distributed under the MIT License.
Download the Plan 9 distribution.


�`^c@s�dZdZddlZddlZddlZddlZddlmZmZm	Z	m
Z
mZddlm
Z
mZddlmZddlmZddlZejZejZejZejZejejejejfZ ej!dkoej"d%kZ#e#r'dZ$dZ%d
Z&dZ'ndZ$dZ%dZ&dZ'idd6dd6dd6Z(dd&d��YZ)dd'd��YZ*d�Z+d�Z,d�Z-d�Z.dd �Z/e+�Z0e0d!kr�ed"e0��nd#e
fd$��YZ1dS((sdistutils.msvc9compiler

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

The module is compatible with VS 2005 and VS 2008. You can find legacy support
for older versions of VS in distutils.msvccompiler.
s$Id$i�N(tDistutilsExecErrortDistutilsPlatformErrortCompileErrortLibErrort	LinkError(t	CCompilertgen_lib_options(tlog(tget_platformtwin32ii s1Software\Wow6432Node\Microsoft\VisualStudio\%0.1fs.Software\Wow6432Node\Microsoft\VCExpress\%0.1fs5Software\Wow6432Node\Microsoft\Microsoft SDKs\Windowss,Software\Wow6432Node\Microsoft\.NETFrameworks%Software\Microsoft\VisualStudio\%0.1fs"Software\Microsoft\VCExpress\%0.1fs)Software\Microsoft\Microsoft SDKs\Windowss Software\Microsoft\.NETFrameworktx86tamd64s	win-amd64tia64swin-ia64tRegcBsbeZdZd�Zee�Zd�Zee�Zd�Zee�Zd�Zee�ZRS(s2Helper class to read values from the registry
    cCsMx:tD]2}|j||�}|r||kr||SqWt|��dS(N(tHKEYStread_valuestKeyError(tclstpathtkeytbasetd((s-/sys/lib/python2.7/distutils/msvc9compiler.pyt	get_valueDs

cCs�yt||�}Wntk
r'dSXg}d}xItryt||�}Wntk
rdPnX|j|�|d7}q7W|S(sReturn list of registry keys.iiN(tRegOpenKeyExtRegErrortNonetTruet
RegEnumKeytappend(RRRthandletLtitk((s-/sys/lib/python2.7/distutils/msvc9compiler.pyt	read_keysLs
	

c	Cs�yt||�}Wntk
r'dSXi}d}xmtr�yt||�\}}}Wntk
rmPnX|j�}|j|�||j|�<|d7}q7W|S(s`Return dict of registry keys and values.

        All names are converted to lowercase.
        iiN(RRRRtRegEnumValuetlowertconvert_mbcs(	RRRRRRtnametvaluettype((s-/sys/lib/python2.7/distutils/msvc9compiler.pyR^s
	
cCsIt|dd�}|dk	rEy|d�}WqEtk
rAqEXn|S(Ntdecodetmbcs(tgetattrRtUnicodeError(tstdec((s-/sys/lib/python2.7/distutils/msvc9compiler.pyR$ts
(	t__name__t
__module__t__doc__RtclassmethodR!RR$tstaticmethod(((s-/sys/lib/python2.7/distutils/msvc9compiler.pyR
@s				t
MacroExpandercBs,eZd�Zd�Zd�Zd�ZRS(cCs'i|_t||_|j|�dS(N(tmacrostVS_BASEtvsbasetload_macros(tselftversion((s-/sys/lib/python2.7/distutils/msvc9compiler.pyt__init__�s	
cCs!tj||�|jd|<dS(Ns$(%s)(R
RR4(R8tmacroRR((s-/sys/lib/python2.7/distutils/msvc9compiler.pyt	set_macro�scCsR|jd|jdd�|jd|jdd�|jdtd�y2|dkrl|jd	td
�ntd
��Wntk
r�td��nX|dkr�|jd
|jd�|jdtd�n}d}xttD]l}yt||�}Wntk
r
q�nXt	|d�}t
j|d||f�}|d|jd<q�WdS(NtVCInstallDirs	\Setup\VCt
productdirtVSInstallDirs	\Setup\VStFrameworkDirtinstallrootg @tFrameworkSDKDirssdkinstallrootv2.0sPython 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"@tFrameworkVersionsclr versiont
WindowsSdkDirtcurrentinstallfolders.Software\Microsoft\NET Framework Setup\Productis%s\%sR9s$(FrameworkVersion)(
R<R6tNET_BASERRtWINSDK_BASERRRRR
RR4(R8R9tpRthRR((s-/sys/lib/python2.7/distutils/msvc9compiler.pyR7�s.




cCs6x/|jj�D]\}}|j||�}qW|S(N(R4titemstreplace(R8R,R tv((s-/sys/lib/python2.7/distutils/msvc9compiler.pytsub�s(R.R/R:R<R7RM(((s-/sys/lib/python2.7/distutils/msvc9compiler.pyR3~s			cCs�d}tjj|�}|dkr(dS|t|�}tj|jdd�\}}t|d �d}t|dd!�d	}|dkr�d
}n|dkr�||SdS(s�Return the version of MSVC that was used to build Python.

    For Python 2.3 and up, the version number is included in
    sys.version.  For earlier versions, assume the compiler is MSVC 6.
    sMSC v.i�it ii�iig$@iN(tsysR9tfindtlentsplittintR(tprefixRR,tresttmajorVersiontminorVersion((s-/sys/lib/python2.7/distutils/msvc9compiler.pytget_build_version�s	cCsIg}x<|D]4}tjj|�}||kr
|j|�q
q
W|S(snReturn a list of normalized paths with duplicates removed.

    The current order of paths is maintained.
    (tosRtnormpathR(tpathst
reduced_pathsRHtnp((s-/sys/lib/python2.7/distutils/msvc9compiler.pytnormalize_and_reduce_paths�s
cCs[|jtj�}g}x*|D]"}||kr|j|�qqWtjj|�}|S(s8Remove duplicate values of an environment variable.
    (RRRYtpathsepRtjoin(tvariabletoldListtnewListRtnewVariable((s-/sys/lib/python2.7/distutils/msvc9compiler.pytremoveDuplicates�s
cCs�t|}ytjd|d�}Wntk
r=d}nX|dkr�t|}ytjd|d�}Wq�tk
r�d}tjd�q�Xn|s�tj	j
|�rZd|}tjj|d�}|rFtj	j
|�rFtj	j
|tjtjd�}tj	j|�}tj	j
|�sWtjd|�dSqZtjd|�n|sqtjd�dStj	j
|d	�}tj	j|�r�|Stjd
�dS(s�Find the vcvarsall.bat file

    At first it tries to find the productdir of VS 2008 in the registry. If
    that fails it falls back to the VS90COMNTOOLS env var.
    s%s\Setup\VCR>s%Unable to find productdir in registrysVS%0.f0COMNTOOLStVCs%s is not a valid directorys Env var %s is not set or invalidsNo productdir founds
vcvarsall.batsUnable to find vcvarsall.batN(R5R
RRRtVSEXPRESS_BASERtdebugRYRtisdirtenvirontgetR`tpardirtabspathtisfile(R9R6R>ttoolskeyttoolsdirt	vcvarsall((s-/sys/lib/python2.7/distutils/msvc9compiler.pytfind_vcvarsall�s@









!

cCs�t|�}td�}i}|dkr9td��ntjd||�tjd||fdtjd	tj�}z�j	�\}}|j
�d
kr�t|jd���n|jd�}x�|jd�D]�}t
j|�}d
|kr�n|j�}|jd
d�\}	}
|	j�}	|	|kr�|
jtj�rW|
d }
nt|
�||	<q�q�WWd|jj�|jj�Xt|�t|�kr�ttt|j�����n|S(sDLaunch vcvarsall.bat and read the settings from its environment
    tincludetlibtlibpathRsUnable to find vcvarsall.bats'Calling 'vcvarsall.bat %s' (version=%s)s
"%s" %s & settstdouttstderriR)s
t=ii�N(sincludeslibslibpathspath(RrtsetRRRRht
subprocesstPopentPIPEtcommunicatetwaitR(RRR
R$tstripR#tendswithRYR_ReRvtcloseRwRQt
ValueErrortstrtlisttkeys(R9tarchRqtinterestingtresulttpopenRvRwtlineRR&((s-/sys/lib/python2.7/distutils/msvc9compiler.pytquery_vcvarsalls<	

!g @s(VC %0.1f is not supported by this moduletMSVCCompilercBsMeZdZdZiZdgZdddgZdgZdgZeeeeZ	dZ
d	Zd
ZdZ
dZZd
Zdddd�Zdd�Zddd�Zdddddddd�Zdddd�Zddddddddddd�Zd�Zd�Zd�Zd�Zd�Zd�Zdd�Zd�ZRS(swConcrete class that implements an interface to Microsoft Visual C++,
       as defined by the CCompiler abstract class.tmsvcs.cs.ccs.cpps.cxxs.rcs.mcs.ress.objs.libs.dlls%s%ss.exeicCsPtj||||�t|_d|_g|_d|_d|_t	|_
dS(NsSoftware\Microsoft\VisualStudio(RR:tVERSIONt_MSVCCompiler__versiont_MSVCCompiler__roott_MSVCCompiler__pathsRt	plat_namet_MSVCCompiler__archtFalsetinitialized(R8tverbosetdry_runtforce((s-/sys/lib/python2.7/distutils/msvc9compiler.pyR:Ss					cCs.|jstd��|dkr.t�}nd&}||krVtd|f��ndtjkr�dtjkr�|jd�r�d|_d	|_	d
|_
d|_d|_n+|t�ks�|dkr�t
|}nt
t�d
t
|}tt|�}|djd�jtj�|_|djd�tjd<|djd�tjd<t|j�dkr�td|j��n|jd�|_|jd	�|_	|jd
�|_
|jd�|_|jd�|_y5x.tjdjd�D]}|jj|�q�ntk
r&nXt|j�|_dj|j�tjd<d|_|jdkr�dddddg|_ddddddg|_n9ddddddg|_dddddddg|_d dd!g|_|jd"krd dd#d$d%g|_ ndg|_!t"|_dS('Nsdon't init multiple timesR	s	win-amd64swin-ia64s--plat-name must be one of %stDISTUTILS_USE_SDKtMSSdkscl.exeslink.exeslib.exesrc.exesmc.exet_RR)RtRsisxPython was built with %s, and extensions need to be built with the same version of the compiler, but it isn't installed.t;R
s/nologos/Oxs/MDs/W3s/DNDEBUGs/Ods/MDds/Z7s/D_DEBUGs/GS-s/DLLs/INCREMENTAL:NOis/INCREMENTAL:nos/DEBUGs	/pdb:None(swin32s	win-amd64swin-ia64(#R�tAssertionErrorRRRRYRjtfind_exetcctlinkerRttrctmctPLAT_TO_VCVARSR�R�tencodeRRR_R�RQt_MSVCCompiler__productRRR^R`tpreprocess_optionsR�tcompile_optionstcompile_options_debugtldflags_sharedR�tldflags_shared_debugtldflags_staticR(R8R�tok_platst	plat_spectvc_envRH((s-/sys/lib/python2.7/distutils/msvc9compiler.pyt
initialize^sf-				
"
	tcCs>|dkrd}ng}x|D]}tjj|�\}}tjj|�d}|tjj|�}||jkr�td|��n|r�tjj|�}n||j	kr�|j
tjj|||j��q"||j
kr|j
tjj|||j��q"|j
tjj|||j��q"W|S(NR�isDon't know how to compile %s(RRYRtsplitextt
splitdrivetisabstsrc_extensionsRtbasenamet_rc_extensionsRR`t
res_extensiont_mc_extensionst
obj_extension(R8tsource_filenamest	strip_dirt
output_dirt	obj_namestsrc_nameRtext((s-/sys/lib/python2.7/distutils/msvc9compiler.pytobject_filenames�s(	
c	Cs�|js|j�n|j||||||�}	|	\}}
}}}|pRg}
|
jd�|r{|
j|j�n|
j|j�xV|
D]N}y||\}}Wntk
r�q�nX|r�tj	j
|�}n||jkr�|}n�||jkrd|}nq||j
kr�|}d|}y)|j|jg||g|g�Wq�tk
r}t|��q�Xq�n||jkrqtj	j|�}tj	j|�}y�|j|jgd|d|g|g�tj	jtj	j|��\}}tj	j||d�}|j|jgd|g|g�Wq�tk
rj}t|��q�Xq�ntd||f��d	|}y-|j|jg|
|||g|�Wq�tk
r�}t|��q�Xq�W|
S(
Ns/cs/Tcs/Tps/fos-hs-rs.rcs"Don't know how to compile %s to %ss/Fo(R�R�t_setup_compileRtextendR�R�RRYRRmt
_c_extensionst_cpp_extensionsR�tspawnR�RRR�tdirnameR�R�R�R`R�(R8tsourcesR�R4tinclude_dirsRht
extra_preargstextra_postargstdependstcompile_infotobjectstpp_optstbuildtcompile_optstobjtsrcR�t	input_optt
output_opttmsgth_dirtrc_dirRR�trc_file((s-/sys/lib/python2.7/distutils/msvc9compiler.pytcompile�sj	






#$$#
c	Cs�|js|j�n|j||�\}}|j|d|�}|j||�r�|d|g}|rony|j|jg|�Wq�tk
r�}t|��q�Xnt	j
d|�dS(NR�s/OUT:sskipping %s (up-to-date)(R�R�t_fix_object_argstlibrary_filenamet
_need_linkR�RtRRRRh(	R8R�toutput_libnameR�Rhttarget_langtoutput_filenametlib_argsR�((s-/sys/lib/python2.7/distutils/msvc9compiler.pytcreate_static_lib)s	
	cCs�|js|j�n|j||�\}}|j|||�}|\}}}|rr|jdt|��nt||||�}|dk	r�tj	j
||�}n|j||�r�tj
kr�r�jd}q
|jd}n|	r|j}n	|j}g}x%|pgD]}|jd|�q W||||d|g}tj	j|d�}|dk	r�tj	jtj	j|��\}}tj	j
||j|��}|jd|�n|j|||�|
r�|d*n|r|j|�n|jtj	j|��y|j|jg|�Wntk
ra}t|��nX|j||�}|dk	r�\}}d||f}y |jdd	d
||g�Wq�tk
r�}t|��q�q�tjd|�dS(Ns5I don't know what to do with 'runtime_library_dirs': is/EXPORT:s/OUT:is/IMPLIB:s-outputresource:%s;%ssmt.exes-nologos	-manifestsskipping %s (up-to-date)(R�R�R�t
_fix_lib_argstwarnR�RRRYRR`R�Rt
EXECUTABLER�R�RR�R�R�R�tmanifest_setup_ldargsR�tmkpathR�R�RRtmanifest_get_embed_infoRRh(R8ttarget_descR�R�R�t	librariestlibrary_dirstruntime_library_dirstexport_symbolsRhR�R�t
build_tempR�t
fixed_argstlib_optstldflagstexport_optstsymtld_argstdll_nametdll_exttimplib_fileR�tmfinfot
mffilenametmfidtout_arg((s-/sys/lib/python2.7/distutils/msvc9compiler.pytlinkBsl	
						
cCs:tjj|tjj|�d�}|jd|�dS(Ns	.manifests/MANIFESTFILE:(RYRR`R�R(R8R�R�R�t
temp_manifest((s-/sys/lib/python2.7/distutils/msvc9compiler.pyR��s	cCs�x;|D]/}|jd�r|jdd�d}PqqWdS|tjkrVd}nd}|j|�}|dkr{dS||fS(Ns/MANIFESTFILE:t:ii(t
startswithRRRRR�t_remove_visual_c_ref(R8R�R�targR�R�((s-/sys/lib/python2.7/distutils/msvc9compiler.pyR��s
	cCs�y�t|�}z|j�}Wd|j�Xtjdtj�}tj|d|�}d}tj|d|�}tjdtj�}tj||�dkr�dSt|d�}z|j	|�|SWd|j�XWnt
k
r�nXdS(NsU<assemblyIdentity.*?name=("|')Microsoft\.VC\d{2}\.CRT("|').*?(/>|</assemblyIdentity>)R�s*<dependentAssembly>\s*</dependentAssembly>sI<assemblyIdentity.*?name=(?:"|')(.+?)(?:"|').*?(?:/>|</assemblyIdentity>)tw(topentreadR�treR�tDOTALLRMtsearchRtwritetIOError(R8t
manifest_filet
manifest_ftmanifest_buftpattern((s-/sys/lib/python2.7/distutils/msvc9compiler.pyR��s.	

cCsd|S(Ns	/LIBPATH:((R8tdir((s-/sys/lib/python2.7/distutils/msvc9compiler.pytlibrary_dir_option�scCstd��dS(Ns<don't know how to set runtime library search path for MSVC++(R(R8R
((s-/sys/lib/python2.7/distutils/msvc9compiler.pytruntime_library_dir_option�scCs
|j|�S(N(R�(R8Rt((s-/sys/lib/python2.7/distutils/msvc9compiler.pytlibrary_option�scCs�|r|d|g}n	|g}xW|D]K}xB|D]:}tjj||j|��}tjj|�r6|Sq6Wq)WdSdS(Nt_d(RYRR`R�texistsR(R8tdirsRtRht	try_namesR
R%tlibfile((s-/sys/lib/python2.7/distutils/msvc9compiler.pytfind_library_file�s	

cCs�xH|jD]=}tjjtjj|�|�}tjj|�r
|Sq
WxUtjdjd�D]=}tjjtjj|�|�}tjj|�rb|SqbW|S(s�Return 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'.
        tPathR�(R�RYRR`RmRnRjRR(R8texeRHtfn((s-/sys/lib/python2.7/distutils/msvc9compiler.pyR�
s	!!N( R.R/R0t
compiler_typetexecutablesR�R�R�R�R�R�R�tstatic_lib_extensiontshared_lib_extensiontstatic_lib_formattshared_lib_formatt
exe_extensionR:RR�R�R�R�R�R�R�R�RRRRR�(((s-/sys/lib/python2.7/distutils/msvc9compiler.pyR�5sR			
YVR			+			l(((2R0t__revision__RYRzRORtdistutils.errorsRRRRRtdistutils.ccompilerRRt	distutilsRtdistutils.utilRt_winregt	OpenKeyExRtEnumKeyRt	EnumValueR"terrorRt
HKEY_USERStHKEY_CURRENT_USERtHKEY_LOCAL_MACHINEtHKEY_CLASSES_ROOTRtplatformtmaxsizetNATIVE_WIN64R5RgRGRFR�R
R3RXR^ReRrR�R�R�(((s-/sys/lib/python2.7/distutils/msvc9compiler.pyt<module>sV(					
>.				,)	

Bell Labs OSI certified Powered by Plan 9

(Return to Plan 9 Home Page)

Copyright © 2021 Plan 9 Foundation. All Rights Reserved.
Comments to [email protected].