B ²µ7›Aâ»ã@sRdZddlZddlZddlZddlZddlmZmZmZm Z m Z ddl m Z m Z mZddlmZddlmZddlZejZejZejZejZejejejejfZ ej!dko²ej"dkZ#e#rÆd Z$d Z%d Z&n d Z$d Z%dZ&dddœZ'Gdd„dƒZ(Gdd„dƒZ)dd„Z*dd„Z+dd„Z,dd„Z-d$dd„Z.e*ƒZ/e/d kr>ed!e/ƒ‚Gd"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)ÚDistutilsExecErrorÚDistutilsPlatformErrorÚ CompileErrorÚLibErrorÚ LinkError)Ú CCompilerÚgen_preprocess_optionsÚgen_lib_options)Úlog)Ú get_platformÚ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) ÚRegz2Helper class to read values from the registry cCs:x,tD]$}| ||¡}|r||kr||SqWt|ƒ‚dS)N)ÚHKEYSÚ read_valuesÚKeyError)ÚclsÚpathÚkeyÚbaseÚd©rú:/opt/alt/python37/lib/python3.7/distutils/msvc9compiler.pyÚ get_value@s     z Reg.get_valuecCsnyt||ƒ}Wntk r"dSXg}d}xt d¡d}YnX|rPtj |¡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.batzUnable to find vcvarsall.bat)r7rrrr ÚdebugrVrÚisdirÚenvironÚgetr[ÚpardirÚabspathÚisfile)r;r8r>ZtoolskeyZtoolsdirÚ vcvarsallrrrÚfind_vcvarsallÚs2         rec Cs<t|ƒ}ddddh}i}|dkr(tdƒ‚t d||¡tjd||ftjtjd }z¨| ¡\}}| ¡d krzt|  d ¡ƒ‚|  d ¡}xr|  d ¡D]d}t   |¡}d |kr¨q|  ¡}|  d d¡\} } |  ¡} | |kr|  tj¡rè| dd…} t| ƒ|| <qWWd|j ¡|j ¡Xt|ƒt|ƒkr8ttt| ¡ƒƒƒ‚|S)zDLaunch vcvarsall.bat and read the settings from its environment ÚincludeÚlibZlibpathrNzUnable to find vcvarsall.batz'Calling 'vcvarsall.bat %s' (version=%s)z "%s" %s & set)ÚstdoutÚstderrrr+Ú ú=rrG)rerr r]Ú subprocessÚPopenÚPIPEZ communicateÚwaitr*rQrr&Ústripr%ÚendswithrVrZr\rhÚcloserirPÚ ValueErrorÚstrÚlistÚkeys) r;ZarchrdZ interestingÚresultÚpopenrhriÚlinerr(rrrÚquery_vcvarsallýs<          rzg @z(VC %0.1f is not supported by this modulec @sÞeZdZdZdZiZdgZdddgZdgZdgZ eeee Z d Z d Z d Z d Zd ZZdZd.dd„Zd/dd„Zd0dd„Zd1dd„Zd2dd„Zd3dd„Zdd„Zd d!„Zd"d#„Zd$d%„Zd&d'„Zd(d)„Zd4d*d+„Zd,d-„ZdS)5Ú 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.exercCs8t ||||¡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<IszMSVCCompiler.__init__NcCs|dkrtƒ}d}||kr(td|fƒ‚dtjkrfdtjkrf| d¡rfd|_d|_d|_d|_d |_ nÂ|tƒksx|d kr‚t |}nt tƒd t |}t t |ƒ}|d   tj¡|_|d tjd <|dtjd<t|jƒdkrìtd|jƒ‚| d¡|_| d¡|_| d¡|_| d¡|_| d ¡|_ y,x&tjd   d¡D]}|j |¡q||j kr>|}d|}y"| |jg| |g|g¡Wqhtk r8}z t|ƒ‚Wdd}~XYqhXqhnÒ||jkrtj  |¡}tj  |¡}yl| |jgd|d|g|g¡tj  tj  |¡¡\}}tj  ||d¡}| |jgd|g|g¡Wqhtk rú}z t|ƒ‚Wdd}~XYqhXqhntd||fƒ‚d |}y&| |jg| | ||g|¡Wqhtk rj}z t|ƒ‚Wdd}~XYqhXqhW| S) Nz/cz/Tcz/Tpz/foz-hz-rz.rcz"Don't know how to compile %s to %sz/Fo)rrZ_setup_compilerÚextendrrŒrrVrrbÚ _c_extensionsÚ_cpp_extensionsr—Úspawnr‰rrr™ÚdirnamerŠr’r–r[r‡)r:Zsourcesr›r6Z include_dirsr]Ú extra_preargsÚextra_postargsZdependsZ compile_infoÚobjectsZpp_optsZbuildZ compile_optsÚobjÚsrcrœZ input_optZ output_optÚmsgZh_dirZrc_dirrrƒZrc_filerrrÚcompileÈsj              zMSVCCompiler.compilec Csž|js| ¡| ||¡\}}|j||d}| ||¡rŽ|d|g}|rJy| |jg|¡Wqštk rŠ}z t|ƒ‚Wdd}~XYqšXn t   d|¡dS)N)r›z/OUT:zskipping %s (up-to-date)) rrÚ_fix_object_argsÚlibrary_filenameÚ _need_linkr¡rgrrr r]) r:r¥Zoutput_libnamer›r]Ú target_langÚoutput_filenameZlib_argsr¨rrrÚcreate_static_libs zMSVCCompiler.create_static_libc CsX|js| ¡| ||¡\}}| |||¡}|\}}}|rL| dt|ƒ¡t||||ƒ}|dk rptj  ||¡}|  ||¡rH|t j kr¬| rœ|j dd…}q¾|jdd…}n| r¸|j }n|j}g}x|pÊgD]}| d|¡qÌW||||d|g}tj |d¡} |dk rPtj tj |¡¡\}}tj  | | |¡¡}| d|¡| || |¡| rp| |dd…<| r€| | ¡| tj |¡¡y| |jg|¡Wn,tk rÔ}z t|ƒ‚Wdd}~XYnX| ||¡}|dk rT|\}}d||f}y| dd d ||g¡Wn,tk rD}z t|ƒ‚Wdd}~XYnXn t d |¡dS) Nz5I don't know what to do with 'runtime_library_dirs': rz/EXPORT:z/OUT:rz/IMPLIB:z-outputresource:%s;%szmt.exez-nologoz -manifestzskipping %s (up-to-date))rrrªZ _fix_lib_argsÚwarnrtr rVrr[r¬rÚ EXECUTABLErrŽrr¢r’r–r«Úmanifest_setup_ldargsržZmkpathr¡rˆrrÚmanifest_get_embed_infor r])r:Ú target_descr¥r®r›Z librariesZ library_dirsZruntime_library_dirsZexport_symbolsr]r£r¤Ú build_tempr­Z fixed_argsZlib_optsZldflagsZ export_optsZsymÚld_argsZdll_nameZdll_extZ implib_filer¨ZmfinfoZ mffilenameÚmfidZout_argrrrÚlink6sl           zMSVCCompiler.linkcCs,tj |tj |¡d¡}| d|¡dS)Nz .manifestz/MANIFESTFILE:)rVrr[r–r)r:r®rµr¶Ú temp_manifestrrrr²•sz"MSVCCompiler.manifest_setup_ldargscCs`x,|D] }| d¡r| dd¡d}PqWdS|tjkr>d}nd}| |¡}|dkrXdS||fS)Nz/MANIFESTFILE:ú:rrL)Ú startswithrQrr±Ú_remove_visual_c_ref)r:r´r¶Úargr¹r·rrrr³¡s    z$MSVCCompiler.manifest_get_embed_infocCs²y˜t|ƒ}z | ¡}Wd| ¡Xt dtj¡}t |d|¡}d}t |d|¡}t dtj¡}t ||¡dkrrdSt|dƒ}z| |¡|S| ¡XWnt k r¬YnXdS)NzU|)r‘z*\s*zI|)Úw) ÚopenÚreadrrÚrer©ÚDOTALLrFÚsearchÚwriteÚOSError)r:Z manifest_fileZ manifest_fZ manifest_bufÚpatternrrrr¼¹s.     z!MSVCCompiler._remove_visual_c_refcCsd|S)Nz /LIBPATH:r)r:ÚdirrrrÚlibrary_dir_optionäszMSVCCompiler.library_dir_optioncCs tdƒ‚dS)Nztjd d¡D]*}tj tj |¡|¡}tj |¡rH|SqHW|S)aŒ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'. ZPathr„)r~rVrr[rbrcr_rQ)r:ZexerAÚfnrrrr†s   zMSVCCompiler.find_exe)rrr)N)rr‘)NNNrNNN)NrN) NNNNNrNNNN)r) r/r0r1r2Z compiler_typeZ executablesrŸr r—r™r•r˜ršZstatic_lib_extensionZshared_lib_extensionZstatic_lib_formatZshared_lib_formatZ exe_extensionr<rrr©r¯r¸r²r³r¼rÈrÉrÊrÍr†rrrrr{+sR  W  V  R + r{)r )1r2rVrlrNrÁZdistutils.errorsrrrrrZdistutils.ccompilerrrr Z distutilsr Zdistutils.utilr ÚwinregZ OpenKeyExrZEnumKeyrZ EnumValuer$ÚerrorrZ HKEY_USERSÚHKEY_CURRENT_USERÚHKEY_LOCAL_MACHINEZHKEY_CLASSES_ROOTrÚplatformÚmaxsizeZ NATIVE_WIN64r7r@r?r‹rr5rUrYr\rerzr|r{rrrrÚsL  >. # )