a
    b3j                     @  s~   d dl mZ d dlZd dlZd dlZd dlmZ d dl	m
Z
 ddlmZmZ edZddd	d
dddZdddddZdS )    )annotationsN)BytesGenerator)BytesParser   )
WheelError	WheelFilez6^(?P<namever>(?P<name>.+?)-(?P<ver>\d.*?))\.dist-info$strz
str | NoneNone)	directorydest_dirbuild_numberreturnc                   s   fddt  D }t|dkr4td  n|sFtd  |d }t|d}t j |d}t	|d	N}t
tjjd
|}|dg }	|d}
|	std| dW d   n1 s0    Y  |dur|n|
}|durX|d= |r||d< |d| 7 }||
krXt	|d"}t|dd| W d   n1 sN0    Y  t|	}t j|| d| d}t|d0}td| dddd |  W d   n1 s0    Y  td dS )aB  Repack a previously unpacked wheel directory into a new wheel file.

    The .dist-info/WHEEL file must contain one or more tags so that the target
    wheel file name can be determined.

    :param directory: The unpacked wheel directory
    :param dest_dir: Destination directory (defaults to the current directory)
    c                   s0   g | ](}t jt j |rt|r|qS  )ospathisdirjoinDIST_INFO_REmatch).0fnr
   r   q/www/wwwroot/dpstar/app/297b3aabda72fedb274352021c2dd8b5_venv/lib/python3.9/site-packages/wheel/_commands/pack.py
<listcomp>   s    zpack.<locals>.<listcomp>   z)Multiple .dist-info directories found in z#No .dist-info directories found in r   ZnameverZWHEELrb)policyTagBuildzNo tags present in z./WHEEL; cannot determine target wheel filenameN-wb)maxheaderlenz.whlwzRepacking wheel as z... T)endflushOK)r   listdirlenr   r   r   groupr   r   openr   emailr   compat32parseget_allgetr   flattencompute_tagliner   printZwrite_files)r
   r   r   Zdist_info_dirsdist_info_dirZname_versionZwheel_file_pathfinfotagsZexisting_build_numberZtagline
wheel_pathZwfr   r   r   pack   sB    



"

2*r8   z	list[str])r6   r   c                 C  sX   t dd | D }t dd | D }t dd | D }dd|d|d|gS )zcCompute a tagline from a list of tags.

    :param tags: A list of tags
    :return: A tagline
    c                 S  s   h | ]}| d d qS )r   r   splitr   tagr   r   r   	<setcomp>Q       z"compute_tagline.<locals>.<setcomp>c                 S  s   h | ]}| d d qS )r   r   r9   r;   r   r   r   r=   R   r>   c                 S  s   h | ]}| d d qS )r   r   r9   r;   r   r   r   r=   S   r>   r   .)sortedr   )r6   ZimplsZabivers	platformsr   r   r   r1   K   s    r1   )
__future__r   email.policyr+   os.pathr   reemail.generatorr   email.parserr   Z	wheelfiler   r   compiler   r8   r1   r   r   r   r   <module>   s   
=