ó
9£Wc           @   sh   d  d l  Z  y e Wn e k
 r- e Z n Xd „  Z d „  Z d „  Z d „  Z d „  Z d „  Z	 d S(   iÿÿÿÿNc         C   s    d d l  m } | |  ƒ ‚ d  S(   Niÿÿÿÿ(   t   DistutilsSetupError(   t   distutils.errorsR    (   t   msgR    (    (    s9   /usr/lib64/python2.7/site-packages/cffi/setuptools_ext.pyt   error	   s    c         B   sR   e  |  ƒ  } | j ƒ  } Wd  QX| d 7} e | |  d ƒ } | | | f d  Ud  S(   Ns   
t   exec(   t   opent   readt   compile(   t   filenamet   globt   ft   srct   code(    (    s9   /usr/lib64/python2.7/site-packages/cffi/setuptools_ext.pyt   execfile   s
    
c         C   s/  d d l  m } t | t ƒ s< t d t | ƒ j f ƒ n  t | ƒ } y | j d ƒ \ } } Wn" t	 k
 r… t d | f ƒ n Xt
 j j | ƒ sõ d } | j d d ƒ d	 } t
 j j | ƒ rÞ d
 | d | f } n  t d | | f ƒ n  i d d 6| d 6} t | | ƒ y | | } Wn% t k
 rKt d | | f ƒ n Xt | | ƒ sg| ƒ  } n  t | | ƒ s–t d | t | ƒ j f ƒ n  t | d ƒ s¹t d | f ƒ n  | j \ }	 }
 } } | j ró| j ƒ  } | j | ƒ n  |
 d  k rt |  | |	 ƒ n t |  | |	 |
 | | ƒ d  S(   Niÿÿÿÿ(   t   FFIsE   argument to 'cffi_modules=...' must be a str or a list of str, not %rt   :s3   %r must be of the form 'path/build.py:ffi_variable't    t   .t   /s   .pys    (rewrite cffi_modules to [%r])s#   %r does not name an existing file%st   __cffi__t   __name__t   __file__s!   %r: object %r not found in modules"   %r is not an FFI instance (got %r)t   _assigned_sources*   %r: the set_source() method was not called(   t   cffi.apiR   t
   isinstancet
   basestringR   t   typeR   t   strt   splitt
   ValueErrort   ost   patht   existst   replaceR   t   KeyErrort   hasattrR   t   _windows_unicodet   copyt   _apply_windows_unicodet   Nonet   _add_py_modulet   _add_c_module(   t   distt   mod_specR   t   build_file_namet   ffi_var_namet   extt	   rewrittent   mod_varst   ffit   module_namet   sourcet   source_extensiont   kwds(    (    s9   /usr/lib64/python2.7/site-packages/cffi/setuptools_ext.pyt   add_cffi_module   sL    			c   
   	      s$  d d l  m } d d l m } d d l m ‰ d d l m ‰ d d l m	 ‰ d g } | j
 | j d g  ƒ ƒ | d	 ˆ d | |  ‰ d  ‡ ‡ ‡ ‡ ‡ ‡ ‡ ‡	 f d
 † ‰ |  j d  k rÌ g  |  _ n  |  j j ˆ ƒ |  j j d | ƒ ‰  d ˆ  f ‡  ‡ ‡ f d †  ƒ  Y}	 |	 |  j d <d  S(   Niÿÿÿÿ(   t	   Extension(   t	   build_ext(   t   mkpath(   t   log(   t
   recompilers   $PLACEHOLDERt   sourcest   namec            s‚   t  j j |  ˆ ˆ ƒ } ˆ j d | ƒ ˆ |  ƒ | d  k	 rP | ˆ  ˆ ƒ n  ˆ j ˆ ˆ ˆ | ƒ } | s~ ˆ j d ƒ n  | S(   Ns   generating cffi module %rs   already up-to-date(   R   R   t   joint   infoR'   t   make_c_source(   t   tmpdirt   pre_runt   c_filet   updated(   R.   R1   R:   R9   R2   R;   R3   R4   (    s9   /usr/lib64/python2.7/site-packages/cffi/setuptools_ext.pyt   make_modT   s    
R8   t   build_ext_make_modc              s   e  Z ‡  ‡ ‡ f d  †  Z RS(   c            sR   ˆ j  d d k rA t |  d d  ƒ } ˆ |  j | ƒ ˆ j  d <n  ˆ  j |  ƒ d  S(   Ni    s   $PLACEHOLDERRB   (   R<   t   getattrR'   t
   build_tempt   run(   t   selfRB   (   t
   base_classR.   RE   (    s9   /usr/lib64/python2.7/site-packages/cffi/setuptools_ext.pyRI   i   s    (   R   t
   __module__RI   (    (   RK   R.   RE   (    s9   /usr/lib64/python2.7/site-packages/cffi/setuptools_ext.pyRF   h   s   (   t   distutils.coreR7   t   distutils.command.build_extR8   t   distutils.dir_utilR9   t	   distutilsR:   t   cffiR;   t   extendt   popR'   t   ext_modulest   appendt   cmdclasst   get(
   R*   R1   R2   R3   R4   R5   R7   R8   t
   allsourcesRF   (    (
   RK   R.   R1   R:   RE   R9   R2   R;   R3   R4   s9   /usr/lib64/python2.7/site-packages/cffi/setuptools_ext.pyR)   I   s    	'"c            s÷   d d l  m ‰ d d l m } d d l m } d d l m ‰ d d l m	 ‰ ‡ ‡ ‡ ‡ ‡ f d †  ‰ |  j
 j d | ƒ ‰  d	 ˆ  f ‡  ‡ ‡ f d
 †  ƒ  Y} | |  j
 d <|  j
 j d | ƒ ‰ d ˆ f ‡ ‡ ‡ f d †  ƒ  Y} | |  j
 d <d  S(   Niÿÿÿÿ(   R9   (   t   build_py(   R8   (   R:   (   R;   c            sV   ˆ j  d |  ƒ ˆ t j j |  ƒ ƒ ˆ j ˆ  ˆ |  ƒ } | sR ˆ j  d ƒ n  d  S(   Ns   generating cffi module %rs   already up-to-date(   R?   R   R   t   dirnamet   make_py_source(   t   py_fileRD   (   R1   R:   R9   R2   R;   (    s9   /usr/lib64/python2.7/site-packages/cffi/setuptools_ext.pyt   generate_mod|   s
    RY   t   build_py_make_modc              s   e  Z ‡  ‡ ‡ f d  †  Z RS(   c            sL   ˆ  j  |  ƒ ˆ j d ƒ } | d c d 7<ˆ t j j |  j | Œ ƒ d  S(   NR   iÿÿÿÿs   .py(   RI   R   R   R   R>   t	   build_lib(   RJ   t   module_path(   RK   R]   R2   (    s9   /usr/lib64/python2.7/site-packages/cffi/setuptools_ext.pyRI   …   s    (   R   RL   RI   (    (   RK   R]   R2   (    s9   /usr/lib64/python2.7/site-packages/cffi/setuptools_ext.pyR^   „   s   R8   RF   c              s   e  Z ‡  ‡ ‡ f d  †  Z RS(   c            s„   ˆ  j  |  ƒ |  j r€ ˆ j d ƒ } d j | d  ƒ } |  j d ƒ } | j | ƒ } | d d } ˆ t j j | | ƒ ƒ n  d  S(   NR   iÿÿÿÿRY   s   .py(   RI   t   inplaceR   R>   t   get_finalized_commandt   get_package_dirR   R   (   RJ   R`   t   packageRY   t   package_dirt	   file_name(   t   base_class_2R]   R2   (    s9   /usr/lib64/python2.7/site-packages/cffi/setuptools_ext.pyRI      s    	(   R   RL   RI   (    (   Rg   R]   R2   (    s9   /usr/lib64/python2.7/site-packages/cffi/setuptools_ext.pyRF   Ž   s   (   RO   R9   t   distutils.command.build_pyRY   RN   R8   RP   R:   RQ   R;   RV   RW   (   R*   R1   R2   RY   R8   R^   RF   (    (   RK   Rg   R1   R]   R:   R9   R2   R;   s9   /usr/lib64/python2.7/site-packages/cffi/setuptools_ext.pyR(   u   s    ""c         C   s=   t  | t ƒ r | g } n  x | D] } t |  | ƒ q" Wd  S(   N(   R   R   R6   (   R*   t   attrt   valuet   cffi_module(    (    s9   /usr/lib64/python2.7/site-packages/cffi/setuptools_ext.pyt   cffi_modules›   s    (
   R   R   t	   NameErrorR   R   R   R6   R)   R(   Rl   (    (    (    s9   /usr/lib64/python2.7/site-packages/cffi/setuptools_ext.pyt   <module>   s   
			.	,	&