)Uc@sddlmZddlmZddlmZddlmZddlZ ddl Z ddl Z ddl Z ddl Z ddlZgZgZdZdZdZd Zd Zd Zd Zd ZdZdefdYZdefdYZdefdYZdefdYZeZdZ yLddl!m"Z"ddl#m$Z$ddl%m&Z&m'Z'm(Z(ddl)Z*Wne+k rZ,e-ZnXde.fdYZ/defdYZ0dS(i(t build_ext(t install_lib(t install_data(t ExtensionNcCstjd|d}tjjdr2d}n'tjjdrMd}n tdx<t|jD](}|j|}|rl|j dSqlWdS(s@Return the value of a m4_define variable as set in configure.in.s m4_define\(s \,\s*(.+)\)s configure.acs configure.inscould not find configure fileiN( tretcompiletostpathtexistst SystemExittopent readlinestmatchtgrouptNone(tvarnametpatterntfnametlinet match_obj((s6/usr/lib/python2.7/vendor-packages/gtk-2.0/dsextras.pyt get_m4_defines   cCst|dS(s=Return output (stdout or stderr) of executing cmd in a shell.i(tgetstatusoutput(tcmd((s6/usr/lib/python2.7/vendor-packages/gtk-2.0/dsextras.pyt getoutput%scCstjdkrftj|d}|j}|jp<d}|ddkr\|d }n||fSddlm}||SdS(s4Return (status, output) of executing cmd in a shell.twin32triis (RN(tsystplatformRtpopentreadtclosetcommandsR(RtpipettexttstsR((s6/usr/lib/python2.7/vendor-packages/gtk-2.0/dsextras.pyR)s   cCsFtjdkr(tjddkr(dStdddkrBdSdS(s&Checks for the existence of pkg-configRspkg-config --version > NULiis pkg-configiN(RRRtsystemR(((s6/usr/lib/python2.7/vendor-packages/gtk-2.0/dsextras.pythave_pkgconfig6s cCs|jtjdkrP|jtj}tj|d tj}|d}n |}d}tjj|}g}xHtj|D]7}t j ||r|j tjj||qqW|S(sList all files in a dir, with filename match support: for example: glade/*.glade will return all files in the glade directory that matches *.glade. It also looks up the full pathit.( tfindRtseptsplittstringtjoinRtabspathtlistdirtfnmatchtappend(tdirtpartsRtretvaltfile((s6/usr/lib/python2.7/vendor-packages/gtk-2.0/dsextras.pyt list_files?s #cCsrtjd| }|sdStd|}tt|jd}tt|jd}||krndSdS(slCheck the existence and version number of a package: returns 0 if not installed or too old, 1 otherwise.spkg-config --exists %sispkg-config --modversion %sR%i(RR#RtmaptintR((tnamet req_versiont is_installedt orig_versiontversiont pkc_version((s6/usr/lib/python2.7/vendor-packages/gtk-2.0/dsextras.pytpkgc_version_checkRs cCs&td|}|jddjS(sCreturns a list of libraries as returned by pkg-config --libs-only-lspkg-config --libs-only-l %ss-lt(RtreplaceR((R6toutput((s6/usr/lib/python2.7/vendor-packages/gtk-2.0/dsextras.pytpkgc_get_librariesbscCs&td|}|jddjS(sFreturns a list of library dirs as returned by pkg-config --libs-only-Lspkg-config --libs-only-L %ss-LR=(RR>R((R6R?((s6/usr/lib/python2.7/vendor-packages/gtk-2.0/dsextras.pytpkgc_get_library_dirsgscCs&td|}|jddjS(sHreturns a list of include dirs as returned by pkg-config --cflags-only-Ispkg-config --cflags-only-I %ss-IR=(RR>R((R6R?((s6/usr/lib/python2.7/vendor-packages/gtk-2.0/dsextras.pytpkgc_get_include_dirslstBuildExtcBs,eZdZdZdZdZRS(cCsg|_tjdkr||jjdkr|idd6dd6}td}d|||d fGH|jj||d ndS( NRtmingw32s-fnative-structt2s-mms-bitfieldst3sgcc -dumpversions)using MinGW GCC version %s with %s optioni(textra_compile_argsRRtcompilert compiler_typeRR.(tselftmsnative_structt gcc_version((s6/usr/lib/python2.7/vendor-packages/gtk-2.0/dsextras.pytinit_extra_compile_argsrs    cCsStjdkrO|jjdkrO|jjjdrO|jjjdqOndS(NRRDs-static(RRRHRIt linker_sotcounttremove(RJ((s6/usr/lib/python2.7/vendor-packages/gtk-2.0/dsextras.pytmodify_compilerscCs%|j|jtj|dS(N(RMRQRtbuild_extensions(RJ((s6/usr/lib/python2.7/vendor-packages/gtk-2.0/dsextras.pyRRs  cCs|j|j7_t|dr.|jntjdkr|jjdkr|j}g|jD]}|dkrb|^qb|_n |j}tj |||dkr||jkr||_ndS(NtgenerateRtmsvctctm(RURV( RGthasattrRSRRRHRIt librariesRtbuild_extensionR(RJtextt save_libstlib((s6/usr/lib/python2.7/vendor-packages/gtk-2.0/dsextras.pyRYs !  (t__name__t __module__RMRQRRRY(((s6/usr/lib/python2.7/vendor-packages/gtk-2.0/dsextras.pyRCqs   t InstallLibcBs/eZgZgZdZdZdZRS(cCs ||_dS(N(t install_dir(RJR`((s6/usr/lib/python2.7/vendor-packages/gtk-2.0/dsextras.pytset_install_dirscCstj||jS(N(Rt get_outputst local_outputs(RJ((s6/usr/lib/python2.7/vendor-packages/gtk-2.0/dsextras.pyRbscCstj||jS(N(Rt get_inputst local_inputs(RJ((s6/usr/lib/python2.7/vendor-packages/gtk-2.0/dsextras.pyRds(R]R^RcReRaRbRd(((s6/usr/lib/python2.7/vendor-packages/gtk-2.0/dsextras.pyR_s   t InstallDatacBsPeZgZgZiZdZdZdZdZdZ dZ RS(cCs(tjdkr:tjj|jjtjd |_n(tjj|jjtjd |_d|_d|_d|_ d|_ d|_ |j d|j|j d |j|j d |j|j d |j |j d |j |j d |j |j dt j|j dddS(Ntntiis ${prefix}/bins${prefix}/includes ${prefix}/libs${prefix}/sharetprefixt exec_prefixt includedirtlibdirt datarootdirtdatadirtPYTHONtTHREADING_CFLAGSR=(RR6R'R*R`R(RhRiRjRkRlRmtadd_template_optionRt executable(RJ((s6/usr/lib/python2.7/vendor-packages/gtk-2.0/dsextras.pytprepares +(     cCs ||_dS(N(R`(RJR`((s6/usr/lib/python2.7/vendor-packages/gtk-2.0/dsextras.pyRascCs||jd|R*tmkpathtwriteReR.Rc(RJtfilenameR`t output_filettemplatetkeyRtR?((s6/usr/lib/python2.7/vendor-packages/gtk-2.0/dsextras.pytinstall_templates cCstj||jS(N(RRbRc(RJ((s6/usr/lib/python2.7/vendor-packages/gtk-2.0/dsextras.pyRbscCstj||jS(N(RRdRe(RJ((s6/usr/lib/python2.7/vendor-packages/gtk-2.0/dsextras.pyRds( R]R^RcReRsRrRaRpR}RbRd(((s6/usr/lib/python2.7/vendor-packages/gtk-2.0/dsextras.pyRfs     tPkgConfigExtensioncBsJeZdZdZdZdZdZdZdZ dZ RS(s pygobject-2.0cKs|d}d|kr6|dc|j|t7R((RJtnamesR1R6R?((s6/usr/lib/python2.7/vendor-packages/gtk-2.0/dsextras.pyRs  #cCsht|tkr|f}ng}x=|D]5}td|}|j|jddjq+W|S(Nspkg-config --libs-only-l %ss-lR=(RRRRR>R((RJRR1R6R?((s6/usr/lib/python2.7/vendor-packages/gtk-2.0/dsextras.pyRs  #cCsht|tkr|f}ng}x=|D]5}td|}|j|jddjq+W|S(Nspkg-config --libs-only-L %ss-LR=(RRRRR>R((RJRR1R6R?((s6/usr/lib/python2.7/vendor-packages/gtk-2.0/dsextras.pyRs  #cCs |jd kr|jSt|jtkrC|j|jfg}nt|j|j}x|D]\}}tjd|}|rd||j fGHd|_dSt d|}t t |j dt t |j dkrd|_dSd|jGHd||fGHd|_dSq_Wd S( s.If the pkg-config version found is good enoughspkg-config --exists %ss>* %s.pc could not be found, bindings for %s will not be built.ispkg-config --modversion %sR%isWarning: Too old version of %ss% Need %s, but %s is installedN(t can_build_okRRRRR;tzipRR#R6RR4R5R((RJtreqstpackageR:R1R9((s6/usr/lib/python2.7/vendor-packages/gtk-2.0/dsextras.pyt can_build"s.      cCsdS(N((RJ((s6/usr/lib/python2.7/vendor-packages/gtk-2.0/dsextras.pyRSAsN( R]R^RRRRRRRRRS(((s6/usr/lib/python2.7/vendor-packages/gtk-2.0/dsextras.pyR~s  sz *************************************************************************** Codegen could not be found on your system and is required by the dsextras.Template and dsextras.TemplateExtension classes. codegen is part of PyGTK. To use either Template or TemplateExtension, you should also install PyGTK. *************************************************************************** (t Overrides(t DefsParser(tregister_typest SourceWritert FileOutputtTemplatecBs>eZdZgdedZdZdZdZRS(cOs3ts td|jtntj|||S(Ns'%s' is not defined (ttemplate_classes_enabledt NameErrorR]tcodegen_error_messagetobjectt__new__(tclstargstkwds((s6/usr/lib/python2.7/vendor-packages/gtk-2.0/dsextras.pyR^s  c Cs||_||_||_||_||_g|_t|tre|d|_|jj |n ||_g|_ xT|D]L}t|tr|j j |d|jj |q~|j j |q~WdS(Ni( toverrideR?Rht load_typestpy_ssize_t_cleant built_defst isinstanceRtdefsR.tregister( RJRR?RRhRRRR((s6/usr/lib/python2.7/vendor-packages/gtk-2.0/dsextras.pyRds           cCsA|j}|j|j|j|jtjj||j S(N(RR.RRt distutilstdep_utilt newer_groupR?(RJtfiles((s6/usr/lib/python2.7/vendor-packages/gtk-2.0/dsextras.pyt check_dates|s cCsVxO|jD]D\}}tjj||r d|g|}tjj|q q WdS(Ntdummy(RRRRtcodegent createdefstmain(RJttargettsourcesR((s6/usr/lib/python2.7/vendor-packages/gtk-2.0/dsextras.pyt generate_defsscCs|j|jrdSx:|jD]/}t|tt}|jt|q$W|jryi}t |j|nt|j tt}|jt|t |j d}t |t|j|jt||j }|j|j|jdS(NRu(RRRRtdictRt startParsingRRtexecfileRR R?RRRRhRRxRR(RJtitemtdptglobalstfdtsw((s6/usr/lib/python2.7/vendor-packages/gtk-2.0/dsextras.pyRSs$      N( R]R^RRtFalseRRRRS(((s6/usr/lib/python2.7/vendor-packages/gtk-2.0/dsextras.pyR]s    tTemplateExtensioncBs#eZdZdZdZRS(cOs3ts td|jtntj|||S(Ns'%s' is not defined (RRR]RR~R(RRR((s6/usr/lib/python2.7/vendor-packages/gtk-2.0/dsextras.pyRs  c Ks |d}|d}t|tr8|dd d}n|d d}|d}|jd}|jdt}g|_|jjt|||d ||d |||d =|d=|d=|r|d=n|jd r|d |d<|d =nt j ||dS( NR6Riis.cRRRtpyRR?( RRtgetRRt templatesR.Rthas_keyR~R(RJRR6RR?RRR((s6/usr/lib/python2.7/vendor-packages/gtk-2.0/dsextras.pyRs&        cCstd|jdS(NcSs |jS(N(RS(tx((s6/usr/lib/python2.7/vendor-packages/gtk-2.0/dsextras.pyts(R4R(RJ((s6/usr/lib/python2.7/vendor-packages/gtk-2.0/dsextras.pyRSs(R]R^RRRS(((s6/usr/lib/python2.7/vendor-packages/gtk-2.0/dsextras.pyRs  (1tdistutils.command.build_extRtdistutils.command.install_libRtdistutils.command.install_dataRtdistutils.extensionRtdistutils.dep_utilRR-RRR)RRRRRRR$R3R<R@RARBRCR_RfR~tTrueRRtcodegen.overrideRtcodegen.defsparserRtcodegen.codegenRRRtcodegen.createdefsRt ImportErrorteRRRR(((s6/usr/lib/python2.7/vendor-packages/gtk-2.0/dsextras.pytsF             27c I