�`^c@sdZdZddlZddlZddlZddlmZmZmZm Z m
Z
ddlmZm
Z
ddlmZdZy@ddlZdZeZejZejZejZejZWn~ek
rDyLddlZddlZdZeZejZejZejZejZWnek
r@ejd �nXnXerlejej ej!ej"fZ#nd
�Z$d�Z%d�Z&d
fd��YZ'd�Z(d�Z)d�Z*defd��YZ+e(�dkrej,d�e+Z-ddl.m+Z+ddl.m'Z'ndS(s�distutils.msvccompiler
Contains MSVCCompiler, an implementation of the abstract CCompiler class
for the Microsoft Visual Studio.
s$Id$i�N(tDistutilsExecErrortDistutilsPlatformErrortCompileErrortLibErrort LinkError(t CCompilertgen_lib_options(tlogiis�Warning: Can't read registry to find the necessary compiler setting
Make sure that Python modules _winreg, win32api or win32con are installed.cCs}yt||�}Wntk
r'dSXg}d}xByt||�}Wntk
r^PnX|j|�|d}q7|S(sReturn list of registry keys.iiN(tRegOpenKeyExtRegErrortNonet
RegEnumKeytappend(tbasetkeythandletLtitk((s,/sys/lib/python2.7/distutils/msvccompiler.pyt read_keys;s
cCs�yt||�}Wntk
r'dSXi}d}x`yt||�\}}}Wntk
rgPnX|j�}t|�|t|�<|d}q7|S(sXReturn dict of registry keys and values.
All names are converted to lowercase.
iiN(RR R
tRegEnumValuetlowertconvert_mbcs(R
RRtdRtnametvaluettype((s,/sys/lib/python2.7/distutils/msvccompiler.pytread_valuesMs
cCsIt|dd�}|dk rEy|d�}WqEtk
rAqEXn|S(Ntencodetmbcs(tgetattrR
tUnicodeError(tstenc((s,/sys/lib/python2.7/distutils/msvccompiler.pyRbs
t
MacroExpandercBs,eZd�Zd�Zd�Zd�ZRS(cCsi|_|j|�dS(N(tmacrostload_macros(tselftversion((s,/sys/lib/python2.7/distutils/msvccompiler.pyt__init__ms cCsCx<tD]4}t||�}|r|||jd|<PqqWdS(Ns$(%s)(tHKEYSRR#(R%tmacrotpathRR
R((s,/sys/lib/python2.7/distutils/msvccompiler.pyt set_macroqs
c Cs%d|}|jd|dd�|jd|dd�d}|jd|d �y9|d
krv|jd|d�n|jd|d
�Wntk
r�td�nXd}xqtD]i}yt||�}Wntk
r�q�nXt|d�}t|d||f�}|d|jd<q�WdS(Ns%Software\Microsoft\VisualStudio\%0.1ftVCInstallDirs \Setup\VCt
productdirtVSInstallDirs \Setup\VSs Software\Microsoft\.NETFrameworktFrameworkDirtinstallrootg@tFrameworkSDKDirssdkinstallrootv1.1tsdkinstallrootsPython was built with Visual Studio 2003;
extensions must be built with a compiler than can generate compatible binaries.
Visual Studio 2003 was not found on this system. If you have Cygwin installed,
you can try compiling with MingW32, by passing "-c mingw32" to setup.py.s.Software\Microsoft\NET Framework Setup\Productis%s\%sR&s$(FrameworkVersion)( R+tKeyErrorRR(RR RRR#( R%R&tvsbasetnettpR
thRR((s,/sys/lib/python2.7/distutils/msvccompiler.pyR$xs*
cCs9x2|jj�D]!\}}tj|||�}qW|S(N(R#titemststringtreplace(R%R Rtv((s,/sys/lib/python2.7/distutils/msvccompiler.pytsub�s(t__name__t
__module__R'R+R$R<(((s,/sys/lib/python2.7/distutils/msvccompiler.pyR"ks cCs�d}tjtj|�}|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(R9tfindtsysR&tlentsplittintR
(tprefixRR tresttmajorVersiontminorVersion((s,/sys/lib/python2.7/distutils/msvccompiler.pytget_build_version�s cCs[d}tjtj|�}|dkr+dStjtjd|�}tj|t|�|!S(saReturn the processor architecture.
Possible results are "Intel", "Itanium", or "AMD64".
s bit (i�tIntelt)(R9R@RAR&RB(RERtj((s,/sys/lib/python2.7/distutils/msvccompiler.pytget_build_architecture�scCsIg}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.
(tosR*tnormpathR(tpathst
reduced_pathsR6tnp((s,/sys/lib/python2.7/distutils/msvccompiler.pytnormalize_and_reduce_paths�s
tMSVCCompilercBsDeZdZdZiZdgZdddgZdgZdgZeeeeZ dZ
d Zd
ZdZ
dZZd
Zdddd�Zd�Zddd�Zdddddddd�Zdddd�Zddddddddddd�Zd�Zd�Zd�Zdd�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.exeicCs�tj||||�t�|_t�|_|jdkr�|jdkrjd|_t|j�|_n d|_d|j|_ nd|jd|_ t
|_dS(NRJisSoftware\Microsoft\VisualStudiosSoftware\Microsoft\DevstudiosVisual Studio version %ssMicrosoft SDK compiler %si(RR'RIt_MSVCCompiler__versionRMt_MSVCCompiler__archt_MSVCCompiler__rootR"t_MSVCCompiler__macrost_MSVCCompiler__producttFalsetinitialized(R%tverbosetdry_runtforce((s,/sys/lib/python2.7/distutils/msvccompiler.pyR'�s cCs�g|_dtjkrfdtjkrf|jd�rfd|_d|_d|_d|_d|_n�|j d�|_t
|j�d kr�td
|j�n|jd�|_|jd�|_|jd�|_|jd�|_|jd�|_|j
d�|j
d�y8x1tjtjdd
�D]}|jj|�q1WWntk
r_nXt|j�|_tj|jd
�tjd<d|_|jdkr�dddddg|_dddddddg|_n9ddddddg|_dddddddg|_dddg|_|jdkrTddddg|_ndddddg|_dg|_t|_dS( NtDISTUTILS_USE_SDKtMSSdkscl.exeslink.exeslib.exesrc.exesmc.exeR*isxPython was built with %s, and extensions need to be built with the same version of the compiler, but it isn't installed.tlibtincludet;RJs/nologos/Oxs/MDs/W3s/GXs/DNDEBUGs/Ods/MDds/Z7s/D_DEBUGs/GS-s/DLLs/INCREMENTAL:NOis/INCREMENTAL:nos/DEBUGs /pdb:None(t_MSVCCompiler__pathsRNtenvirontfind_exetcctlinkerRbtrctmctget_msvc_pathsRBRRZtset_path_env_varR9RCRR3RStjoinR
tpreprocess_optionsRWtcompile_optionstcompile_options_debugtldflags_sharedRVtldflags_shared_debugtldflags_statictTrueR\(R%R6((s,/sys/lib/python2.7/distutils/msvccompiler.pyt
initialize�sT -
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(NRwisDon't know how to compile %s(R
RNR*tsplitextt
splitdrivetisabstsrc_extensionsRtbasenamet_rc_extensionsRRnt
res_extensiont_mc_extensionst
obj_extension(R%tsource_filenamest strip_dirt
output_dirt obj_namestsrc_nameR
text((s,/sys/lib/python2.7/distutils/msvccompiler.pytobject_filenames<s(
c Cs�|js|j�n|j||||||�\}} }}
}|pLg}|jd�|ru|j|j�n|j|j�xM| D]E}
y||
\}}Wntk
r�q�nX|r�tj j
|�}n||jkr�|}n�||jkrd|}nk||j
kr}|}d|
}y)|j|jg|
|g|g�Wq�tk
rv}t|�q�Xq�n�|jkretj j|�}tj j|
�}y�|j|jgd|d|g|g�tj jtj j|��\}}tj j||d�}|j|jgd|
g|g�Wq�tk
r^}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\Rvt_setup_compileRtextendRqRpR3RNR*tabspatht
_c_extensionst_cpp_extensionsR}tspawnRjRRRtdirnameRkRxR|RnRh(R%tsourcesR�R#tinclude_dirstdebugt
extra_preargstextra_postargstdependstobjectstpp_optstbuildtcompile_optstobjtsrcR�t input_optt
output_opttmsgth_dirtrc_dirR
t_trc_file((s,/sys/lib/python2.7/distutils/msvccompiler.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\Rvt_fix_object_argstlibrary_filenamet
_need_linkR�RbRRRR�( R%R�toutput_libnameR�R�ttarget_langtoutput_filenametlib_argsR�((s,/sys/lib/python2.7/distutils/msvccompiler.pytcreate_static_lib�s
cCsW|js|j�n|j||�\}}|j|||�\}}}|rl|jdt|��nt||||�}|dk r�tj j
||�}n|j||�rC|tj
kr� r�|jd}q|jd}n| r�j}n |j}g}x%|pgD]}|jd|�qW||||d|g}|dk r�tj jtj j|��\}}tj j
tj j|d�|j|��}|jd|�n|
r�|
|d*n|r�j|�n|jtj j|��y|j|jg|�WqStk
r?}t|�qSXntjd|�dS(Ns5I don't know what to do with 'runtime_library_dirs': is/EXPORT:s/OUT:is/IMPLIB:sskipping %s (up-to-date)(R\RvR�t
_fix_lib_argstwarntstrRR
RNR*RnR�Rt
EXECUTABLERsRrRRxR|R�R�R�tmkpathR�RiRRRR�(R%ttarget_descR�R�R�t librariestlibrary_dirstruntime_library_dirstexport_symbolsR�R�R�t
build_tempR�tlib_optstldflagstexport_optstsymtld_argstdll_nametdll_exttimplib_fileR�((s,/sys/lib/python2.7/distutils/msvccompiler.pytlink�sR
cCsd|S(Ns /LIBPATH:((R%tdir((s,/sys/lib/python2.7/distutils/msvccompiler.pytlibrary_dir_option$scCs
td�dS(Ns<don't know how to set runtime library search path for MSVC++(R(R%R�((s,/sys/lib/python2.7/distutils/msvccompiler.pytruntime_library_dir_option'scCs
|j|�S(N(R�(R%Rb((s,/sys/lib/python2.7/distutils/msvccompiler.pytlibrary_option+scCs�|r|d|g}n |g}xW|D]K}xB|D]:}tjj||j|��}tjj|�r6|Sq6Wq)WdSdS(Nt_d(RNR*RnR�texistsR
(R%tdirsRbR�t try_namesR�Rtlibfile((s,/sys/lib/python2.7/distutils/msvccompiler.pytfind_library_file/s
cCs�xH|jD]=}tjjtjj|�|�}tjj|�r
|Sq
WxXtjtjdd�D]=}tjjtjj|�|�}tjj|�re|SqeW|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'.
tPathRd( ReRNR*RnR�tisfileR9RCRf(R%texeR6tfn((s,/sys/lib/python2.7/distutils/msvccompiler.pyRgCs
! !tx86cCsts
gS|d}|jdkr<d|j|jf}nd|j|f}xitD]a}t||�}|rV|jdkr�tj|jj||�d�Stj||d�SqVqVW|jdkrx>tD]3}t|d|j�d k r�|j
d�Pq�q�WngS(
s�Get a list of devstudio directories (include, lib or path).
Return a list of strings. The list will be empty if unable to
access the registry or appropriate registry keys not found.
s dirsis6%s\%0.1f\VC\VC_OBJECTS_PLATFORM_INFO\Win32\Directoriess?%s\6.0\Build System\Components\Platforms\Win32 (%s)\DirectoriesRdis%s\6.0s�It seems you have Visual Studio 6 installed, but the expected registry settings are not present.
You must at least run the Visual Studio GUI once so that these entries are created.N(t
_can_read_regRVRXR(RR9RCRYR<R
R�(R%R*tplatformRR
R((s,/sys/lib/python2.7/distutils/msvccompiler.pyRlZs(
cCsS|dkr|jd�}n|j|�}|rOtj|d�tj|<ndS(s�Set environment variable 'name' to an MSVC path type value.
This is equivalent to a SET command prior to execution of spawned
commands.
RbtlibraryRdN(RlR9RnRNRf(R%RR6((s,/sys/lib/python2.7/distutils/msvccompiler.pyRms
N(R=R>t__doc__t
compiler_typetexecutablesR�R�R}RR{R~R�tstatic_lib_extensiontshared_lib_extensiontstatic_lib_formattshared_lib_formatt
exe_extensionR'RvR�R
R�R�R�R�R�R�R�RgRlRm(((s,/sys/lib/python2.7/distutils/msvccompiler.pyRT�sP
BZG %g @s3Importing new compiler from distutils.msvc9compiler(RT(R"(/R�t__revision__RARNR9tdistutils.errorsRRRRRtdistutils.ccompilerRRt distutilsRR�t_winregthkey_modt OpenKeyExRtEnumKeyRt EnumValueRterrorR tImportErrortwin32apitwin32continfot
HKEY_USERStHKEY_CURRENT_USERtHKEY_LOCAL_MACHINEtHKEY_CLASSES_ROOTR(RRRR"RIRMRSRTR�tOldMSVCCompilertdistutils.msvc9compiler(((s,/sys/lib/python2.7/distutils/msvccompiler.pyt<module>s`(
.
�
|