o
    1ήcU@                     @   s  U d dl Z d dlZd dlZd dlZd dlZd dlmZ d dlmZm	Z	m
Z
mZmZmZmZmZmZmZ ddlmZmZ e eZee Zeeef Zdddd	d
dZeeef ed< ejdkZG dd dZ dede	e  fddZ!dHdede"deeedf fddZ#dedefddZ$dede"fddZ%dHdede"dee fd d!Z&			dIdd"dee d#ee
e  d$ee
e  de"dee  f
d%d&Z'dee fd'd(Z(			dIdd"d)ee d#ee
e  d$ee
e  de"dee  f
d*d+Z)dedee fd,d-Z*			dIdee d)ee d$ee
e  dee  fd.d/Z+efd0ed1e"defd2d3Z,d4ed5edee fd6d7Z-	dJd4ee d0ee dee fd8d9Z.efd1e"dee fd:d;Z/dee fd<d=Z0dee fd>d?Z1defd@dAZ2dd"de"defdBdCZ3d4edefdDdEZ4dd"de"dee  fdFdGZ5dS )K    N)EXTENSION_SUFFIXES)
Dict	FrozenSetIterableIteratorListOptionalSequenceTupleUnioncast   )
_manylinux
_musllinuxpycpppipjy)pythoncpythonpypy
ironpythonjythonINTERPRETER_SHORT_NAMESl        c                   @   s   e Zd ZdZg dZdedededdfdd	Zedefd
dZedefddZ	edefddZ
dedefddZdefddZdefddZdefddZdS )Tagz
    A representation of the tag triple for a wheel.

    Instances are considered immutable and thus are hashable. Equality checking
    is also supported.
    )_interpreter_abi	_platform_hashinterpreterabiplatformreturnNc                 C   s8   |  | _|  | _|  | _t| j| j| jf| _d S N)lowerr   r   r   hashr   )selfr    r!   r"    r(   5/tmp/pip-target-vg8gfxp4/lib/python/packaging/tags.py__init__5   s   


zTag.__init__c                 C      | j S r$   )r   r'   r(   r(   r)   r    @      zTag.interpreterc                 C   r+   r$   )r   r,   r(   r(   r)   r!   D   r-   zTag.abic                 C   r+   r$   )r   r,   r(   r(   r)   r"   H   r-   zTag.platformotherc                 C   s>   t |tstS | j|jko| j|jko| j|jko| j|jkS r$   )
isinstancer   NotImplementedr   r   r   r   )r'   r.   r(   r(   r)   __eq__L   s   



z
Tag.__eq__c                 C   r+   r$   )r   r,   r(   r(   r)   __hash__W   s   zTag.__hash__c                 C   s   | j  d| j d| j S )N-)r   r   r   r,   r(   r(   r)   __str__Z   s   zTag.__str__c                 C   s   d|  dt |  dS )N<z @ >)idr,   r(   r(   r)   __repr__]   s   zTag.__repr__)__name__
__module____qualname____doc__	__slots__strr*   propertyr    r!   r"   objectboolr1   intr2   r4   r8   r(   r(   r(   r)   r   +   s    r   tagr#   c              	   C   s`   t  }| d\}}}|dD ]}|dD ]}|dD ]}|t||| qqqt|S )z
    Parses the provided tag (e.g. `py3-none-any`) into a frozenset of Tag instances.

    Returning a set is required due to the possibility that the tag is a
    compressed tag set.
    r3   .)setsplitaddr   	frozenset)rC   tagsinterpretersabis	platformsr    r!   	platform_r(   r(   r)   	parse_taga   s   rN   Fnamewarnc                 C   s&   t | }|d u r|rtd|  |S )Nz>Config variable '%s' is unset, Python ABI tag may be incorrect)	sysconfigget_config_varloggerdebug)rO   rP   valuer(   r(   r)   _get_config_varq   s   
rV   stringc                 C   s   |  dd ddS )NrD   _r3   )replace)rW   r(   r(   r)   _normalize_stringz   s   rZ   python_versionc                 C   s   t | dkot| dkS )zj
    Determine if the Python version supports abi3.

    PEP 384 was first implemented in Python 3.2.
    r   )      )lentuple)r[   r(   r(   r)   _abi3_applies~   s   r`   
py_versionc              	   C   s   t | } g }t| d d }d } }}td|}ttd}dtv }	|s,|d u r.|s,|	r.d}| dk rXtd|}
|
s=|
d u r?d	}| d
k rWtd|}|dksU|d u rWtjdkrWd}n
|rb|d|  |ddj	||||d |S )Nr]    Py_DEBUGgettotalrefcountz_d.pydd)r\      WITH_PYMALLOCm)r\   r\   Py_UNICODE_SIZE   i ur   r   z"cp{version}{debug}{pymalloc}{ucs4})versionrT   pymallocucs4)
r_   _version_nodotrV   hasattrsysr   
maxunicodeappendinsertformat)ra   rP   rK   rl   rT   rm   rn   
with_debughas_refcounthas_extwith_pymallocunicode_sizer(   r(   r)   _cpython_abis   s>   



r{   rP   rK   rL   c             	   #   sB   | s
t jdd } dt| dd   |du r't| dkr%t| |}ng }t|}dD ]}z|| W q- ty?   Y q-w t|pEt }|D ]}|D ]	}t	 ||V  qMqIt
| rh fdd|D E dH   fdd|D E dH  t
| rt| d d dd	D ]}|D ]}d
jt| d |fd t	 d|V  qqdS dS )a  
    Yields the tags for a CPython interpreter.

    The tags consist of:
    - cp<python_version>-<abi>-<platform>
    - cp<python_version>-abi3-<platform>
    - cp<python_version>-none-<platform>
    - cp<less than python_version>-abi3-<platform>  # Older Python versions down to 3.2.

    If python_version only specifies a major version then user-provided ABIs and
    the 'none' ABItag will be used.

    If 'abi3' or 'none' are specified in 'abis' then they will be yielded at
    their normal position and not at the beginning.
    Nr]   r   r   )abi3nonec                 3       | ]	}t  d |V  qdS )r}   Nr   .0rM   r    r(   r)   	<genexpr>       zcpython_tags.<locals>.<genexpr>c                 3   r   )r~   Nr   r   r   r(   r)   r      r   zcp{version}r   rl   r}   )rq   version_inforo   r^   r{   listremove
ValueErrorplatform_tagsr   r`   rangeru   )r[   rK   rL   rP   explicit_abir!   rM   minor_versionr(   r   r)   cpython_tags   sB   r   c                  c   s"    t d} | rt| V  d S d S )NSOABI)rQ   rR   rZ   )r!   r(   r(   r)   _generic_abi   s
   
r   r    c                c   s    | st  }t|d}d||g} |du rt }t|pt }t|}d|vr-|d |D ]}|D ]	}t| ||V  q3q/dS )z
    Yields the tags for a generic interpreter.

    The tags consist of:
    - <interpreter>-<abi>-<platform>

    The "none" ABI will be added if it was not explicitly provided.
    r|   rb   Nr~   )interpreter_nameinterpreter_versionjoinr   r   r   rs   r   )r    rK   rL   rP   interp_nameinterp_versionr!   rM   r(   r(   r)   generic_tags   s    

r   c                 c   s|    t | dkrdt| dd  V  d| d  V  t | dkr:t| d d ddD ]}dt| d |f V  q+dS dS )z
    Yields Python versions in descending order.

    After the latest version, the major-only version will be yielded, and then
    all previous versions of that major version.
    r   r   Nr]   r   r   )r^   ro   r   )ra   minorr(   r(   r)   _py_interpreter_range  s   r   c                 c   sz    | s
t jdd } t|pt }t| D ]}|D ]	}t|d|V  qq|r-t|ddV  t| D ]	}t|ddV  q1dS )z
    Yields the sequence of tags that are compatible with a specific version of Python.

    The tags consist of:
    - py*-none-<platform>
    - <interpreter>-none-any  # ... if `interpreter` is provided.
    - py*-none-any
    Nr]   r~   any)rq   r   r   r   r   r   )r[   r    rL   rl   rM   r(   r(   r)   compatible_tags  s   r   archis_32bitc                 C   s   |s| S |  drdS dS )Nppci386)
startswith)r   r   r(   r(   r)   	_mac_arch0  s
   
r   rl   cpu_archc                 C   s   |g}|dkr| dk rg S | g d n7|dkr'| dk rg S | g d n%|dkr;| dks3| dk r5g S |d n|d	krL| d
krEg S | ddg |dv rU|d |dv r^|d |S )Nx86_64)
   rj   )intelfat64fat32r   )r   r   fatppc64)r      r   r   )r      r   r   >   arm64r   
universal2>   r   r   r   r   r   	universal)extendrs   )rl   r   formatsr(   r(   r)   _mac_binary_formats:  s,   

r   c           
      c   s   t  \}}}| du rFtdttt|ddd } | dkrEtjt	j
dddgd	d
ditjd	dj}tdttt|ddd } n| } |du rQt|}n|}d| kr}| dk r}t| d ddD ]}d|f}t||}|D ]}djd||dV  qpqc| dkrt| d ddD ]}	|	df}t||}|D ]}dj|	d|dV  qq| dkr|dkrtdddD ]}d|f}t||}|D ]}dj|d |d |dV  qqdS tdddD ]}d|f}d}dj|d |d |dV  qdS dS )aD  
    Yields the platform tags for a macOS system.

    The `version` parameter is a two-item tuple specifying the macOS version to
    generate platform tags for. The `arch` parameter is the CPU architecture to
    generate platform tags for. Both parameters default to the appropriate value
    for the current system.
    N
MacVersionrD   r]   )r      z-sSz-cz-import platform; print(platform.mac_ver()[0])TSYSTEM_VERSION_COMPAT0)checkenvstdoutuniversal_newlines)r   r   )   r   r   r   r   z&macosx_{major}_{minor}_{binary_format})majorr   binary_formatr   r   r   r\   r   )r"   mac_verr   r_   maprB   rF   
subprocessrunrq   
executablePIPEr   r   r   r   ru   )
rl   r   version_strrX   r   r   compat_versionbinary_formatsr   major_versionr(   r(   r)   mac_platformsZ  s   ""








r   c                 c   sh    t t }| r|dkrd}n|dkrd}|dd\}}t||E d H  t|E d H  |V  d S )Nlinux_x86_64
linux_i686linux_aarch64linux_armv7lrX   r   )rZ   rQ   get_platformrF   r   r   r   )r   linuxrX   r   r(   r(   r)   _linux_platforms  s   
r   c                   c   s    t t V  d S r$   )rZ   rQ   r   r(   r(   r(   r)   _generic_platforms  s   r   c                   C   s*   t  dkr	t S t  dkrt S t S )z;
    Provides the platform tags for this installation.
    DarwinLinux)r"   systemr   r   r   r(   r(   r(   r)   r     s
   r   c                  C   s   t jj} t| p
| S )z6
    Returns the name of the running interpreter.
    )rq   implementationrO   r   get)rO   r(   r(   r)   r     s   r   c                 C   s2   t d| d}|rt|}|S ttjdd }|S )z9
    Returns the version of the running interpreter.
    py_version_nodotr|   Nr]   )rV   r>   ro   rq   r   )rP   rl   r(   r(   r)   r     s   r   c                 C   s   d tt| S )Nrb   )r   r   r>   r   r(   r(   r)   ro     s   ro   c                 c   sl    t  }|dkrt| dE dH  nt E dH  |dkrd}n|dkr*dt| d }nd}t|dE dH  dS )z
    Returns the sequence of tag triples for the running interpreter.

    The order of the sequence corresponds to priority order for the
    interpreter, from most to least important.
    r   r|   Nr   pp3r   )r   r   r   r   r   )rP   r   interpr(   r(   r)   sys_tags  s   r   )F)NNN)NN)6loggingr"   r   rq   rQ   importlib.machineryr   typingr   r   r   r   r   r   r	   r
   r   r   rb   r   r   	getLoggerr9   rS   rB   PythonVersionr   r   r>   __annotations__maxsize_32_BIT_INTERPRETERr   rN   rA   rV   rZ   r`   r{   r   r   r   r   r   r   r   r   r   r   r   r   r   ro   r   r(   r(   r(   r)   <module>   s   
0

	6"		%


9





!
X 