3 )]b* @sdZddlmZddlZddlZddlZddlZddlZy ddlZWne k rbddl jZYnXddl Z ddl mZddlZejeZejdZddZdd Zd d Zd d ZddZd!ddZddZddZddZddZddZ d"ddZ!e!Z"e!dd Z#eZ$dS)#z2Generate and work with PEP 425 Compatibility Tags.)absolute_importN) OrderedDictz(.+)_(\d+)_(\d+)_(.+)cCsBy tj|Stk r<}ztjdj|tdSd}~XnXdS)Nz{0}) sysconfigget_config_varIOErrorwarningswarnformatRuntimeWarning)varer /usr/lib/python3.6/pep425tags.pyrs  rcCs:ttdrd}n&tjjdr"d}ntjdkr2d}nd}|S)z'Return abbreviated implementation name.pypy_version_infoppjavaZjyZcliZipcp)hasattrsysplatform startswith)Zpyimplr r r get_abbr_impl!s   rcCs.td}| stdkr*djttt}|S)zReturn implementation version.py_version_nodotr)rrjoinmapstrget_impl_version_info)Zimpl_verr r r get_impl_ver.srcCs:tdkr"tjdtjjtjjfStjdtjdfSdS)zQReturn sys.version_info-like tuple for use in decrementing the minor version.rrN)rr version_informajorminorr r r rr6s  rcCsdjttS)z; Returns the Tag for this specific implementation. z{0}{1})r rrr r r r get_impl_tagAsr#TcCs.t|}|dkr&|r tjd||S||kS)zgUse a fallback method for determining SOABI flags if the needed config var is unset or unavailable.Nz>Config variable '%s' is unset, Python ABI tag may be incorrect)rloggerdebug)r Zfallbackexpectedrvalr r rget_flagHsr(cstd}t| rdkrttdrd}d}d}tddddkd rLd }td fd ddkd rjd }tdddddkotjdkdrtjdkrd}dt|||f}n@|r|jdrd|jdd}n|r|j ddj dd}nd}|S)zXReturn the ABI tag based on SOABI (if available) or emulate SOABI (CPython 2, PyPy).SOABIrr maxunicoderPy_DEBUGcSs ttdS)Ngettotalrefcount)rrr r r r^szget_abi_tag..)rd WITH_PYMALLOCcsdkS)Nrr r )implr rr-bsmZPy_UNICODE_SIZEcSs tjdkS)Ni)rr*r r r rr-fs)r&ruz %s%s%s%s%szcpython--r._N)rr)r3r3)r3r3) rrrrr(r rrsplitreplace)Zsoabir.r1r4abir )r0r get_abi_tagTs8    r;cCs tjdkS)Ni)rmaxsizer r r r_is_running_32bitvsr=cCstjdkr^tj\}}}|jd}|dkr6tr6d}n|dkrHtrHd}dj|d|d |Stjjj dd j d d }|d krtrd }|S)z0Return our platform name 'win32', 'linux_x86_64'darwinr6x86_64i386ppc64ppczmacosx_{0}_{1}_{2}rrr7r5 linux_x86_64 linux_i686) rrZmac_verr8r=r distutilsutil get_platformr9)releaser7machineZ split_verresultr r rrGzs  rGc CsJtdkrdSyddl}t|jSttfk r8YnXtjjj ddS)NrCrDFr)rCrD) rG _manylinuxboolZmanylinux1_compatible ImportErrorAttributeErrorpipZutilsZglibcZhave_compatible_glibc)rMr r ris_manylinux1_compatibles  rRcsvg}fddtd dddg|||r8|j|x.D]&}||kr>|||r>|j|q>W|jd |S)zReturn a list of supported arches (including group arches) for the given major, minor and machine architecture of an macOS machine. cs~|dkr||fd kS|dkr(||fd kS|dkr<||fd kS|dkrP||fd kS|krzx |D]}|||rbdSqbWd S)NrB rLrAr@r2r?TF)rSrL)rSrL)rSr2)rSrLr )r!r"archgarch)_supports_archgroupsr rrVs     z)get_darwin_arches.._supports_archfatr@rBintelr?fat64rAfat32Z universalr@rB)rXr\r?r@)rYr]r?rA)rZr^r?r@rB)r[r_)rappend)r!r"rIarchesrUr )rVrWrget_darwin_archess$    rbFcCsg}|dkrXg}t}|dd}x4t|dddD] }|jdjtt||fq4W|p`t}g} |pnt}|r|g| dd<t} ddl } x8| j D],} | dj dr| j | dj dddqW| jtt| | jd|sx|pt} | j d rtj| }|r|j\}}}}d j||}g}xTttt|dD]4}x,tt|||D]}|j|||fq^WqHWn| g}n*|dkrtr| jd d | g}n| g}x:| D]2}x*|D]"} |jd ||df|| fqWqWxZ|ddD]J}|dkrPx6| D].}x&|D]} |jd ||f|| fqWqWqWx*|D]"} |jd|ddd| fqRW|jd ||dfddf|jd ||ddfddfxNt|D]B\}}|jd|fddf|dkr|jd|dddfqW|S)acReturn a list of supported tags for each version specified in `versions`. :param versions: a list of string versions, of the form ["33", "32"], or None. The first version will be assumed to support our ABI. :param platform: specify the exact platform you want valid tags for, or None. If None, use the local system platform. :param impl: specify the exact implementation you want valid tags for, or None. If None, use the local interpreter impl. :param abi: specify the exact abi you want valid tags for, or None. If None, use the local interpreter abi. Nrrrz.abir6rKZnoneZmacosxz {0}_{1}_%i_%slinuxZ manylinux1z%s%s3130zpy%sanyrgrgrg)rdre)rranger`rrrrr;setimpZ get_suffixesraddr8extendsortedlistrG _osx_arch_patmatchrWr reversedintrbrRr9 enumerate)Zversionsnoarchrr0r:Z supportedr r!r"ZabisZabi3srjsuffixrTrpnameZ actual_archZtplrar1aversionir r r get_supportedsh            (   * "  rz)rt)TT)NFNNN)%__doc__Z __future__rrerrrZloggingrrOZdistutils.sysconfigZdistutils.utilrEZ pip.compatrZpip.utils.glibcrQZ getLogger__name__r$compilerorrrrr#r(r;r=rGrRrbrzZsupported_tagsZsupported_tags_noarchZimplementation_tagr r r rs>        "= ^