
][\                 @   s   d  Z  d d l m Z d d l m Z m Z d d l Z d d l Z d d l Z Gd d   d e  Z	 d d   Z
 d	 d
   Z d d   Z d S)zdistutils.command.install_egg_info

Implements the Distutils 'install_egg_info' command, for installing
a package's PKG-INFO metadata.    )Command)logdir_utilNc               @   sX   e  Z d  Z d Z d Z d d g Z d	 d
   Z d d   Z d d   Z d d   Z	 d S)install_egg_infoz)Install an .egg-info file for the packagez8Install package's PKG-INFO metadata as an .egg-info fileinstall-dir=ddirectory to install toinstall-layoutNcustom installation layoutc             C   s   d  |  _  d  |  _ d  |  _ d  S)N)install_dirinstall_layoutprefix_option)self r   8/usr/lib/python3.4/distutils/command/install_egg_info.pyinitialize_options   s    		z#install_egg_info.initialize_optionsc             C   sH  |  j  d d  |  j  d d  |  j  d d  |  j ru |  j j   d k r] t d   n  |  j j   d k } n |  j r d	 } n d
 } | r d t t |  j j     t t	 |  j j
     f } nJ d t t |  j j     t t	 |  j j
     t j d  d  f } t j j |  j |  |  _ |  j g |  _ d  S)NZinstall_libr   Zinstallr   r   debunixz"unknown value for --install-layoutFTz%s-%s.egg-infoz%s-%s-py%s.egg-info   )install_dirr   )install_layoutr   )prefix_optionr   )r   r   )Zset_undefined_optionsr   lowerZDistutilsOptionErrorr   to_filename	safe_namedistributionZget_namesafe_versionZget_versionsysversionospathjoinr   targetoutputs)r   Zno_pyverbasenamer   r   r   finalize_options   s*    			"z!install_egg_info.finalize_optionsc          	   C   s  |  j  } t j j |  rG t j j |  rG t j | d |  j np t j j |  r| |  j	 t j
 |  j  f d |  n; t j j |  j  s |  j	 t j |  j f d |  j  n  t j d |  |  j st | d d d  } |  j j j |  Wd  QXn  d  S)Ndry_runz	Removing z	Creating z
Writing %swencodingzUTF-8)r"   r   r    isdirislinkr   Zremove_treer&   existsZexecuteunlinkr   makedirsr   infoopenr   ZmetadataZwrite_pkg_file)r   r"   fr   r   r   run4   s    	%#	zinstall_egg_info.runc             C   s   |  j  S)N)r#   )r   r   r   r   get_outputsB   s    zinstall_egg_info.get_outputs)r   r   r   )r	   Nr
   )
__name__
__module____qualname____doc__ZdescriptionZuser_optionsr   r%   r1   r2   r   r   r   r   r      s   	r   c             C   s   t  j d d |   S)zConvert an arbitrary string to a standard distribution name

    Any runs of non-alphanumeric/. characters are replaced with a single '-'.
    z[^A-Za-z0-9.]+-)resub)namer   r   r   r   J   s    r   c             C   s%   |  j  d d  }  t j d d |   S)zConvert an arbitrary string to a standard version string

    Spaces become dots, and all other non-alphanumeric characters become
    dashes, with runs of multiple dashes condensed to a single dash.
     .z[^A-Za-z0-9.]+r7   )replacer8   r9   )r   r   r   r   r   R   s    r   c             C   s   |  j  d d  S)z|Convert a project or version name to its filename-escaped form

    Any '-' characters are currently replaced with '_'.
    r7   _)r=   )r:   r   r   r   r   \   s    r   )r6   Zdistutils.cmdr   Z	distutilsr   r   r   r   r8   r   r   r   r   r   r   r   r   <module>   s   $?
