U ÀÒ.e-ã@sxddlmZddlZddlZddlZddlmZerDddlmZm Z dd„Z dd„Z d d „Z d d „Z d d„Zdd„ZdS)é)Úabsolute_importN)ÚMYPY_CHECK_RUNNING)ÚOptionalÚTuplecCs tƒp tƒS)z9Returns glibc version string, or None if not using glibc.)Úglibc_version_string_confstrÚglibc_version_string_ctypes©rrú=/usr/lib/python3.8/site-packages/pip/_internal/utils/glibc.pyÚglibc_version_stringsr c Cs8zt d¡ ¡\}}Wntttfk r2YdSX|S)z@Primary implementation of glibc_version_string using os.confstr.ÚCS_GNU_LIBC_VERSIONN)ÚosÚconfstrÚsplitÚAttributeErrorÚOSErrorÚ ValueError)Ú_Úversionrrr rs rcCsvz ddl}Wntk r"YdSX| d¡}z |j}Wntk rNYdSX|j|_|ƒ}t|tƒsr|  d¡}|S)z=Fallback implementation of glibc_version_string using ctypes.rNÚascii) ÚctypesÚ ImportErrorZCDLLÚgnu_get_libc_versionrZc_char_pZrestypeÚ isinstanceÚstrÚdecode)rZprocess_namespacerÚ version_strrrr r&s     rcCsHt d|¡}|s$t d|t¡dSt| d¡ƒ|koFt| d¡ƒ|kS)Nz$(?P[0-9]+)\.(?P[0-9]+)z=Expected glibc version with 2 components major.minor, got: %sFÚmajorÚminor)ÚreÚmatchÚwarningsÚwarnÚRuntimeWarningÚintÚgroup)rÚrequired_majorÚ minimum_minorÚmrrr Úcheck_glibc_versionFs ÿÿÿr(cCstƒ}|dkrdSt|||ƒS)NF)r r()r%r&rrrr Úhave_compatible_glibcWsr)cCstƒ}|dkrdSd|fSdS)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*Zglibc)r )Z glibc_versionrrr Úlibc_verpsr+)Z __future__rr rr Zpip._internal.utils.typingrÚtypingrrr rrr(r)r+rrrr Ús