a „oeìuã@sLdZddlZddlZddlZddlZddlZddlmZmZm Z m Z m Z ddl m Z mZddlmZddlmZddlZe de¡ejZejZejZejZejejej ej!fZ"ej#d koÂej$d kZ%e%rÖd Z&d Z'd Z(n dZ&dZ'dZ(dddœZ)Gdd„dƒZ*Gdd„dƒZ+dd„Z,dd„Z-dd„Z.dd„Z/d$d d!„Z0e,ƒZ1Gd"d#„d#e ƒZ2dS)%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é)ÚDistutilsExecErrorÚDistutilsPlatformErrorÚ CompileErrorÚLibErrorÚ LinkError)Ú CCompilerÚgen_lib_options)Úlog)Ú get_platformz™msvc9compiler is deprecated and slated to be removed in the future. Please discontinue use or file an issue with pypa/distutils describing your use case.Úwin32lz1Software\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\.NETFrameworkÚx86Zamd64©r z win-amd64c@sPeZdZdZdd„ZeeƒZdd„ZeeƒZdd„ZeeƒZdd „Ze eƒZd S) ÚRegz-Helper class to read values from the registrycCs:tD](}| ||¡}|r||vr||Sqt|ƒ‚dS©N)ÚHKEYSÚ read_valuesÚKeyError)ÚclsÚpathÚkeyÚbaseÚd©rúDC:\Program Files\Certbot\pkgs\setuptools\_distutils\msvc9compiler.pyÚ get_valueNs   z Reg.get_valuecCsjzt||ƒ}Wnty"YdS0g}d}zt||ƒ}WntyPYqfYn0| |¡|d7}q,|S)zReturn list of registry keys.Nrr)Ú RegOpenKeyExÚRegErrorÚ RegEnumKeyÚappend)rrrÚhandleÚLÚiÚkrrrÚ read_keysWs     z Reg.read_keysc Cs‚zt||ƒ}Wnty"YdS0i}d}zt||ƒ\}}}WntyVYq~Yn0| ¡}| |¡|| |¡<|d7}q,|S)z`Return dict of registry keys and values. All names are converted to lowercase. Nrr)rrÚ RegEnumValueÚlowerÚ convert_mbcs) rrrr rr"ÚnameÚvalueÚtyperrrrjs    zReg.read_valuescCs8t|ddƒ}|dur4z |dƒ}Wnty2Yn0|S)NÚdecodeÚmbcs)ÚgetattrÚ UnicodeError)ÚsZdecrrrr's   zReg.convert_mbcsN) Ú__name__Ú __module__Ú __qualname__Ú__doc__rÚ classmethodr$rr'Ú staticmethodrrrrrKs rc@s,eZdZdd„Zdd„Zdd„Zdd„Zd S) Ú MacroExpandercCsi|_t||_| |¡dSr)ÚmacrosÚVS_BASEÚvsbaseÚ load_macros)ÚselfÚversionrrrÚ__init__Žs zMacroExpander.__init__cCst ||¡|jd|<dS)Nz$(%s))rrr7)r;ZmacrorrrrrÚ set_macro“szMacroExpander.set_macroc Cs| d|jdd¡| d|jdd¡| dtd¡z$|dkrP| d td ¡ntd ƒ‚Wntyttd ƒ‚Yn0|d krž| d |jd¡| dtd¡n`d}tD]V}zt||ƒ}WntyÎYq¦Yn0t |dƒ}t   |d  ||¡¡}|d|j d<q¦dS)NZ VCInstallDirz \Setup\VCÚ productdirZ VSInstallDirz \Setup\VSZ FrameworkDirZ installrootç @ZFrameworkSDKDirzsdkinstallrootv2.0aPython 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"@ZFrameworkVersionz clr versionZ WindowsSdkDirZcurrentinstallfolderz.Software\Microsoft\NET Framework Setup\Productrz{}\{}r<z$(FrameworkVersion))r>r9ÚNET_BASErrÚ WINSDK_BASErrrrrrÚformatr7)r;r<ÚprÚhrrrrrr:–s.  ÿ    zMacroExpander.load_macroscCs$|j ¡D]\}}| ||¡}q |Sr)r7ÚitemsÚreplace)r;r/r#ÚvrrrÚsubµszMacroExpander.subN)r0r1r2r=r>r:rIrrrrr6sr6cCsšd}tj |¡}|dkrdS|t|ƒ}tj|d… dd¡\}}t|dd…ƒd}|dkrf|d7}t|d d …ƒd }|dkr†d }|dkr–||SdS) zÃ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. zMSC v.éÿÿÿÿéNú réþÿÿÿé éég$@r)Úsysr<ÚfindÚlenÚsplitÚint)Úprefixr"r/ÚrestZ majorVersionZ minorVersionrrrÚget_build_version»s  rXcCs0g}|D]"}tj |¡}||vr| |¡q|S)znReturn a list of normalized paths with duplicates removed. The current order of paths is maintained. )ÚosrÚnormpathr)ÚpathsZ reduced_pathsrDZnprrrÚnormalize_and_reduce_pathsÕs   r\cCs<| tj¡}g}|D]}||vr| |¡qtj |¡}|S)z3Remove duplicate values of an environment variable.)rTrYÚpathseprÚjoin)ÚvariableZoldListZnewListr"Z newVariablerrrÚremoveDuplicatesäs   r`cCst|}zt d|d¡}Wn ty<t d¡d}Yn0|rNtj |¡sÄd|}tj   |d¡}|r¶tj |¡r¶tj  |tj tj d¡}tj  |¡}tj |¡sÄt d|¡dSnt d|¡|sÖt d ¡dStj  |d ¡}tj |¡rô|St d ¡dS) z¨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. z %s\Setup\VCr?z%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.batúUnable to find vcvarsall.bat)r8rrrr ÚdebugrYrÚisdirÚenvironÚgetr^ÚpardirÚabspathÚisfile)r<r9r?ZtoolskeyZtoolsdirÚ vcvarsallrrrÚfind_vcvarsallïs0        rjc CsHt|ƒ}hd£}i}|dur$tdƒ‚t d||¡tjd ||¡tjtjd}z¸| ¡\}}|  ¡dkrvt|  d¡ƒ‚|  d¡}|  d ¡D]d}t   |¡}d |vr¢qŠ| ¡}|  d d ¡\} } |  ¡} | |vrŠ|  tj¡râ| dd …} t| ƒ|| <qŠW|j ¡|j ¡n|j ¡|j ¡0t|ƒt|ƒkrDttt| ¡ƒƒƒ‚|S) z?Launch vcvarsall.bat and read the settings from its environment>ÚincludeZlibpathrÚlibNraz'Calling 'vcvarsall.bat %s' (version=%s)z "{}" {} & set)ÚstdoutÚstderrrr,Ú ú=rrJ)rjrr rbÚ subprocessÚPopenrCÚPIPEZ communicateÚwaitr+rTrr'Ústripr&ÚendswithrYr]r`rmÚclosernrSÚ ValueErrorÚstrÚlistÚkeys) r<ZarchriZ interestingÚresultÚpopenrmrnÚlinerr)rrrÚquery_vcvarsallsD ý        ÿ  rc säeZdZdZdZiZdgZgd¢ZdgZdgZ eeee Z dZ dZ d Z d Zd ZZd Zd,‡fdd„ Zd-dd„Zd.dd„Zd/dd„Zd0dd„Zd1dd„Zdd„Zdd„Zd d!„Zd"d#„Zd$d%„Zd&d'„Zd2d(d)„Zd*d+„Z‡Z S)3Ú MSVCCompilerztConcrete class that implements an interface to Microsoft Visual C++, as defined by the CCompiler abstract class.Zmsvcz.c)z.ccz.cppz.cxxú.rcz.mcz.resz.objz.libz.dllz%s%sz.exercs8tƒ |||¡t|_d|_g|_d|_d|_d|_dS)NzSoftware\Microsoft\VisualStudioF) Úsuperr=ÚVERSIONÚ_MSVCCompiler__versionZ_MSVCCompiler__rootÚ_MSVCCompiler__pathsÚ plat_nameÚ_MSVCCompiler__archÚ initialized)r;ÚverboseÚdry_runÚforce©Ú __class__rrr=^szMSVCCompiler.__init__NcCs|jrJdƒ‚|jdkr&td|jƒ‚|dur4tƒ}d}||vrNtd |¡ƒ‚dtjvrŒdtjvrŒ| d¡rŒd|_d |_ d |_ d |_ d |_ nÀ|tƒd fvr¤t |}nt tƒdt |}tt|ƒ}|d tj¡|_|dtjd<|dtjd<t|jƒdkrtd|jƒ‚| d¡|_| d ¡|_ | d ¡|_ | d ¡|_ | d ¡|_ z(tjd d¡D]}|j |¡q^WntyˆYn0t|jƒ|_d |j¡tjd<d|_|jdkrÐgd¢|_gd¢|_ngd¢|_gd¢|_gd¢|_|jdkrgd¢|_dg|_d|_dS)Nzdon't init multiple timesr@z(VC %0.1f is not supported by this modulerz--plat-name must be one of {}ZDISTUTILS_USE_SDKZMSSdkzcl.exezlink.exezlib.exezrc.exezmc.exer Ú_rrlrkrzxPython was built with %s, and extensions need to be built with the same version of the compiler, but it isn't installed.ú;r )ú/nologoú/O2ú/MDú/W3ú/DNDEBUG)rú/Odú/MDdr“ú/Z7ú/D_DEBUG)rr‘r’r“ú/GS-r”)rr•r–r“r™r—r˜)ú/DLLrz/INCREMENTAL:NOé)ršrz/INCREMENTAL:noz/DEBUGrT) rˆr„rr rCrYrdÚfind_exeÚccÚlinkerrlÚrcÚmcÚPLAT_TO_VCVARSrrƒrTr]r…rSZ_MSVCCompiler__productrrr\r^Zpreprocess_optionsr‡Úcompile_optionsÚcompile_options_debugÚldflags_sharedÚldflags_shared_debugZldflags_static)r;r†Zok_platsZ plat_specZvc_envrDrrrÚ initializeisx ÿÿÿþý ÿ þÿ            zMSVCCompiler.initializeÚcCsÞ|dur d}g}|D]Ä}tj |¡\}}tj |¡d}|tj |¡d…}||jvrbtd|ƒ‚|rrtj |¡}||jvr˜|  tj  |||j ¡¡q||j vr¾|  tj  |||j ¡¡q|  tj  |||j ¡¡q|S)Nr§rzDon't know how to compile %s)rYrÚsplitextÚ splitdriveÚisabsÚsrc_extensionsrÚbasenameÚ_rc_extensionsrr^Ú res_extensionÚ_mc_extensionsÚ obj_extension)r;Zsource_filenamesZ strip_dirÚ output_dirZ obj_namesZsrc_namerÚextrrrÚobject_filenamesÒs"     zMSVCCompiler.object_filenamesc  Cst|js| ¡| ||||||¡} | \}} }} } |p6g} |  d¡|rT|  |j¡n |  |j¡| D]}z| |\}}WntyYqdYn0|r¢tj   |¡}||j vr¸d|}nX||j vrÎd|}nB||j vr<|}d|}z"| |jg| |g|g¡Wqdty6}zt|ƒ‚WYd}~qdd}~00qdnÔ||jvrtj  |¡}tj  |¡}zl| |jgd|d|g|g¡tj  tj  |¡¡\}}tj  ||d¡}| |jgd|g|g¡Wqdtyú}zt|ƒ‚WYd}~qdd}~00qdntd ||¡ƒ‚d |}z&| |jg| | ||g|¡Wqdtyl}zt|ƒ‚WYd}~qdd}~00qd| S) Nz/cz/Tcz/Tpz/foz-hz-rrz"Don't know how to compile {} to {}z/Fo)rˆr¦Z_setup_compilerÚextendr£r¢rrYrrgÚ _c_extensionsÚ_cpp_extensionsr­ÚspawnrŸrrr¯Údirnamer r¨r¬r^rCr)r;Zsourcesr±r7Z include_dirsrbÚ extra_preargsÚextra_postargsZdependsZ compile_infoÚobjectsZpp_optsÚbuildZ compile_optsÚobjÚsrcr²Z input_optZ output_optÚmsgZh_dirZrc_dirrrŽZrc_filerrrÚcompileësx  ÿ           "   " ÿÿþýüÿ zMSVCCompiler.compilec Cs |js| ¡| ||¡\}}|j||d}| ||¡r|d|g}|rJz| |jg|¡WqœtyŒ}zt|ƒ‚WYd}~qœd}~00n t   d|¡dS)N)r±ú/OUT:úskipping %s (up-to-date)) rˆr¦Ú_fix_object_argsÚlibrary_filenameÚ _need_linkr·rlrrr rb) r;r»Zoutput_libnamer±rbÚ target_langÚoutput_filenameZlib_argsr¿rrrÚcreate_static_libIs  zMSVCCompiler.create_static_libc CsX|js| ¡| ||¡\}}| |||¡}|\}}}|rL| dt|ƒ¡t||||ƒ}|durptj  ||¡}|  ||¡rH|t j kr¬| rœ|j dd…}q¾|jdd…}n| r¸|j }n|j}g}|pÈgD]}| d|¡qÊ||||d|g}tj |d¡} |durLtj tj |¡¡\}}tj  | | |¡¡}| d|¡| || |¡| rl| |dd…<| r|| | ¡| tj |¡¡z| |jg|¡Wn.tyÒ}zt|ƒ‚WYd}~n d}~00| ||¡}|durT|\}}d ||¡}z| dd d ||g¡Wn.tyD}zt|ƒ‚WYd}~n d}~00n t d |¡dS) Nz5I don't know what to do with 'runtime_library_dirs': rz/EXPORT:rÁrz/IMPLIB:z-outputresource:{};{}zmt.exez-nologoz -manifestrÂ)rˆr¦rÃZ _fix_lib_argsÚwarnryr rYrr^rÅrÚ EXECUTABLEr¥r¤rr¸r¨r¬rÄÚmanifest_setup_ldargsr´Zmkpathr·ržrrÚmanifest_get_embed_inforCr rb)r;Ú target_descr»rÇr±Z librariesZ library_dirsZruntime_library_dirsZexport_symbolsrbr¹rºÚ build_temprÆZ fixed_argsZlib_optsZldflagsZ export_optsZsymÚld_argsZdll_nameZdll_extZ implib_filer¿ZmfinfoZ mffilenameÚmfidZout_argrrrÚlink\sj ÿÿ  ÿ   ÿ      zMSVCCompiler.linkcCs,tj |tj |¡d¡}| d|¡dS)Nz .manifestú/MANIFESTFILE:)rYrr^r¬r)r;rÇrÎrÏÚ temp_manifestrrrr˺sÿz"MSVCCompiler.manifest_setup_ldargscCs^|D]"}| d¡r| dd¡d}q,qdS|tjkr|)r§z*\s*zI|)Úw) ÚopenÚreadrwÚrerÀÚDOTALLrIÚsearchÚwriteÚOSError)r;Z manifest_fileZ manifest_fZ manifest_bufÚpatternrrrrÖÞs6  ýý  þ z!MSVCCompiler._remove_visual_c_refcCsd|S)Nz /LIBPATH:r©r;ÚdirrrrÚlibrary_dir_option szMSVCCompiler.library_dir_optioncCs tdƒ‚dS)NzsV  üüþB. # +