ž |yMa}@c@sadZddlZddlZddlZddlmZmZmZddlZddl m Z m Z ddl m Z ddlmZddlmZmZmZddlmZdd lmZdd lmZd d „ZGd d„de ƒZGdd„deƒZdZdZdZdd„Z ej!dƒZ"dd„Z#dd„Z$dd„Z%dS(udistutils.cygwinccompiler Provides the CygwinCCompiler class, a subclass of UnixCCompiler that handles the Cygwin port of the GNU C compiler to Windows. It also contains the Mingw32CCompiler class which handles the mingw32 port of GCC (same as cygwin in no-cygwin mode). iN(uPopenuPIPEu check_output(ugen_preprocess_optionsugen_lib_options(u UnixCCompiler(u write_file(uDistutilsExecErroru CompileErroruUnknownFileError(ulog(u LooseVersion(ufind_executablecCs¯tjjdƒ}|dkr«tj|d|d…}|dkrLdgS|dkr_dgS|d krrd gS|d kr…d gS|d kr˜dgStd|ƒ‚ndS(uaInclude the appropriate MSVC runtime library if Python was built with MSVC 7.0 or later. uMSC v.iii u1300umsvcr70u1310umsvcr71u1400umsvcr80u1500umsvcr90u1600umsvcr100uUnknown MS Compiler version %s Niÿÿÿÿ(usysuversionufindu ValueError(umsc_posumsc_ver((u>/opt/alt/python33/lib64/python3.3/distutils/cygwinccompiler.pyu get_msvcr>s      u get_msvcrc Bs¡|EeZdZdZdZdZdZdZdZdZ dZ d d d d d „Z d d „Z dddddd dddddd„ Zd ddd„ZdS(uCygwinCCompileru? Handles the Cygwin port of the GNU C compiler to Windows. ucygwinu.ou.au.dllulib%s%su%s%su.exeic CsStj||||ƒtƒ\}}|jd||fƒ|tk r\|jd|ƒntƒ\|_|_|_ |j|j d|j|j|j fƒ|jdkr¼d|_ n d|_ |jdkrÝd}nd }|j d d d d dddddd|j |fƒ|jdkrCdg|_ |jdƒn tƒ|_ dS(Nu%Python's GCC status: %s (details: %s)uƒPython's pyconfig.h doesn't seem to support your compiler. Reason: %s. Compiling may fail because of undefined preprocessor macros.u: gcc %s, ld %s, dllwrap %s u2.10.90ugccudllwrapu2.13u-sharedu -mdll -staticucompilerugcc -mcygwin -O -Wallu compiler_sougcc -mcygwin -mdll -O -Wallu compiler_cxxug++ -mcygwin -O -Wallu linker_exeu gcc -mcygwinu linker_sou%s -mcygwin %su2.91.57umsvcrtu,Consider upgrading to a newer version of gcc(u UnixCCompileru__init__ucheck_config_hu debug_printu CONFIG_H_OKuwarnu get_versionsu gcc_versionu ld_versionudllwrap_versionu compiler_typeu linker_dlluset_executablesu dll_librariesu get_msvcr(uselfuverboseudry_runuforceustatusudetailsu shared_option((u>/opt/alt/python33/lib64/python3.3/distutils/cygwinccompiler.pyu__init__cs<        uCygwinCCompiler.__init__cCsÐ|dks|dkroy |jdd|d|gƒWqÌtk rk}zt|ƒ‚WYdd}~XqÌXn]y)|j|j||d|g|ƒWn1tk rË}zt|ƒ‚WYdd}~XnXdS(u:Compiles the source by spawning GCC and windres if needed.u.rcu.resuwindresu-iu-oN(uspawnuDistutilsExecErroru CompileErroru compiler_so(uselfuobjusrcuextucc_argsuextra_postargsupp_optsumsg((u>/opt/alt/python33/lib64/python3.3/distutils/cygwinccompiler.pyu_compiležs " uCygwinCCompiler._compilecCsÖtj| pgƒ} tj|p$gƒ}tj|p9gƒ}|j|jƒ|d k rˆ||jksy|jdkrˆtjj|dƒ}tjj tjj |ƒƒ\}}tjj ||dƒ}tjj |d|dƒ}dtjj |ƒdg}x|D]}|j |ƒq W|j t||fd|ƒ|jd krx| jd |gƒ| jd |gƒqˆ|j |ƒn| sž| j d ƒntj||||||||d | | | | | ƒd S(uLink the objects.ugcciu.defulibu.au LIBRARY %suEXPORTSu writing %sudllwrapu --output-libu--defu-sN(ucopyuextendu dll_librariesuNoneu EXECUTABLEu linker_dlluosupathudirnameusplitextubasenameujoinuappenduexecuteu write_fileu UnixCCompilerulink(uselfu target_descuobjectsuoutput_filenameu output_diru librariesu library_dirsuruntime_library_dirsuexport_symbolsudebugu extra_preargsuextra_postargsu build_tempu target_langutemp_dirudll_nameu dll_extensionudef_fileulib_fileucontentsusym((u>/opt/alt/python33/lib64/python3.3/distutils/cygwinccompiler.pyulink­s:         uCygwinCCompiler.linkucCsú|dkrd}ng}xØ|D]Ð}tjjtjj|ƒƒ\}}||jddgkr~td||fƒ‚n|r™tjj|ƒ}n|dkrÏ|jtjj ||||j ƒƒq"|jtjj |||j ƒƒq"W|S(u#Adds supports for rc and res files.uu.rcu.resu"unknown file type '%s' (from '%s')N(u.resu.rc( uNoneuosupathusplitextunormcaseusrc_extensionsuUnknownFileErrorubasenameuappendujoinu obj_extension(uselfusource_filenamesu strip_diru output_diru obj_namesusrc_nameubaseuext((u>/opt/alt/python33/lib64/python3.3/distutils/cygwinccompiler.pyuobject_filenamesûs    $ u CygwinCCompiler.object_filenamesN(u__name__u __module__u __qualname__u__doc__u compiler_typeu obj_extensionustatic_lib_extensionushared_lib_extensionustatic_lib_formatushared_lib_formatu exe_extensionu__init__u_compileuNoneulinkuobject_filenames(u __locals__((u>/opt/alt/python33/lib64/python3.3/distutils/cygwinccompiler.pyuCygwinCCompilerXs;   KuCygwinCCompilercBs5|EeZdZdZdZddddd„ZdS(uMingw32CCompileru@ Handles the Mingw32 port of the GNU C compiler to Windows. umingw32icCsÝtj||||ƒ|jdkr.d}nd}|jdkrLd}nd}|jdksjtƒrsd}nd}|jd d |d d |d d|dd|dd|j|||fƒg|_tƒ|_dS(Nu2.13u-sharedu -mdll -staticu2.91.57u--entry _DllMain@12uu4u -mno-cygwinucompilerugcc%s -O -Wallu compiler_sougcc%s -mdll -O -Wallu compiler_cxxug++%s -O -Wallu linker_exeugcc%su linker_sou %s%s %s %s( uCygwinCCompileru__init__u ld_versionu gcc_versionu is_cygwingccuset_executablesu linker_dllu dll_librariesu get_msvcr(uselfuverboseudry_runuforceu shared_optionu entry_pointu no_cygwin((u>/opt/alt/python33/lib64/python3.3/distutils/cygwinccompiler.pyu__init__s&        uMingw32CCompiler.__init__N(u__name__u __module__u __qualname__u__doc__u compiler_typeu__init__(u __locals__((u>/opt/alt/python33/lib64/python3.3/distutils/cygwinccompiler.pyuMingw32CCompilersuMingw32CCompileruokunot oku uncertaincCsÈddlm}dtjkr)tdfS|jƒ}yPt|ƒ}z2d|jƒkrgtd|fStd|fSWd|j ƒXWn<t k rÃ}zt d ||j ffSWYdd}~XnXdS( uwCheck if the current Python installation appears amenable to building extensions with GCC. Returns a tuple (status, details), where 'status' is one of the following constants: - CONFIG_H_OK: all is well, go ahead and compile - CONFIG_H_NOTOK: doesn't look good - CONFIG_H_UNCERTAIN: not sure -- unable to read pyconfig.h 'details' is a human-readable string explaining the situation. Note there are two ways to conclude "OK": either 'sys.version' contains the string "GCC" (implying that this Python was built with GCC), or the installed "pyconfig.h" contains the string "__GNUC__". i(u sysconfiguGCCusys.version mentions 'GCC'u__GNUC__u'%s' mentions '__GNUC__'u '%s' does not mention '__GNUC__'Nucouldn't read '%s': %s( u distutilsu sysconfigusysuversionu CONFIG_H_OKuget_config_h_filenameuopenureaduCONFIG_H_NOTOKucloseuIOErroruCONFIG_H_UNCERTAINustrerror(u sysconfigufnuconfig_huexc((u>/opt/alt/python33/lib64/python3.3/distutils/cygwinccompiler.pyucheck_config_hHs   ucheck_config_hs(\d+\.\d+(\.\d+)*)c Cs—|jƒd}t|ƒdkr&dSt|dddtƒj}z|jƒ}Wd|jƒXt j |ƒ}|dkr~dSt |j dƒj ƒƒS(u¤Find the version of an executable by running `cmd` in the shell. If the command is not found, or the output does not match `RE_VERSION`, returns None. iushellustdoutNiT(usplitufind_executableuNoneuPopenuTrueuPIPEustdoutureaducloseu RE_VERSIONusearchu LooseVersionugroupudecode(ucmdu executableuoutu out_stringuresult((u>/opt/alt/python33/lib64/python3.3/distutils/cygwinccompiler.pyu_find_exe_versionus  u_find_exe_versioncCs&dddg}tdd„|DƒƒS(ug Try to find out the versions of gcc, ld and dllwrap. If not possible it returns None for it. ugcc -dumpversionuld -vudllwrap --versioncSsg|]}t|ƒ‘qS((u_find_exe_version(u.0ucmd((u>/opt/alt/python33/lib64/python3.3/distutils/cygwinccompiler.pyu s u get_versions..(utuple(ucommands((u>/opt/alt/python33/lib64/python3.3/distutils/cygwinccompiler.pyu get_versionsŠsu get_versionscCs%tddgƒ}|jƒjdƒS(u>Try to determine if the gcc that would be used is from cygwin.ugccu -dumpmachinescygwin(u check_outputustripuendswith(u out_string((u>/opt/alt/python33/lib64/python3.3/distutils/cygwinccompiler.pyu is_cygwingcc’su is_cygwingcc(&u__doc__uosusysucopyu subprocessuPopenuPIPEu check_outputureudistutils.ccompilerugen_preprocess_optionsugen_lib_optionsudistutils.unixccompileru UnixCCompilerudistutils.file_utilu write_fileudistutils.errorsuDistutilsExecErroru CompileErroruUnknownFileErroru distutilsulogudistutils.versionu LooseVersionudistutils.spawnufind_executableu get_msvcruCygwinCCompileruMingw32CCompileru CONFIG_H_OKuCONFIG_H_NOTOKuCONFIG_H_UNCERTAINucheck_config_hucompileu RE_VERSIONu_find_exe_versionu get_versionsu is_cygwingcc(((u>/opt/alt/python33/lib64/python3.3/distutils/cygwinccompiler.pyus.)     º2 +