7ec@sdZdZddlZddlZddlZddlmZmZmZm Z m Z ddl m Z m Z ddlmZdZy@ddlZdZeZejZejZejZejZWn~ek rDyLddlZddlZdZeZejZejZejZejZWnek r@ejd nXnXerlejej ej!ej"fZ#nd Z$d Z%d Z&d fdYZ'dZ(dZ)dZ*de fdYZ+e(dkrej,de+Z-ddl.m+Z+ddl.m'Z'ndS(sdistutils.msvccompiler Contains MSVCCompiler, an implementation of the abstract CCompiler class for the Microsoft Visual Studio. s$Id$iN(tDistutilsExecErrortDistutilsPlatformErrort CompileErrortLibErrort LinkError(t CCompilertgen_lib_options(tlogiisWarning: 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}xCyt||}Wntk r^PnX|j||d}q7W|S(sReturn list of registry keys.iiN(t RegOpenKeyExtRegErrortNonet RegEnumKeytappend(tbasetkeythandletLtitk((s./usr/lib64/python2.7/distutils/msvccompiler.pyt read_keys;s   cCsyt||}Wntk r'dSXi}d}xayt||\}}}Wntk rgPnX|j}t||t|<|d}q7W|S(sXReturn dict of registry keys and values. All names are converted to lowercase. iiN(RR R t RegEnumValuetlowert convert_mbcs(R RRtdRtnametvaluettype((s./usr/lib64/python2.7/distutils/msvccompiler.pyt read_valuesMs   cCsIt|dd}|dk rEy|d}WqEtk rAqEXn|S(Ntencodetmbcs(tgetattrR t UnicodeError(tstenc((s./usr/lib64/python2.7/distutils/msvccompiler.pyRbs  t MacroExpandercBs,eZdZdZdZdZRS(cCsi|_|j|dS(N(tmacrost load_macros(tselftversion((s./usr/lib64/python2.7/distutils/msvccompiler.pyt__init__ms cCsCx<tD]4}t||}|r|||jd||dkrd}ng}x|D]}tjj|\}}tjj|d}|tjj|}||jkrtd|n|rtjj|}n||j kr|j tjj |||j q"||j kr|j tjj |||j q"|j tjj |||jq"W|S(NRwisDon't know how to compile %s(R RNR*tsplitextt splitdrivetisabstsrc_extensionsRtbasenamet_rc_extensionsR Rnt res_extensiont_mc_extensionst obj_extension(R%tsource_filenamest strip_dirt output_dirt obj_namestsrc_nameR text((s./usr/lib64/python2.7/distutils/msvccompiler.pytobject_filenames<s(  c Cs|js|jn|j||||||\}} }} } |pLg} | jd|ru| j|jn| j|jxM| D]E} y| | \}}Wntk rqnX|rtj j |}n||j krd|}n||j krd|}nk||j kr}|}d| }y)|j|jg| |g|gWqtk rv}t|qXqn||jkretj j|}tj j| }y|j|jgd|d|g|gtj jtj j|\}}tj j||d}|j|jgd| g|gWqtk r^}t|qXqntd|| fd | }y-|j|jg| | ||g|Wqtk r}t|qXqW| S( Ns/cs/Tcs/Tps/fos-hs-rs.rcs"Don't know how to compile %s to %ss/Fo(R\Rvt_setup_compileR textendRqRpR3RNR*tabspatht _c_extensionst_cpp_extensionsR}tspawnRjRRRtdirnameRkRxR|RnRh(R%tsourcesRR#t include_dirstdebugt extra_preargstextra_postargstdependstobjectstpp_optstbuildt compile_optstobjtsrcRt input_optt output_opttmsgth_dirtrc_dirR t_trc_file((s./usr/lib64/python2.7/distutils/msvccompiler.pytcompile]sj        # $$#   c Cs|js|jn|j||\}}|j|d|}|j||r|d|g}|rony|j|jg|Wqtk r}t|qXnt j d|dS(NRs/OUT:sskipping %s (up-to-date)( R\Rvt_fix_object_argstlibrary_filenamet _need_linkRRbRRRR( R%Rtoutput_libnameRRt target_langtoutput_filenametlib_argsR((s./usr/lib64/python2.7/distutils/msvccompiler.pytcreate_static_libs cCsW|js|jn|j||\}}|j|||\}}}|rl|jdt|nt||||}|dk rtj j ||}n|j ||rC|t j kr| r|jd}q|jd}n| r|j}n |j}g}x%|pgD]}|jd|qW||||d|g}|dk rtj 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\RvRt _fix_lib_argstwarntstrRR RNR*RnRRt EXECUTABLERsRrR RxR|RRRtmkpathRRiRRRR(R%t target_descRRRt librariest library_dirstruntime_library_dirstexport_symbolsRRRt build_tempRtlib_optstldflagst export_optstsymtld_argstdll_nametdll_extt implib_fileR((s./usr/lib64/python2.7/distutils/msvccompiler.pytlinksR          cCsd|S(Ns /LIBPATH:((R%tdir((s./usr/lib64/python2.7/distutils/msvccompiler.pytlibrary_dir_option$scCs tddS(Ns<don't know how to set runtime library search path for MSVC++(R(R%R((s./usr/lib64/python2.7/distutils/msvccompiler.pytruntime_library_dir_option'scCs |j|S(N(R(R%Rb((s./usr/lib64/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*RnRtexistsR (R%tdirsRbRt try_namesRRtlibfile((s./usr/lib64/python2.7/distutils/msvccompiler.pytfind_library_file/s    cCsxH|jD]=}tjjtjj||}tjj|r |Sq WxXtjtjddD]=}tjjtjj||}tjj|re|SqeW|S(sReturn 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*RnRtisfileR9RCRf(R%texeR6tfn((s./usr/lib64/python2.7/distutils/msvccompiler.pyRgCs ! !tx86cCsts gS|d}|jdkr<d|j|jf}nd|j|f}xitD]a}t||}|rV|jdkrtj|jj||dStj||dSqVqVW|jdkr x>tD]3}t|d|jd k r|j dPqqWngS( sGet 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.0sIt 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./usr/lib64/python2.7/distutils/msvccompiler.pyRlZs(      cCsS|dkr|jd}n|j|}|rOtj|dtj|t__doc__t compiler_typet executablesRRR}RR{R~Rtstatic_lib_extensiontshared_lib_extensiontstatic_lib_formattshared_lib_formatt exe_extensionR'RvRR RRRRRRRRgRlRm(((s./usr/lib64/python2.7/distutils/msvccompiler.pyRTsP     B  Z  G      %g @s3Importing new compiler from distutils.msvc9compiler(RT(R"(/Rt __revision__RARNR9tdistutils.errorsRRRRRtdistutils.ccompilerRRt distutilsRRt_winregthkey_modt OpenKeyExRtEnumKeyR t EnumValueRterrorR t ImportErrortwin32apitwin32continfot HKEY_USERStHKEY_CURRENT_USERtHKEY_LOCAL_MACHINEtHKEY_CLASSES_ROOTR(RRRR"RIRMRSRTRtOldMSVCCompilertdistutils.msvc9compiler(((s./usr/lib64/python2.7/distutils/msvccompiler.pyts`   (                 .