U
    e                     @   s`   d dl mZ d dlZd dlZd dlmZ er<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   =/tmp/pip-unpacked-wheel-indi3crb/pip/_internal/utils/glibc.pyglibc_version_string   s    r
   c               
   C   sF   t jdkrdS ztd \} }W n tttfk
r@   Y dS 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   sv   zddl } W n tk
r"   Y dS X | d}z
|j}W n tk
rN   Y dS X | j|_| }t|tsr|	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S d| fS dS )zTry to determine the glibc version

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