ó
8Ţ	Pc           @   s  d  d l  Z  d  d l Z e j d k rE d   Z d   Z d   Z n  e j d k r` d   Z n  e j d k r e  j d	 k r d  d
 l m Z	 d   Z nÉ e j d k rcd  d l
 Z
 d  d l Z d  d l Z d   Z e  j d k rń d   Z n	 d   Z e  j j d  s0e  j j d  s0e  j j d  rEd   Z d   Z qcd   Z d   Z d   Z n  d   Z e d k re   n  d S(   i˙˙˙˙Nt   ntc          C   sŻ   d }  t  j j |   } | d k r( d S| t |   } t  j | j d d  \ } } t | d   d } t | d d ! d	 } | d k r d
 } n  | d k rŤ | | Sd S(   sĎ   Return the version of MSVC that was used to build Python.

        For Python 2.3 and up, the version number is included in
        sys.version.  For earlier versions, assume the compiler is MSVC 6.
        s   MSC v.i˙˙˙˙i   t    i   iţ˙˙˙i   i   g      $@i    N(   t   syst   versiont   findt   lent   splitt   intt   None(   t   prefixt   it   st   restt   majorVersiont   minorVersion(    (    s!   /usr/lib/python2.7/ctypes/util.pyt   _get_build_version	   s    	c          C   sw   t    }  |  d k r d S|  d k r. d } n d |  d } d d l } | j   d d d k ro | d	 7} n  | d
 S(   s%   Return the name of the VC runtime dlli   t   msvcrts   msvcr%di
   i˙˙˙˙Ni    s   _d.pydt   ds   .dll(   R   R   t   impt   get_suffixes(   R   t   clibnameR   (    (    s!   /usr/lib/python2.7/ctypes/util.pyt   find_msvcrt    s    		c         C   sĄ   |  d k r t    Sx t j d j t j  D]l } t j j | |   } t j j |  r^ | S| j   j	 d  ry q- n  | d } t j j |  r- | Sq- Wd  S(   Nt   ct   mt   PATHs   .dll(   R   R   (   R   t   ost   environR   t   pathsept   patht   joint   isfilet   lowert   endswithR   (   t   namet	   directoryt   fname(    (    s!   /usr/lib/python2.7/ctypes/util.pyt   find_library1   s     
t   cec         C   s   |  S(   N(    (   R!   (    (    s!   /usr/lib/python2.7/ctypes/util.pyR$   G   s    t   posixt   darwin(   t	   dyld_findc         C   s[   d |  d |  d |  |  f g } x3 | D]+ }  y t  |   SWq( t k
 rR q( q( Xq( Wd  S(   Ns   lib%s.dylibs   %s.dylibs   %s.framework/%s(   t
   _dyld_findt
   ValueErrorR   (   R!   t   possible(    (    s!   /usr/lib/python2.7/ctypes/util.pyR$   L   s    c   
      C   sű   d t  j |   } t j   \ } } t j |  d | d |  } z3 t j |  } z | j   } Wd  | j   } XWd  y t j |  Wn+ t	 k
 r¸ } | j
 t
 j k rš   qš n XX| d k rŇ t	 d  n  t  j | |  }	 |	 sî d  S|	 j d  S(   Ns   [^\(\)\s]*lib%s\.[^\(\)\s]*sr   if type gcc >/dev/null 2>&1; then CC=gcc; elif type cc >/dev/null 2>&1; then CC=cc;else exit 10; fi;$CC -Wl,-t -o s    2>&1 -li
   s   gcc or cc command not foundi    (   t   ret   escapet   tempfilet   mkstempR   t   closet   popent   readt   unlinkt   OSErrort   errnot   ENOENTt   searchR   t   group(
   R!   t   exprt   fdoutt   ccoutt   cmdt   ft   tracet   rvt   et   res(    (    s!   /usr/lib/python2.7/ctypes/util.pyt   _findLib_gcc[   s(    t   sunos5c         C   sj   |  s
 d  Sd |  } t j |  }  z |  j   } Wd  |  j   Xt j d |  } | s] d  S| j d  S(   Ns#   /usr/ccs/bin/dump -Lpv 2>/dev/null s   \[.*\]\sSONAME\s+([^\s]+)i   (   R   R   R1   R2   R0   R,   R7   R8   (   R=   R<   t   dataRA   (    (    s!   /usr/lib/python2.7/ctypes/util.pyt   _get_sonamew   s    
c         C   sŠ   |  s
 d  Sd |  } t j |  }  |  j   } |  j   } | d k rS t d  n  t j |  }  z |  j   } Wd  |  j   Xt j d |  } | s d  S| j d  S(   NsW   if ! type objdump >/dev/null 2>&1; then exit 10; fi;objdump -p -j .dynamic 2>/dev/null i
   s   objdump command not founds   \sSONAME\s+([^\s]+)i   (	   R   R   R1   R2   R0   R4   R,   R7   R8   (   R=   R<   t   dumpR?   RD   RA   (    (    s!   /usr/lib/python2.7/ctypes/util.pyRE      s"    t   freebsdt   openbsdt	   dragonflyc         C   sf   |  j  d  } g  } y- x& | r@ | j d t | j     q WWn t k
 rU n X| pe t j g S(   Nt   .i    (   R   t   insertR   t   popR*   R   t   maxint(   t   libnamet   partst   nums(    (    s!   /usr/lib/python2.7/ctypes/util.pyt   _num_version   s    	$c         C   s   t  j |   } d | | f } t j d  } z | j   } Wd  | j   Xt  j | |  } | st t t |    S| j	 d d    | d S(   Ns   :-l%s\.\S+ => \S*/(lib%s\.\S+)s   /sbin/ldconfig -r 2>/dev/nullt   cmpc         S   s   t  t |   t |   S(   N(   RR   RQ   (   t   xt   y(    (    s!   /usr/lib/python2.7/ctypes/util.pyt   <lambda>´   s    i˙˙˙˙(
   R,   R-   R   R1   R2   R0   t   findallRE   RB   t   sort(   R!   t   enameR9   R=   RD   RA   (    (    s!   /usr/lib/python2.7/ctypes/util.pyR$   Š   s    c         C   sž   d t  j |   } t j d  } z | j   } Wd  | j   Xt  j | |  } | są d t j } t j |  } z | j   } Wd  | j   Xt  j | |  } | są d  Sn  | j
 d  S(   Ns   /[^\(\)\s]*lib%s\.[^\(\)\s]*s-   LC_ALL=C LANG=C /sbin/ldconfig -p 2>/dev/nulls   ldd %s 2>/dev/nulli    (   R,   R-   R   R1   R2   R0   R7   R   t
   executableR   R8   (   R!   R9   R=   RD   RA   R<   (    (    s!   /usr/lib/python2.7/ctypes/util.pyt   _findLib_ldconfigš   s     c   	      C   sö   d d  l  } | j d  d k r8 t j   d d } n t j   d d } i d d 6d d	 6d d
 6d d 6d d 6} | j | d  } d | t j |   f } t j d  } z | j   } Wd  | j	   Xt j
 | |  } | sé d  S| j d  S(   Ni˙˙˙˙t   li   s   -32s   -64s   libc6,x86-64s	   x86_64-64s   libc6,64bits   ppc64-64s
   sparc64-64s   s390x-64s   libc6,IA-64s   ia64-64t   libc6sG   (\S+)\s+\((%s(?:, OS ABI:[^\)]*)?)\)[^/]*(/[^\(\)\s]*lib%s\.[^\(\)\s]*)s   /sbin/ldconfig -p 2>/dev/nulli   (   t   structt   calcsizeR   t   unamet   getR,   R-   R1   R2   R0   R7   R   R8   (	   R!   R]   t   machinet   mach_mapt   abi_typeR9   R=   RD   RA   (    (    s!   /usr/lib/python2.7/ctypes/util.pyt   _findSoname_ldconfigĎ   s*    
c         C   s   t  |   p t t |    S(   N(   Rd   RE   RB   (   R!   (    (    s!   /usr/lib/python2.7/ctypes/util.pyR$   ë   s    c          C   së   d d l  m }  t j d k rC |  j GH|  j d  GHt d  GHn  t j d k rç t d  GHt d  GHt d  GHt j d	 k r˝ |  j	 d
  GH|  j	 d  GH|  j	 d  GH|  j	 d  GHqç |  j	 d  GH|  j	 d  GHt d  GHn  d  S(   Ni˙˙˙˙(   t   cdllR    R   R&   R   R   t   bz2R'   s
   libm.dylibs   libcrypto.dylibs   libSystem.dylibs   System.framework/Systems   libm.sos   libcrypt.sot   crypt(
   t   ctypesRe   R   R!   R   t   loadR$   R   t   platformt   LoadLibrary(   Re   (    (    s!   /usr/lib/python2.7/ctypes/util.pyt   testń   s"    t   __main__(   R   R   R!   R   R   R$   Rj   t   ctypes.macholib.dyldR(   R)   R,   R.   R5   RB   RE   t
   startswithRQ   RZ   Rd   Rl   t   __name__(    (    (    s!   /usr/lib/python2.7/ctypes/util.pyt   <module>   s4   		$						