o
    6_                     @   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	 e
dZe
dZdd ZdS )	    )print_functionN)
WheelError)	WheelFilez6^(?P<namever>(?P<name>.+?)-(?P<ver>\d.*?))\.dist-info$s   Build: (\d\w*)$c                    sf   fddt  D }t|dkrtd |s"td |d }t|d}d}t j	 |d	}t
|8}g }	|D ]"}
|
d
rU|	|
dd   qA|
drc|
dd  }qA|	smtd|W d   n1 sww   Y  |dur|n|}|dur|r|d| 7 }||kr|rd| dnd}t
|d!}| }t||d s||7 }|  || W d   n1 sw   Y  tdd |	D }tdd |	D }tdd |	D }d	d	|d	|d	|g}t j	|d||}t|d}td|dd tj  |  W d   n	1 s(w   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	directoryr   .lib/python3.10/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nameverNZWHEELzTag:  zBuild: zCNo tags present in {}/WHEEL; cannot determine target wheel filename-zBuild: %s
ascii    zrb+c                 S      h | ]	}| d d qS )r   r   splitr   tagr   r   r   	<setcomp>C       zpack.<locals>.<setcomp>c                 S   r   )r   r   r   r   r   r   r   r   D   r   c                 S   r   )r      r   r   r   r   r   r   E   r   .z	{}-{}.whlwzRepacking wheel as {}... )endZOK)r   listdirlenr   formatr
   r   groupr   r	   open
startswithappendr   rstripencodereadBUILD_NUM_REsubntruncatewritesortedr   printsysstdoutflushZwrite_files)r   Zdest_dirZbuild_numberZdist_info_dirsZdist_info_dirZname_versionZexisting_build_numberZwheel_file_pathftagslineZreplacementZwheel_file_contentZimplsZabiversZ	platformsZtaglineZ
wheel_pathZwfr   r   r   pack   s^   



	"
r9   )Z
__future__r   Zos.pathr   rer3   Z	wheel.clir   Zwheel.wheelfiler   compiler
   r-   r9   r   r   r   r   <module>   s    

