B
    ülc7  ã               @  s^   d dl m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dd	œd
d„ZdS )é    )ÚannotationsN)Ú
WheelError)Ú	WheelFilez6^(?P<namever>(?P<name>.+?)-(?P<ver>\d.*?))\.dist-info$s   Build: (\d\w*)$Ústrz
str | None)Ú	directoryÚdest_dirÚbuild_numberc          	     sD  ‡ fdd„t  ˆ ¡D ƒ}t|ƒdkr4tdˆ › ƒ‚n|sFtdˆ › ƒ‚|d }t |¡ d¡}d}t j ˆ |d	¡}t	|ƒj}g }	xL|D ]D}
|
 
d
¡r®|	 |
 d¡d  ¡ ¡ q†|
 
d¡r†|
 d¡d  ¡ }q†W |	sàtd |¡ƒ‚W dQ R X |dk	rö|n|}|dk	r|r|d| 7 }||kr|r4d|  d¡nd}t	|dƒH}| ¡ }t ||¡\}}|sj||7 }| d¡ | ¡  | |¡ W dQ R X tdd„ |	D ƒƒ}tdd„ |	D ƒƒ}tdd„ |	D ƒƒ}d d |¡d |¡d |¡g¡}t j ||› d|› d¡}t|dƒ&}td|› dddd | ˆ ¡ W d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	   ú-lib/python3.7/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  s   h | ]}|  d ¡d ’qS )r   r   )Úsplit)r   Útagr	   r	   r   ú	<setcomp>O   s    zpack.<locals>.<setcomp>c             S  s   h | ]}|  d ¡d ’qS )r   r   )r   )r   r   r	   r	   r   r   P   s    c             S  s   h | ]}|  d ¡d ’qS )r   é   )r   )r   r   r	   r	   r   r   Q   s    Ú.z.whlÚwzRepacking wheel as z...Ú T)ÚendÚflushZOK)r
   ÚlistdirÚlenr   r   r   Úgroupr   r   ÚopenÚ
startswithÚappendr   ÚrstripÚformatÚencodeÚreadÚBUILD_NUM_REÚsubnÚseekÚtruncateÚwriteÚsortedr   ÚprintZwrite_files)r   r   r   Zdist_info_dirsZdist_info_dirZname_versionZexisting_build_numberZwheel_file_pathÚfZtagsÚlineZreplacementZwheel_file_contentZnum_replacedZimplsZabiversZ	platformsZtaglineZ
wheel_pathZwfr	   )r   r   Úpack   s\    







"r5   )Z
__future__r   Zos.pathr
   ÚreZ	wheel.clir   Zwheel.wheelfiler   Úcompiler   r,   r5   r	   r	   r	   r   Ú<module>   s   

