3 L]@sddlZddlZddlmZdddddgZffd d Zdd d Zdd dZyddlm Z Wne k rvddZ YnXddZ ye e fZddlZWn ek re ZddlZYnXddZddZddZdS)N)VerificationErrorsources include_dirs library_dirs extra_objectsdependscKsLtddlm}|g}x|D]}|jtjj|qW|f||d|S)Nr) Extension)namer)_hack_at_distutilsdistutils.corer appendospathnormpath)Z srcfilenamemodnamerkwdsr Z allsourcessrcr2/tmp/pip-install-wfra5znf/cffi/cffi/ffiplatform.py get_extensions   rc Csfttjj}zt||||}tjj|}Wdx.|jD]"\}}tjj||kr:|tj|<q:WX|S)z-Compile a C extension module using distutils.N) r renvironcopy_buildrabspathitemsget)tmpdirextcompiler_verbosedebugZ saved_environZoutputfilenamekeyvaluerrrcompiles r#c Csddlm}ddl}ddl}|d|gi}|j|jd}|dkrLtjj}d|f|d<d |d<d|f|d <d|f|d <yR|j j dpd}z.|j j ||j d|j d} | j\} Wd|j j |XWnD|jj|jjfk r} ztd | jj| fWYdd} ~ XnX| S) Nr) Distribution ext_modules build_ext ffiplatformr Tforce build_lib build_tempz%s: %s)r'T)r r$distutils.errorsZ distutils.logparse_config_filesget_option_dictsysflagsr log set_threshold set_verbosity run_commandget_command_obj get_outputserrors CompileError LinkErrorr __class____name__) rrrr r$ distutilsdistoptionsZ old_levelcmd_objZsonameerrrr s.        &r)samefilecCstjj|tjj|kS)N)rrr)f1f2rrrr@Asr@c Cstjj|s|S|}g}xn|}tjj|\}}||ks<| r@|S|j|y$t|tjrl|jtjj|SWqt k rYqXqWdS)N) rrisabssplitr r@curdirreversejoinOSError)rdirnamesZprevdirr rrrmaybe_relative_pathDs    rKcCst|tr"|jdt||fnt|trrt|j}|jdt|x|D]}t||t|||qPWndt|tt fr|jdt|xB|D]}t||qWn*t|t r|jd|fnt d|fdS)Nz%ds%sz%ddz%dlz%diz7the keywords to verify() contains unsupported object %r) isinstancestrwritelendictsortedkeys_flattenlisttuple int_or_long TypeError)xfrRr!r"rrrrS_s        rScCstj}t|||jS)N) cStringIOStringIOrSgetvalue)rXrYrrrflattenrs r]c Cs0tjdkr,y ddl}Wntk r*YnXdS)Nwin32r)r.platform setuptools ImportError)r`rrrr ws   r )rN)rN)r.rerrorrZLIST_OF_FILE_NAMESrr#ros.pathr@rarKintlongrVrZ NameErroriorSr]r rrrrs(