U
    ZÊ¹j  ã                   @  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	ƒ�D}t
tjjd
� |¡}| dg ¡}	| d¡}
|	s¸td|› 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/bwave/python/venv/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nameverÚWHEELÚrb)ÚpolicyÚTagZ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    

þ

ÿ

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   
=