ó
p§Wc           @   s  d  d l  Z  d  d l Z d e f d „  ƒ  YZ d e f d „  ƒ  YZ d d d d	 d
 g Z d d „ Z d d „ Z d d „ Z y d  d l	 m
 Z
 Wn e k
 r­ d „  Z
 n Xd „  Z y e e f Z d  d l Z Wn# e k
 rø e Z d  d l Z n Xd „  Z d „  Z d S(   iÿÿÿÿNt   VerificationErrorc           B   s   e  Z d  Z RS(   s-    An error raised when verification fails
    (   t   __name__t
   __module__t   __doc__(    (    (    s6   /usr/lib64/python2.7/site-packages/cffi/ffiplatform.pyR       s   t   VerificationMissingc           B   s   e  Z d  Z RS(   sl    An error raised when incomplete structures are passed into
    cdef, but no verification has been done
    (   R   R   R   (    (    (    s6   /usr/lib64/python2.7/site-packages/cffi/ffiplatform.pyR      s   t   sourcest   include_dirst   library_dirst   extra_objectst   dependsc         K   sY   d d l  m } |  g } x' | D] } | j t j j | ƒ ƒ q  W| d | d | |  S(   Niÿÿÿÿ(   t	   Extensiont   nameR   (   t   distutils.coreR
   t   appendt   ost   patht   normpath(   t   srcfilenamet   modnameR   t   kwdsR
   t
   allsourcest   src(    (    s6   /usr/lib64/python2.7/site-packages/cffi/ffiplatform.pyt   get_extension   s
    	i    c         C   s„   t  j j ƒ  } z( t |  | | ƒ } t  j j | ƒ } Wd xB | j ƒ  D]4 \ } } t  j j | ƒ | k rG | t  j | <qG qG WX| S(   s-   Compile a C extension module using distutils.N(   R   t   environt   copyt   _buildR   t   abspatht   itemst   get(   t   tmpdirt   extt   compiler_verboset   saved_environt   outputfilenamet   keyt   value(    (    s6   /usr/lib64/python2.7/site-packages/cffi/ffiplatform.pyt   compile   s    c         C   s>  d d l  m } d d  l } d d  l } | i | g d 6ƒ } | j ƒ  | j d ƒ } d t f | d <d |  f | d <d |  f | d <yo | j j d	 ƒ pŸ d	 } z? | j j	 | ƒ | j
 d ƒ | j d ƒ } | j ƒ  \ }	 Wd  | j j | ƒ XWnA | j j | j j f k
 r9}
 t d
 |
 j j |
 f ƒ ‚ n X|	 S(   Niÿÿÿÿ(   t   Distributiont   ext_modulest	   build_extt   ffiplatformt   forcet	   build_libt
   build_tempi    s   %s: %s(   R   R%   t   distutils.errorst   distutils.logt   parse_config_filest   get_option_dictt   Truet   logt   set_thresholdt   set_verbosityt   run_commandt   get_command_objt   get_outputst   errorst   CompileErrort	   LinkErrorR    t	   __class__R   (   R   R   R   R%   t	   distutilst   distt   optionst	   old_levelt   cmd_objt   sonamet   e(    (    s6   /usr/lib64/python2.7/site-packages/cffi/ffiplatform.pyR   '   s(    

 (   t   samefilec         C   s"   t  j j |  ƒ t  j j | ƒ k S(   N(   R   R   R   (   t   f1t   f2(    (    s6   /usr/lib64/python2.7/site-packages/cffi/ffiplatform.pyRB   E   s    c         C   s¹   t  j j |  ƒ s |  S|  } g  } x t r´ | } t  j j | ƒ \ } } | | k s\ | r` |  S| j | ƒ y0 t | t  j ƒ rœ | j ƒ  t  j j	 | Œ  SWq% t
 k
 r° q% Xq% Wd  S(   N(   R   R   t   isabsR0   t   splitR   RB   t   curdirt   reverset   joint   OSError(   R   t   dirt   namest   prevdirR   (    (    s6   /usr/lib64/python2.7/site-packages/cffi/ffiplatform.pyt   maybe_relative_pathH   s     	
c         C   s#  t  |  t ƒ r/ | j d t |  ƒ |  f ƒ nð t  |  t ƒ r™ t |  j ƒ  ƒ } | j d t | ƒ ƒ xµ | D]$ } t | | ƒ t |  | | ƒ qn Wn† t  |  t t	 f ƒ ræ | j d t |  ƒ ƒ xW |  D] } t | | ƒ qÌ Wn9 t  |  t
 ƒ r| j d |  f ƒ n t d |  f ƒ ‚ d  S(   Ns   %ds%ss   %dds   %dls   %dis7   the keywords to verify() contains unsupported object %r(   t
   isinstancet   strt   writet   lent   dictt   sortedt   keyst   _flattent   listt   tuplet   int_or_longt	   TypeError(   t   xt   fRU   R"   R#   (    (    s6   /usr/lib64/python2.7/site-packages/cffi/ffiplatform.pyRV   c   s      c         C   s#   t  j ƒ  } t |  | ƒ | j ƒ  S(   N(   t	   cStringIOt   StringIORV   t   getvalue(   R[   R\   (    (    s6   /usr/lib64/python2.7/site-packages/cffi/ffiplatform.pyt   flattenv   s    (    (   t   sysR   t	   ExceptionR    R   t   LIST_OF_FILE_NAMESR   R$   R   t   os.pathRB   t   ImportErrorRN   t   intt   longRY   R]   t	   NameErrort   ioRV   R`   (    (    (    s6   /usr/lib64/python2.7/site-packages/cffi/ffiplatform.pyt   <module>   s(   			