U
    ݱe&                     @  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 d dl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	B}t
tjjd
|}|dg }	|d}
|	std|W 5 Q R X |dk	r|n|
}|dk	r*|d= |r||d< |d| 7 }||
kr*t	|d}t|dd| W 5 Q R X t|	}t j|| d| d}t|d&}td| dddd |  W 5 Q R X 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   M/var/www/html/apps/cwerpapp/env/lib/python3.8/site-packages/wheel/cli/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TagZBuildzCNo tags present in {}/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getformatr   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   sF    




r7   z	list[str])r5   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>R   s     z"compute_tagline.<locals>.<setcomp>c                 S  s   h | ]}| d d qS )r   r   r8   r:   r   r   r   r<   S   s     c                 S  s   h | ]}| d d qS )r      r8   r:   r   r   r   r<   T   s     r   .)sortedr   )r5   ZimplsZabivers	platformsr   r   r   r0   L   s    r0   )
__future__r   email.policyr)   os.pathr   reemail.generatorr   email.parserr   Z	wheel.clir   Zwheel.wheelfiler   compiler   r7   r0   r   r   r   r   <module>   s   
=