???<!-- GIF89;a -->
123123123123
.....................................................................................................................................???<!-- GIF89;a -->
123123123123
.....................................................................................................................................3
Pf*                 @   s  d Z ddlmZ ddlZddlZddlZddlZddlZyddlZW n e	k
rb   ddl
jZY nX ddlZddlmZ ddlZejeZejdZdd Zdd	 Zd
d Zdd Zdd Zd!ddZdd Zdd Zdd Zdd Zdd Z d"ddZ!e! Z"e!dd Z#e Z$dS )#z2Generate and work with PEP 425 Compatibility Tags.    )absolute_importN)OrderedDictz(.+)_(\d+)_(\d+)_(.+)c             C   sB   y
t j| S  tk
r< } ztjdj|t d S d }~X nX d S )Nz{0})	sysconfigget_config_varIOErrorwarningswarnformatRuntimeWarning)vare r    /usr/lib/python3.6/pep425tags.pyr      s
    
r   c              C   s:   t tdrd} n&tjjdr"d} ntjdkr2d} nd} | S )z'Return abbreviated implementation name.pypy_version_infoppjavaZjyZcliZipcp)hasattrsysplatform
startswith)Zpyimplr   r   r   get_abbr_impl!   s    

r   c              C   s.   t d} |  st dkr*djttt } | S )zReturn implementation version.py_version_nodotr    )r   r   joinmapstrget_impl_version_info)Zimpl_verr   r   r   get_impl_ver.   s    r   c               C   s:   t  dkr"tjd tjjtjjfS tjd tjd fS dS )zQReturn sys.version_info-like tuple for use in decrementing the minor
    version.r   r      N)r   r   version_infor   majorminorr   r   r   r   r   6   s    

r   c               C   s   dj t t S )z;
    Returns the Tag for this specific implementation.
    z{0}{1})r	   r   r   r   r   r   r   get_impl_tagA   s    r#   Tc             C   s.   t | }|dkr&|r tjd|  | S ||kS )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)r   loggerdebug)r   Zfallbackexpectedr   valr   r   r   get_flagH   s    r(   c                 s   t d} t  |  r dkrttdrd}d}d}tddd  dkd	rLd
}td fdd dkd	rjd}tddd d dkotjdk drtjdk rd}d t |||f }n@| r| jdrd| jdd  }n| r| j	ddj	dd}nd}|S )zXReturn the ABI tag based on SOABI (if available) or emulate SOABI
    (CPython 2, PyPy).SOABIr   r   
maxunicoder   Py_DEBUGc               S   s
   t tdS )Ngettotalrefcount)r   r   r   r   r   r   <lambda>^   s    zget_abi_tag.<locals>.<lambda>)r   dWITH_PYMALLOCc                  s    dkS )Nr   r   r   )implr   r   r-   b   s    mZPy_UNICODE_SIZEc               S   s
   t jdkS )Ni )r   r*   r   r   r   r   r-   f   s          )r&   r   uz
%s%s%s%s%szcpython--r   ._N)r   r   )r3   r3   )r3   r3   )
r   r   r   r   r(   r    r   r   splitreplace)Zsoabir.   r1   r4   abir   )r0   r   get_abi_tagT   s8    

r;   c               C   s
   t jdkS )Ni)r   maxsizer   r   r   r   _is_running_32bitv   s    r=   c              C   s   t jdkr^tj \} }}| jd}|dkr6t r6d}n|dkrHt rHd}dj|d |d	 |S tjj j	dd
j	dd
}|dkrt rd}|S )z0Return our platform name 'win32', 'linux_x86_64'darwinr6   x86_64i386ppc64ppczmacosx_{0}_{1}_{2}r   r   r7   r5   linux_x86_64
linux_i686)
r   r   Zmac_verr8   r=   r	   	distutilsutilget_platformr9   )releaser7   machineZ	split_verresultr   r   r   rG   z   s    

rG   c              C   sJ   t  dkrdS ydd l} t| jS  ttfk
r8   Y nX tjjj	ddS )NrC   rD   Fr         )rC   rD   )
rG   
_manylinuxboolZmanylinux1_compatibleImportErrorAttributeErrorpipZutilsZglibcZhave_compatible_glibc)rM   r   r   r   is_manylinux1_compatible   s    

rR   c                sv   g } fdd t ddddg | ||r8|j| x.D ]&}|| kr> | ||r>|j| q>W |jd |S )zReturn a list of supported arches (including group arches) for
    the given major, minor and machine architecture of an macOS machine.
    c                s~   |dkr| |fd
kS |dkr(| |fdkS |dkr<| |fdkS |dkrP| |fdkS |krzx | D ]} | ||rbdS qbW d	S )NrB   
   rL   rA   r@   r2   r?   TF)rS   rL   )rS   rL   )rS   r2   )rS   rL   r   )r!   r"   archgarch)_supports_archgroupsr   r   rV      s    z)get_darwin_arches.<locals>._supports_archfatr@   rB   intelr?   fat64rA   fat32Z	universalr@   rB   )rX   r\   r?   r@   )rY   r]   r?   rA   )rZ   r^   r?   r@   rB   )r[   r_   )r   append)r!   r"   rI   archesrU   r   )rV   rW   r   get_darwin_arches   s    $


rb   Fc             C   s  g }| dkrXg } t  }|dd }x4t|d ddD ] }| jdjtt||f  q4W |p`t }g }	|pnt }|r|g|	dd< t }
ddl	}x8|j
 D ],}|d jdr|
j|d jddd  qW |	jtt|
 |	jd |sx|pt }|jd	rtj|}|r|j \}}}}d
j||}g }xTttt|d D ]4}x,tt|||D ]}|j|||f  q^W qHW n|g}n*|dkrt r|jdd|g}n|g}x:|	D ]2}x*|D ]"}|jd|| d f ||f qW qW xZ| dd D ]J}|dkrP x6|
D ].}x&|D ]}|jd||f ||f qW qW qW x*|D ]"}|jd| d d  d|f qRW |jd|| d f ddf |jd|| d d f ddf xNt| D ]B\}}|jd|f ddf |dkr|jd|d  ddf qW |S )ac  Return 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.
    Nr   r   r   z.abir6   rK   ZnoneZmacosxz{0}_{1}_%i_%slinuxZ
manylinux1z%s%s3130zpy%sanyrg   rg   rg   )rd   re   )r   ranger`   r   r   r   r   r;   setimpZget_suffixesr   addr8   extendsortedlistrG   _osx_arch_patmatchrW   r	   reversedintrb   rR   r9   	enumerate)Zversionsnoarchr   r0   r:   Z	supportedr    r!   r"   ZabisZabi3srj   suffixrT   rp   nameZactual_archZtplra   r1   aversionir   r   r   get_supported   sh     




 

(


*
" 
rz   )rt   )TT)NFNNN)%__doc__Z
__future__r   rer   r   r   Zloggingr   rO   Zdistutils.sysconfigZdistutils.utilrE   Z
pip.compatr   Zpip.utils.glibcrQ   Z	getLogger__name__r$   compilero   r   r   r   r   r#   r(   r;   r=   rG   rR   rb   rz   Zsupported_tagsZsupported_tags_noarchZimplementation_tagr   r   r   r   <module>   s>   


"= 
^
