ó p§Wc@s7ddlZddlZddlZddlZddlZddlmZddlmZejdkrƒddl Z d„Z nddl Z d„Z ejdkr³ej Zndejfd „ƒYZd „Zd efd „ƒYZeZd „Zdad„Zd„Zded„Zd„Zd„ZdS(iÿÿÿÿNi(t__version_verifier_modules__(t ffiplatformicCs tjjS(N(t importlibt machinerytEXTENSION_SUFFIXES(((s3/usr/lib64/python2.7/site-packages/cffi/verifier.pyt_extension_suffixes scCs5gtjƒD]$\}}}|tjkr |^q S(N(timpt get_suffixest C_EXTENSION(tsuffixt_ttype((s3/usr/lib64/python2.7/site-packages/cffi/verifier.pyRstNativeIOcBseZd„ZRS(cCs;t|tƒr!|jdƒ}ntt|ƒj|ƒdS(Ntascii(t isinstancetunicodetencodetsuperR twrite(tselfts((s3/usr/lib64/python2.7/site-packages/cffi/verifier.pyRs(t__name__t __module__R(((s3/usr/lib64/python2.7/site-packages/cffi/verifier.pyR scCs:tjdkr6yddl}Wq6tk r2q6XndS(Ntwin32iÿÿÿÿ(tsystplatformt setuptoolst ImportError(R((s3/usr/lib64/python2.7/site-packages/cffi/verifier.pyt_hack_at_distutilss  tVerifierc Bs›eZddddedddd„Zdd„Zd„Zd„Zd„Zd„Z d„Z d „Z d „Z d „Z dd „Zd „Zd„ZRS(ts.cc Ks|jjr+tjd|jjfƒ‚n||_||_|sUtj| ƒ} nt||ƒ} | |ƒ|_|jj | ƒ| |_ |j | | ƒ|_ |r¿|r¡t dƒ‚q¡nâdjtjd t|| g|jƒ}tjdkr |jdƒ}nttj|ddd…ƒd@ƒ}|jd ƒjd ƒ}ttj|d dd…ƒd@ƒ}|jd ƒjd ƒ}d ||jj||f}tƒd}|pºtƒ|_tjj|j||ƒ|_ tjj|j||ƒ|_!||_"t#|_$t#|_%dS(NsKfeature not supported with ffi.verify(), but only with ffi.set_source(): %ss)can't specify both 'modulename' and 'tag'tisutf-8iiIÿÿÿÿt0xtLit0s_cffi_%s_%s%s%s(i(&t_parsert_uses_new_featureRtVerificationErrortffitpreambletflattent_locate_engine_classt_venginetpatch_extension_kwdstflagstmake_relative_totkwdst TypeErrortjoinRtversionRt _cdefsourcest version_infoRthextbinasciitcrc32tlstriptrstript _class_keyt_get_so_suffixest_caller_dir_pycachettmpdirtostpathtsourcefilenametmodulefilenamet ext_packagetFalset _has_sourcet _has_module(RR&R'R<t modulenameRAttagtforce_generic_enginetsource_extensionR,t relative_toR.tflattened_kwdst vengine_classtkeytk1tk2R ((s3/usr/lib64/python2.7/site-packages/cffi/verifier.pyt__init__)sD      &&    cCsK|jj9|jr4|dkr4tjdƒ‚n|j|ƒWdQXdS(skWrite the C source code. It is produced in 'self.sourcefilename', which can be tweaked beforehand.ssource code already writtenN(R&t_lockRCtNoneRR%t _write_source(Rtfile((s3/usr/lib64/python2.7/site-packages/cffi/verifier.pyt write_sourceQs   cCsR|jj@|jr(tjdƒ‚n|js>|jƒn|jƒWdQXdS(s„Write the C source code (if not done already) and compile it. This produces a dynamic link library in 'self.modulefilename'.smodule already compiledN(R&RPRDRR%RCRRt_compile_module(R((s3/usr/lib64/python2.7/site-packages/cffi/verifier.pytcompile_moduleZs     cCsc|jjQ|jsO|jƒ|jsO|js?|jƒn|jƒqOn|jƒSWdQXdS(s"Get a C module from this Verifier instance. Returns an instance of a FFILibrary class that behaves like the objects returned by ffi.dlopen(), but that delegates all operations to the C module. If necessary, the C code is written and compiled first. N(R&RPRDt_locate_moduleRCRRRUt _load_library(R((s3/usr/lib64/python2.7/site-packages/cffi/verifier.pyt load_libraryds      cCsZtjj|jƒ}|jddƒd}|jdƒrVttdƒrV|d }n|S(Nt.iit_dtgettotalrefcountiþÿÿÿ(R=R>tbasenameR@tsplittendswiththasattrR(RR]((s3/usr/lib64/python2.7/site-packages/cffi/verifier.pytget_module_namets  cCsptƒ|js<|jj|js3|jƒnWdQXntj|jƒ}|jƒ}tj |||j S(N( RRCR&RPRRRtmaybe_relative_pathR?Rat get_extensionR.(Rt sourcenametmodname((s3/usr/lib64/python2.7/site-packages/cffi/verifier.pyRcs    cCs |jjS(N(R*t_gen_python_module(R((s3/usr/lib64/python2.7/site-packages/cffi/verifier.pytgenerates_python_module‰scCsÇ|rÃtjj|ƒrÃtjj|ƒ}|jƒ}xŠtjD]|}||kr@||}t|ttfƒs‡t d|fƒ‚ng|D]}tjj ||ƒ^qŽ}|||tdirnametcopyRtLIST_OF_FILE_NAMESRtlistttupleR/R0(RR.RIRhRLtlsttfn((s3/usr/lib64/python2.7/site-packages/cffi/verifier.pyR-Œs   (cCs»tjj|jƒs¡|jr^yt|jdddgƒ}Wntk rQdSX|j}nd}|j j |j ƒ|t ƒƒ}|dkr•dS||_n|j j ƒt|_dS(Nt__doc__(R=R>tisfileR@RAt __import__RQRt__path__R*t find_moduleRaR:t collect_typestTrueRD(RtpkgR>tfilename((s3/usr/lib64/python2.7/site-packages/cffi/verifier.pyRWœs       cCs.||j_z|jjƒWd|j`XdS(N(R*t_ftwrite_source_to_f(RRS((s3/usr/lib64/python2.7/site-packages/cffi/verifier.pyt_write_source_to¯s cCsÕ|dk r|j|ƒnµtƒ}|j|ƒ|jƒ}tjj|jƒr„t|jdƒ}|j ƒ|k }WdQXnt }|rÈt |jƒt|jdƒ}|j |ƒWdQXnt |_ dS(Ntrtw(RQRzR tgetvalueR=R>texistsR?topentreadRut _ensure_dirRRC(RRStft source_datatfpt needs_written((s3/usr/lib64/python2.7/site-packages/cffi/verifier.pyRR¶s     cCs–tjj|jƒ}tj||jƒƒ}ytj||jƒ}Wnt k r_t }nX|s‰t |jƒt j ||jƒnt|_dS(N(R=R>RhR?RtcompileRctsamefileR@tOSErrorRBRtshutiltmoveRuRD(RR<toutputfilenametsame((s3/usr/lib64/python2.7/site-packages/cffi/verifier.pyRUÏs   cCsB|jst‚|jdk r1|jj|jƒS|jjƒSdS(N(RDtAssertionErrorR,RQR*RY(R((s3/usr/lib64/python2.7/site-packages/cffi/verifier.pyRXÜsN(RRRQRBRORTRVRYRaRcRgR-RWRzRRRURX(((s3/usr/lib64/python2.7/site-packages/cffi/verifier.pyR's &       cCsªtrt}n|srdtjkr-t}qryddl}Wntk rVd}nX|j|k rrt}qrn|rddlm}|j Sddlm }|j SdS(Nt__pypy__iÿÿÿÿt?i(t vengine_gen(t vengine_cpy( t_FORCE_GENERIC_ENGINERuRtbuiltin_module_namest _cffi_backendRt_backendRRtVGenericEngineR‘tVCPythonEngine(R&RGR”RR‘((s3/usr/lib64/python2.7/site-packages/cffi/verifier.pyR)çs      cCsftr tStjjdƒ}|r&|Stjdƒjj}tjj tjj tjj |ƒdƒƒS(Nt CFFI_TMPDIRit __pycache__( t_TMPDIRR=tenvirontgetRt _getframetf_codet co_filenameR>tabspathR0Rh(tresultRw((s3/usr/lib64/python2.7/site-packages/cffi/verifier.pyR;ÿs!cCs |adS(s:Set the temporary directory to use instead of __pycache__.N(Rš(Rh((s3/usr/lib64/python2.7/site-packages/cffi/verifier.pyt set_tmpdir sc Csƒ|p tƒ}ytj|ƒ}Wntk r6dSX|rFd}ntƒdjƒ}x„|D]|}|jƒjdƒr`|jƒj|ƒs¥|jƒjdƒr`y tjtj j ||ƒƒWqÜtk rØqÜXq`q`Wtj j |dƒg}x„|D]|}ybx[tj|ƒD]J}tj j ||ƒ}tj j |ƒrU|j |ƒqtj|ƒqWWqÿtk rzqÿXqÿWdS(s}Clean up the temporary directory by removing all files in it called `_cffi_*.{c,so}` as well as the `build` subdirectory.Ns.cit_cffi_tbuild( R;R=tlistdirRˆR:tlowert startswithR_tunlinkR>R0tisdirtappend(R<tkeep_sotfilelistR Rnt clean_dirtdir((s3/usr/lib64/python2.7/site-packages/cffi/verifier.pytcleanup_tmpdirs2   *     cCs:tƒ}|s6tjdkr*dg}q6dg}n|S(NRs.pyds.so(RRR(tsuffixes((s3/usr/lib64/python2.7/site-packages/cffi/verifier.pyR:-s    cCs5ytjtjj|ƒƒWntk r0nXdS(N(R=tmakedirsR>RhRˆ(Rw((s3/usr/lib64/python2.7/site-packages/cffi/verifier.pyR8s (ii(i(RR=R5R‰tioRRRR3timportlib.machineryRRRtStringIOR tBytesIORtobjectRRBR’R)RQRšR;R¢R¯R:R(((s3/usr/lib64/python2.7/site-packages/cffi/verifier.pyts(<      ¾