ó
ƒI	ec           @   s°  d  d l  Z  d  d l Z d  d l Z e  j d k rQ d „  Z d „  Z d „  Z n  e  j d k rl 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 r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 ƒ s<e j j d ƒ s<e j j d ƒ rQd „  Z d „  Z qe j d k rxd „  Z e d „ Z q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_library0   s     
t   cec         C   s   |  S(   N(    (   R!   (    (    s!   /usr/lib/python2.7/ctypes/util.pyR$   F   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$   K   s    c   	      C   sÑ   d t  j |  ƒ } d } t j ƒ  } zC t j | d |  | j f d t d t j ƒ} | j	 ƒ  \ } } Wd  y | j
 ƒ  Wn+ t k
 r¦ } | j t j k r§ ‚  q§ n XXt  j | | ƒ } | sÄ d  S| j d ƒ S(   Ns   [^\(\)\s]*lib%s\.[^\(\)\s]*s   if type gcc >/dev/null 2>&1; then CC=gcc; elif type cc >/dev/null 2>&1; then CC=cc;else exit; fi;LANG=C LC_ALL=C $CC -Wl,-t -o "$2" 2>&1 -l"$1"t   _findLib_gcct   shellt   stdouti    (   t   ret   escapet   tempfilet   NamedTemporaryFilet
   subprocesst   PopenR!   t   Truet   PIPEt   communicatet   closet   OSErrort   errnot   ENOENTt   searchR   t   group(	   R!   t   exprt   cmdt   tempt   proct   tracet   _t   et   res(    (    s!   /usr/lib/python2.7/ctypes/util.pyR,   Z   s"    t   sunos5c      
   C   s¤   |  s
 d  St t j d ƒ } y8 | , t j d d |  f d t j d | ƒ} Wd  QXWn t k
 rh d  SX| j ƒ  \ } } t	 j
 d | ƒ } | s— d  S| j d ƒ S(   Nt   wbs   /usr/ccs/bin/dumps   -LpvR.   t   stderrs   \[.*\]\sSONAME\s+([^\s]+)i   (   R   t   openR   t   devnullR3   R4   R6   R9   R7   R/   R<   R=   (   t   ft   nullRA   t   dataRC   RE   (    (    s!   /usr/lib/python2.7/ctypes/util.pyt   _get_sonamey   s    	c         C   sr   |  s
 d  Sd } t j | d |  f d t d t j ƒ} | j ƒ  \ } } t j d | ƒ } | se d  S| j d ƒ S(   NsX   if ! type objdump >/dev/null 2>&1; then exit; fi;objdump -p -j .dynamic 2>/dev/null "$1"RN   R-   R.   s   \sSONAME\s+([^\s]+)i   (	   R   R3   R4   R5   R6   R7   R/   R<   R=   (   RK   R?   RA   t   dumpRC   RE   (    (    s!   /usr/lib/python2.7/ctypes/util.pyRN   ‹   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 t j d ƒ } y/ | # t j d
 d t j d | ƒ} Wd  QXWn t k
 ry d } n X| j	 ƒ  \ } } t  j
 | | ƒ } | s´ t t |  ƒ ƒ S| j d t ƒ | d	 S(   Ns   :-l%s\.\S+ => \S*/(lib%s\.\S+)RG   s   /sbin/ldconfigs   -rR.   RH   t    t   keyiÿÿÿÿ(   s   /sbin/ldconfigs   -r(   R/   R0   RI   R   RJ   R3   R4   R6   R9   R7   t   findallRN   R,   t   sortRZ   (   R!   t   enameR>   RL   RA   RM   RC   RE   (    (    s!   /usr/lib/python2.7/ctypes/util.pyR$   ¨   s     	
c   
      C   s^  t  j j d ƒ s d  St t  j ƒ } d | d <| r> d } n d } d  } t t  j d ƒ } y5 | ) t j	 | d t j
 d | d | ƒ} Wd  QXWn t k
 r¥ d  SXzF x? | j D]4 } | j ƒ  } | j d	 ƒ r³ | j ƒ  d
 } q³ q³ WWd  | j j ƒ  | j ƒ  X| sd  SxF | j d ƒ D]5 } t  j j | d |  ƒ }	 t  j j |	 ƒ r!|	 Sq!Wd  S(   Ns   /usr/bin/crlet   Ct   LC_ALLs   -64RG   R.   RH   t   envs   Default Library Path (ELF):i   t   :s   lib%s.so(   s   /usr/bin/crles   -64(   s   /usr/bin/crle(   R   R   t   existsR   t   dictR   RI   RJ   R3   R4   R6   R9   R.   t   stript
   startswithR   R8   t   waitR   (
   R!   t   is64Rb   t   argst   pathsRL   RA   t   linet   dirt   libfile(    (    s!   /usr/lib/python2.7/ctypes/util.pyt   _findLib_crle¿   s>    
		c         C   s   t  t |  | ƒ p t |  ƒ ƒ S(   N(   RN   Ro   R,   (   R!   Ri   (    (    s!   /usr/lib/python2.7/ctypes/util.pyR$   è   s    c         C   s{  d d  l  } t j ƒ  d } | j d ƒ r4 d } n  | j d ƒ d k rV | d } n
 | d } i d d 6d	 d
 6d	 d 6d	 d 6d d 6d d 6} | j | d ƒ } d t j |  ƒ | f } t t j	 ƒ } d | d <d | d <t
 t j d ƒ } y; | / t j d d g d | d t j d | ƒ}	 Wd  QXWn t k
 r?d  SX|	 j ƒ  \ }
 } t j | |
 ƒ } | snd  S| j d ƒ S(   Niÿÿÿÿi   t   armt   ls   -32s   -64s   libc6,x86-64s	   x86_64-64s   libc6,64bits   ppc64-64s
   sparc64-64s   s390x-64s   libc6,IA-64s   ia64-64s   libc6(,hard-float)?s   arm-32t   libc6s   \s+(lib%s\.[^\s]+)\s+\(%sR`   Ra   t   LANGRG   s   /sbin/ldconfigs   -pRH   R.   Rb   i   (   t   structR   t   unameRg   t   calcsizet   getR/   R0   Re   R   RI   RJ   R3   R4   R6   R9   R   R7   R<   R=   (   R!   Rt   Ru   t   machinet   mach_mapt   abi_typeR>   Rb   RL   t   pRM   RC   RE   (    (    s!   /usr/lib/python2.7/ctypes/util.pyt   _findSoname_ldconfigí   sB    	



	c         C   s   t  |  ƒ p t t |  ƒ ƒ S(   N(   R|   RN   R,   (   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   ctypesR}   R   R!   R   t   loadR$   R   t   platformt   LoadLibrary(   R}   (    (    s!   /usr/lib/python2.7/ctypes/util.pyt   test"  s"    t   __main__(   R   R3   R   R!   R   R   R$   R‚   t   ctypes.macholib.dyldR(   R)   R/   R1   R:   R,   RN   Rg   RZ   Ro   t   FalseR|   R„   t   __name__(    (    (    s!   /usr/lib/python2.7/ctypes/util.pyt   <module>   s<   		$				)	/	