
0c@_á  ã               @   sˆ   d  d l  m Z d  d l Z d  d l Z d  d l m Z e rT d  d l m Z m Z d d „  Z	 d d „  Z
 d	 d
 „  Z d d „  Z d S)é    )Úabsolute_importN)ÚMYPY_CHECK_RUNNING)ÚOptionalÚTuplec               C   s   t  ƒ  p t ƒ  S)z9Returns glibc version string, or None if not using glibc.)Úglibc_version_string_confstrÚglibc_version_string_ctypes© r   r   ú8/tmp/pip-build-jynh7p1z/pip/pip/_internal/utils/glibc.pyÚglibc_version_string   s    r
   c              C   sX   t  j d k r d Sy t j d ƒ j ƒ  \ }  } Wn t t t f k
 rS d SYn X| S)z@Primary implementation of glibc_version_string using os.confstr.Úwin32NÚCS_GNU_LIBC_VERSION)ÚsysÚplatformÚosÚconfstrÚsplitÚAttributeErrorÚOSErrorÚ
ValueError)Ú_Úversionr   r   r	   r      s    	r   c              C   s•   y d d l  }  Wn t k
 r( d SYn X|  j d ƒ } y | j } Wn t k
 r] d SYn X|  j | _ | ƒ  } t | t ƒ s‘ | j	 d ƒ } | S)z=Fallback implementation of glibc_version_string using ctypes.r   NÚascii)
ÚctypesÚImportErrorÚCDLLÚgnu_get_libc_versionr   Úc_char_pÚrestypeÚ
isinstanceÚstrÚdecode)r   Úprocess_namespacer   Úversion_strr   r   r	   r   '   s    			r   c              C   s'   t  ƒ  }  |  d k r d Sd |  f Sd S)z“Try to determine the glibc version

    Returns a tuple of strings (lib, version) which default to empty strings
    in case the lookup fails.
    NÚ Úglibc)r#   r#   )r
   )Zglibc_versionr   r   r	   Úlibc_verW   s    	r%   )Ú
__future__r   r   r   Zpip._internal.utils.typingr   Ztypingr   r   r
   r   r   r%   r   r   r   r	   Ú<module>   s   0