pWc@s7ddlZddlZddlZddlZddlZddlmZddlmZejdkrddl Z dZ nddl Z dZ ejdkrej Zndejfd YZd Zd efd YZeZd ZdadZdZdedZdZdZdS(iNi(t__version_verifier_modules__(t ffiplatformicCs tjjS(N(t importlibt machinerytEXTENSION_SUFFIXES(((s3/usr/lib64/python2.7/site-packages/cffi/verifier.pyt_extension_suffixes scCs5gtjD]$\}}}|tjkr |^q S(N(timpt get_suffixest C_EXTENSION(tsuffixt_ttype((s3/usr/lib64/python2.7/site-packages/cffi/verifier.pyRstNativeIOcBseZdZRS(cCs;t|tr!|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 BseZddddeddddZddZdZdZdZdZ dZ d Z d Z d Z dd Zd ZdZRS(ts.cc Ks|jjr+tjd|jjfn||_||_|sUtj| } nt||} | ||_|jj | | |_ |j | | |_ |r|rt dqndjtjd t|| g|j}tjdkr |jd}nttj|dddd@}|jd jd }ttj|d ddd@}|jd jd }d ||jj||f}td}|pt|_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-8iiIt0xtLit0s_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|dkr4tjdn|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(tjdn|js>|jn|jWdQXdS(sWrite 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?|jn|jqOn|jSWdQXdS(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}|jddd}|jdrVttdrV|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|jnWdQXntj|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_modulescCs|rtjj|rtjj|}|j}xtjD]|}||kr@||}t|ttfst d|fng|D]}tjj ||^q}|||tdirnametcopyRtLIST_OF_FILE_NAMESRtlistttupleR/R0(RR.RIRhRLtlsttfn((s3/usr/lib64/python2.7/site-packages/cffi/verifier.pyR-s   (cCstjj|js|jr^yt|jdddg}Wntk rQdSX|j}nd}|j j |j |t }|dkrdS||_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.pyRWs       cCs.||j_z|jjWd|j`XdS(N(R*t_ftwrite_source_to_f(RRS((s3/usr/lib64/python2.7/site-packages/cffi/verifier.pyt_write_source_tos cCs|dk r|j|nt}|j||j}tjj|jrt|jd}|j |k }WdQXnt }|rt |jt|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.pyRRs     cCstjj|j}tj||j}ytj||j}Wnt k r_t }nX|st |jt j ||jnt|_dS(N(R=R>RhR?RtcompileRctsamefileR@tOSErrorRBRtshutiltmoveRuRD(RR<toutputfilenametsame((s3/usr/lib64/python2.7/site-packages/cffi/verifier.pyRUs   cCsB|jst|jdk r1|jj|jS|jjSdS(N(RDtAssertionErrorR,RQR*RY(R((s3/usr/lib64/python2.7/site-packages/cffi/verifier.pyRXsN(RRRQRBRORTRVRYRaRcRgR-RWRzRRRURX(((s3/usr/lib64/python2.7/site-packages/cffi/verifier.pyR's &       cCstrt}n|srdtjkr-t}qryddl}Wntk rVd}nX|j|k rrt}qrn|rddlm}|j Sddlm }|j SdS(Nt__pypy__it?i(t vengine_gen(t vengine_cpy( t_FORCE_GENERIC_ENGINERuRtbuiltin_module_namest _cffi_backendRt_backendRRtVGenericEngineRtVCPythonEngine(R&RGRRR((s3/usr/lib64/python2.7/site-packages/cffi/verifier.pyR)s      cCsftr tStjjd}|r&|Stjdjj}tjj tjj tjj |dS(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}ntdj}x|D]|}|jjdr`|jj|s|jjdr`y tjtj j ||Wqtk rqXq`q`Wtj j |dg}x|D]|}ybx[tj|D]J}tj j ||}tj j |rU|j |qtj|qWWqtk rzqXqWdS(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=tlistdirRR: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=R5RtioRRRR3timportlib.machineryRRRtStringIOR tBytesIORtobjectRRBRR)RQRR;RRR:R(((s3/usr/lib64/python2.7/site-packages/cffi/verifier.pyts(<