i f3w@sdZddlZddlZddlZddlZddlmZmZmZm Z m Z ddl m Z m Z mZddlmZddlmZddlZejZejZejZejZejejejejfZ ej!dkoej"d'kZ#e#r!d Z$d Z%d Z&nd Z$dZ%dZ&idd6dd6dd6Z'GdddZ(GdddZ)ddZ*ddZ+ddZ,dd Z-dd!d"Z.e*Z/e/d#kred$e/nGd%d&d&e Z0dS)(a 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. N)DistutilsExecErrorDistutilsPlatformError CompileErrorLibError LinkError) CCompilergen_preprocess_optionsgen_lib_options)log) get_platformwin32 z1Software\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\.NETFrameworkx86amd64z win-amd64Zia64zwin-ia64c@sveZdZdZddZeeZddZeeZddZeeZdd Ze eZd S) Regz2Helper class to read values from the registry cCsMx:tD]2}|j||}|r||kr||SqWt|dS)N)HKEYS read_valuesKeyError)clspathkeybasedrz$(FrameworkVersion)) r@r;NET_BASErr WINSDK_BASErrrr rrr9)r=r>prhrrrrrr<s.       zMacroExpander.load_macroscCs6x/|jjD]\}}|j||}qW|S)N)r9itemsreplace)r=r1r%vrrrsubszMacroExpander.subN)r2r3r4r?r@r<rIrrrrr8{s    r8cCsd}tjj|}|d kr(dS|t|}tj|djdd\}}t|dd d}t|ddd}|dkrd }n|dkr||SdS) zReturn 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. zMSC v.rN r g$@r)sysr>findlensplitint)prefixr$r1restZ majorVersionZ minorVersionrrrget_build_versions %   rVcCsIg}x<|D]4}tjj|}||kr |j|q q W|S)znReturn a list of normalized paths with duplicates removed. The current order of paths is maintained. )osrnormpathr!)pathsZ reduced_pathsrDZnprrrnormalize_and_reduce_pathss   rZcCs[|jtj}g}x*|D]"}||kr|j|qqWtjj|}|S)z8Remove duplicate values of an environment variable. )rRrWpathsepr!join)ZvariableZoldListZnewListr$Z newVariablerrrremoveDuplicatess  r]c Csat|}ytjd|d}Wn%tk rKtjdd}YnX| sftjj| rd|}tj j |d}|rtjj|rtjj |tj tj d}tjj |}tjj|s tjd|dSqtjd|n|s%tjd dStjj |d }tjj|rP|Stjd dS) zFind 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. z %s\Setup\VCrAz%Unable to find productdir in registryNzVS%0.f0COMNTOOLSZVCz%s is not a valid directoryz Env var %s is not set or invalidzNo productdir foundz vcvarsall.batzUnable to find vcvarsall.bat)r:rrrr debugrWrisdirenvirongetr\pardirabspathisfile)r>r;rAZtoolskeyZtoolsdir vcvarsallrrrfind_vcvarsalls2       !  rfc Cst|}td}i}|dkr9tdntjd||tjd||fd tjd tj}z|j\}}|j d krt|j d n|j d }x|j d D]}t j |}d|krqn|j}|j dd\} } | j} | |kr| jtjr]| dd} nt| || ZarchreZ interestingresultpopenrjrklinerr+rrrquery_vcvarsalls<          !r}g @z(VC %0.1f is not supported by this modulec @seZdZdZdZiZdgZdddgZdgZdgZ eeee Z d Z d Z d Z d Zd ZZdZdddddZdddZddddZdddddddddZdddddZdddddddddddd ZddZd d!Zd"d#Zd$d%Zd&d'Zd(d)Zdd*d+Zd,d-ZdS). 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.exercCsPtj||||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?Gs     zMSVCCompiler.__init__NcCs|j std|dkr.t}nd%}||krVtd|fndtjkrdtjkr|jdrd|_d |_d |_ d |_ d |_ n|tks|dkrt |}nt td t |}t t|}|djtj|_|dtjd<|dtjd|)rz*\s*zI|)w) openreadrurerDOTALLrIsearchwriteOSError)r=Z manifest_fileZ manifest_fZ manifest_bufpatternrrrrs.      z!MSVCCompiler._remove_visual_c_refcCsd|S)Nz /LIBPATH:r)r=dirrrrlibrary_dir_optionszMSVCCompiler.library_dir_optioncCstddS)NzsP    (        >.   #)