o
    ¾ÔiŽ  ã                   @  sH   d dl mZ d dlZd dlZddd„Zddd„Zdd	d
„Zddd„ZdS )é    )ÚannotationsNÚreturnú
str | Nonec                   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   ú9lib/python3.10/site-packages/pip/_internal/utils/glibc.pyÚglibc_version_string   s   r	   c               
   C  sT   t jdkrdS zt d¡} | du rW dS |  ¡ \}}W |S  tttfy)   Y dS w )z@Primary implementation of glibc_version_string using os.confstr.Úwin32NÚCS_GNU_LIBC_VERSION)ÚsysÚplatformÚosÚconfstrÚsplitÚAttributeErrorÚOSErrorÚ
ValueError)Zgnu_libc_versionÚ_Úversionr   r   r   r      s   

ýþr   c                  C  sŒ   zddl } W n
 ty   Y dS w z|  d¡}W n
 ty"   Y dS w z|j}W n
 ty2   Y dS w | j|_|ƒ }t|t	ƒsD| 
d¡}|S )z=Fallback implementation of glibc_version_string using ctypes.r   NÚascii)ÚctypesÚImportErrorZCDLLr   Úgnu_get_libc_versionr   Zc_char_pZrestypeÚ
isinstanceÚstrÚdecode)r   Zprocess_namespacer   Zversion_strr   r   r   r       s(   ÿÿ
ý

r   útuple[str, str]c                  C  s   t ƒ } | du r	dS d| f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)Ú r   Zglibc)r	   )Zglibc_versionr   r   r   Úlibc_ver\   s   r   )r   r   )r   r   )Z
__future__r   r   r   r	   r   r   r   r   r   r   r   Ú<module>   s    


<