ó Û_e[c@s>ddlZddlZddlZddlZddlZddlmZddlmZddlm Z ej dkr“ddl Z d„Z nddlZd„Z ej dkrÃejZnd ejfd „ƒYZd efd „ƒYZeZd „Zdad„Zd„Zded„Zd„Zd„ZdS(iÿÿÿÿNi(t__version_verifier_modules__(t ffiplatform(tVerificationErroricCs tjjS(N(t importlibt machinerytEXTENSION_SUFFIXES(((s-/tmp/pip-install-KP2Jbq/cffi/cffi/verifier.pyt_extension_suffixes scCs5gtjƒD]$\}}}|tjkr |^q S(N(timpt get_suffixest C_EXTENSION(tsuffixt_ttype((s-/tmp/pip-install-KP2Jbq/cffi/cffi/verifier.pyRstNativeIOcBseZd„ZRS(cCs;t|tƒr!|jdƒ}ntt|ƒj|ƒdS(Ntascii(t isinstancetunicodetencodetsuperR twrite(tselfts((s-/tmp/pip-install-KP2Jbq/cffi/cffi/verifier.pyRs(t__name__t __module__R(((s-/tmp/pip-install-KP2Jbq/cffi/cffi/verifier.pyR stVerifierc Bs›eZddddedddd„Zdd„Zd„Zd„Zd„Zd„Z d„Z d „Z d „Z d „Z dd „Zd „Zd„ZRS(ts.cc Ks|jjr(td|jjfƒ‚n||_||_|sRtj| ƒ} 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_featureRtffitpreambleRtflattent_locate_engine_classt_venginetpatch_extension_kwdstflagstmake_relative_totkwdst TypeErrortjointsystversionRt _cdefsourcest version_infoRthextbinasciitcrc32tlstriptrstript _class_keyt_get_so_suffixest_caller_dir_pycachettmpdirtostpathtsourcefilenametmodulefilenamet ext_packagetFalset _has_sourcet _has_module(RR R!R7t modulenameR<ttagtforce_generic_enginetsource_extensionR&t relative_toR(tflattened_kwdst vengine_classtkeytk1tk2R ((s-/tmp/pip-install-KP2Jbq/cffi/cffi/verifier.pyt__init__ sD      &&    cCsH|jj6|jr1|dkr1tdƒ‚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_lockR>tNoneRt _write_source(Rtfile((s-/tmp/pip-install-KP2Jbq/cffi/cffi/verifier.pyt write_sourceHs   cCsO|jj=|jr%tdƒ‚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 RKR?RR>RMt_compile_module(R((s-/tmp/pip-install-KP2Jbq/cffi/cffi/verifier.pytcompile_moduleQs     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 RKR?t_locate_moduleR>RMRPt _load_library(R((s-/tmp/pip-install-KP2Jbq/cffi/cffi/verifier.pyt load_library[s      cCsZtjj|jƒ}|jddƒd}|jdƒrVttdƒrV|d }n|S(Nt.iit_dtgettotalrefcountiþÿÿÿ(R8R9tbasenameR;tsplittendswiththasattrR+(RRX((s-/tmp/pip-install-KP2Jbq/cffi/cffi/verifier.pytget_module_nameks  cCsstjƒ|js?|jj|js6|jƒnWdQXntj|jƒ}|jƒ}tj |||j S(N( Rt_hack_at_distutilsR>R RKRMtmaybe_relative_pathR:R\t get_extensionR((Rt sourcenametmodname((s-/tmp/pip-install-KP2Jbq/cffi/cffi/verifier.pyR_vs     cCs |jjS(N(R$t_gen_python_module(R((s-/tmp/pip-install-KP2Jbq/cffi/cffi/verifier.pytgenerates_python_module€scCsÇ|rÃtjj|ƒrÃtjj|ƒ}|jƒ}xŠtjD]|}||kr@||}t|ttfƒs‡t d|fƒ‚ng|D]}tjj ||ƒ^qŽ}|||(RRNtft source_datatfpt needs_written((s-/tmp/pip-install-KP2Jbq/cffi/cffi/verifier.pyRM­s     cCs–tjj|jƒ}tj||jƒƒ}ytj||jƒ}Wnt k r_t }nX|s‰t |jƒt j ||jƒnt|_dS(N(R8R9RdR:RtcompileR_tsamefileR;tOSErrorR=R~tshutiltmoveRrR?(RR7toutputfilenametsame((s-/tmp/pip-install-KP2Jbq/cffi/cffi/verifier.pyRPÆs   cCsB|jst‚|jdk r1|jj|jƒS|jjƒSdS(N(R?tAssertionErrorR&RLR$RT(R((s-/tmp/pip-install-KP2Jbq/cffi/cffi/verifier.pyRSÓsN(RRRLR=RJRORQRTR\R_RcR'RRRwRMRPRS(((s-/tmp/pip-install-KP2Jbq/cffi/cffi/verifier.pyRs &       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_ENGINERrR+tbuiltin_module_namest _cffi_backendRnt_backendRRtVGenericEngineRŽtVCPythonEngine(R RBR‘RRŽ((s-/tmp/pip-install-KP2Jbq/cffi/cffi/verifier.pyR#Þs      cCsftr tStjjdƒ}|r&|Stjdƒjj}tjj tjj tjj |ƒdƒƒS(Nt CFFI_TMPDIRit __pycache__( t_TMPDIRR8tenvirontgetR+t _getframetf_codet co_filenameR9tabspathR*Rd(tresultRt((s-/tmp/pip-install-KP2Jbq/cffi/cffi/verifier.pyR6ös!cCs |adS(s:Set the temporary directory to use instead of __pycache__.N(R—(Rd((s-/tmp/pip-install-KP2Jbq/cffi/cffi/verifier.pyt set_tmpdirscCsƒ|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( R6R8tlistdirR…R5tlowert startswithRZtunlinkR9R*tisdirtappend(R7tkeep_sotfilelistR Rjt clean_dirtdir((s-/tmp/pip-install-KP2Jbq/cffi/cffi/verifier.pytcleanup_tmpdirs2   *     cCs:tƒ}|s6tjdkr*dg}q6dg}n|S(Ntwin32s.pyds.so(RR+tplatform(tsuffixes((s-/tmp/pip-install-KP2Jbq/cffi/cffi/verifier.pyR5$s    cCs?tjj|ƒ}|r;tjj|ƒ r;tj|ƒndS(N(R8R9RdR¦tmakedirs(RtRd((s-/tmp/pip-install-KP2Jbq/cffi/cffi/verifier.pyR~/s(ii(i(R+R8R0R†tioRRRterrorRR.timportlib.machineryRRRtStringIOR tBytesIOtobjectRR=RR#RLR—R6RŸR¬R5R~(((s-/tmp/pip-install-KP2Jbq/cffi/cffi/verifier.pyts(<     ¾