B
    v9aº  ã               @   sD   d dl Z d dlmZ d dlT d dlmZ dd„ ZG dd„ deƒZdS )	é    N)ÚCommand)Ú*)Úget_platformc              C   sT   ddl m}  g }x,tjD ]"}| d| d tj| d f¡ qW | |ƒ}| d¡ d S )Nr   )ÚFancyGetoptzformats=é   z'List of available distribution formats:)Zdistutils.fancy_getoptr   ÚbdistÚformat_commandsÚappendÚformat_commandÚ
print_help)r   ÚformatsÚformatZpretty_printer© r   ú/usr/lib/python3.7/bdist.pyÚshow_formats   s    r   c            
   @   s–   e Zd ZdZddddeƒ  fdddd	d
gZdgZdddefgZdZ	dddœZ
dddddddddg	Zddddddd d!d"d#œ	Zd$d%„ Zd&d'„ Zd(d)„ ZdS )*r   z$create a built (binary) distribution)zbdist-base=Úbz4temporary directory for creating built distributionsz
plat-name=Úpz;platform name to embed in generated filenames (default: %s))zformats=Nz/formats for distribution (comma-separated list))z	dist-dir=Údz=directory to put final built distributions in [default: dist])z
skip-buildNz2skip rebuilding everything (for testing/debugging))zowner=Úuz@Owner name used when creating a tar file [default: current user])zgroup=ÚgzAGroup name used when creating a tar file [default: current group]z
skip-buildzhelp-formatsNz$lists available distribution formats)Ú	bdist_rpmÚgztarÚzip)ÚposixÚntÚrpmÚbztarÚxztarÚztarÚtarÚwininstÚmsi)r   zRPM distribution)Ú
bdist_dumbzgzip'ed tar file)r"   zbzip2'ed tar file)r"   zxz'ed tar file)r"   zcompressed tar file)r"   ztar file)Zbdist_wininstzWindows executable installer)r"   zZIP file)Z	bdist_msizMicrosoft Installer)	r   r   r   r   r   r   r    r   r!   c             C   s.   d | _ d | _d | _d | _d| _d | _d | _d S )Nr   )Ú
bdist_baseÚ	plat_namer   Údist_dirÚ
skip_buildÚgroupÚowner)Úselfr   r   r   Úinitialize_optionsQ   s    zbdist.initialize_optionsc             C   s´   | j d kr(| jrtƒ | _ n|  d¡j | _ | jd krT|  d¡j}tj |d| j  ¡| _|  	d¡ | j
d kr y| jtj g| _
W n" tk
rž   tdtj ƒ‚Y nX | jd kr°d| _d S )NZbuildzbdist.r   z;don't know how to create built distributions on platform %sZdist)r$   r&   r   Zget_finalized_commandr#   Ú
build_baseÚosÚpathÚjoinZensure_string_listr   Údefault_formatÚnameÚKeyErrorZDistutilsPlatformErrorr%   )r)   r+   r   r   r   Úfinalize_optionsZ   s$    





zbdist.finalize_optionsc          	   C   sÎ   g }xH| j D ]>}y| | j| d ¡ W q tk
rH   td| ƒ‚Y qX qW xztt| j ƒƒD ]h}|| }|  |¡}|| jkrŠ| j | |_	|dkr¢| j
|_
| j|_|||d d … kr¼d|_|  |¡ q^W d S )Nr   zinvalid format '%s'r"   r   )r   r	   r
   r1   ZDistutilsOptionErrorÚrangeÚlenZreinitialize_commandÚno_format_optionr   r(   r'   Z	keep_tempZrun_command)r)   Zcommandsr   ÚiZcmd_nameZsub_cmdr   r   r   Úrunv   s"    

z	bdist.run)Ú__name__Ú
__module__Ú__qualname__Údescriptionr   Zuser_optionsZboolean_optionsr   Zhelp_optionsr5   r/   r   r
   r*   r2   r7   r   r   r   r   r      s<   

	r   )r,   Zdistutils.corer   Zdistutils.errorsZdistutils.utilr   r   r   r   r   r   r   Ú<module>   s
   