
`@_                 @   s   d  d l  m Z m 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 Z Gd d   d e  Z d S)    )logdir_utilN)map)Command)unpack_archivec               @   s   e  Z d  Z d Z d Z d g Z d d   Z d d   Z d	 d
   Z d d   Z	 d d   Z
 d d   Z d Z d Z e d d    Z d d   Z d S) install_egg_infoz.Install an .egg-info directory for the packageinstall-dir=ddirectory to install toc             C   s   d  |  _  d  |  _ d  |  _ d  S)N)install_dirinstall_layoutprefix_option)self r   I/tmp/pip-build-tw3_dw7d/setuptools/setuptools/command/install_egg_info.pyinitialize_options   s    		z#install_egg_info.initialize_optionsc             C   s6  |  j  d d  |  j  d d  t j d k r? |  j  d d  |  j d  } t j d  d  | j | j  j   d } |  j r |  j j	   d k r t
 d
   |  j j	   |  _ | j d t j d  } n4 |  j sd t j k r n | j d t j d  } | j |  _ t j j |  j |  |  _ g  |  _ d  S)Ninstall_libr   installr   i  r   egg_infoz	.egg-infodebz"unknown value for --install-layoutz-py%s real_prefix)install_dirr   )install_layoutr   )prefix_optionr   )zdeb)set_undefined_optionssys
hexversionget_finalized_commandpkg_resourcesDistributionegg_nameZegg_versionr   lowerDistutilsOptionErrorreplacePY_MAJORr   __dict__r   sourceospathjoinr   targetoutputs)r   Zei_cmdbasenamer   r   r   finalize_options   s(    		z!install_egg_info.finalize_optionsc             C   s   |  j  d  t j j |  j  rT t j j |  j  rT t j |  j d |  j n8 t j j	 |  j  r |  j
 t j |  j f d |  j  |  j s t j |  j  |  j
 |  j f  d |  j |  j f  |  j   d  S)Nr   dry_runz	Removing zCopying %s to %s)run_commandr(   r)   isdirr+   islinkr   remove_treer/   existsexecuteunlinkr   ensure_directorycopytreer'   install_namespaces)r   r   r   r   run3   s    +#	 zinstall_egg_info.runc             C   s   |  j  S)N)r,   )r   r   r   r   get_outputs@   s    zinstall_egg_info.get_outputsc                s,     f d d   } t    j   j |  d  S)Nc                s   x1 d D]) } |  j  |  s, d | |  k r d  Sq W  j rl   j d	 k rl |  j  d  rl t j d  d  S  j j |  t j d |  |  | S)
N.svn/CVS//r   zSOURCES.txtzSkipping SOURCES.txtzCopying %s to %s)r<   r=   )zdeb)
startswithr   r   infor,   appenddebug)srcdstskip)r   r   r   skimmerE   s    'z*install_egg_info.copytree.<locals>.skimmer)r   r'   r+   )r   rF   r   )r   r   r8   C   s    zinstall_egg_info.copytreec          	   C   s   |  j    } | s d  St j j |  j  \ } } | d 7} |  j j |  t j d |  t	 |  j
 |  } |  j r t |  d  St | d   } | j |  Wd  QRXd  S)Nz
-nspkg.pthzInstalling %swt)_get_all_ns_packagesr(   r)   splitextr+   r,   rA   r   r@   r   _gen_nspkg_liner/   listopen
writelines)r   nspfilenameextlinesfr   r   r   r9   U   s    
	
z#install_egg_info.install_namespacesimport sys, types, os@p = os.path.join(sys._getframe(1).f_locals['sitedir'], *%(pth)r)2ie = os.path.exists(os.path.join(p,'__init__.py'))Im = not ie and sys.modules.setdefault(%(pkg)r, types.ModuleType(%(pkg)r))7mp = (m or []) and m.__dict__.setdefault('__path__',[])(p not in mp) and mp.append(p)4m and setattr(sys.modules[%(parent)r], %(child)r, m)c             C   sm   t  |  } t | j d   } |  j } | j d  \ } } } | rU | |  j 7} d j |  t   d S)N.;
)strtuplesplit_nspkg_tmpl
rpartition_nspkg_tmpl_multir*   locals)clspkgpthZ
tmpl_linesparentsepchildr   r   r   rJ   w   s    	z install_egg_info._gen_nspkg_linec             C   sl   t    } xV |  j j p g  D]B } | j d  } x* | r] | j d j |   | j   q4 Wq Wt |  S)z,Return sorted list of all package namespacesrZ   )setdistributionZnamespace_packagesr_   addr*   popsorted)r   rN   re   r   r   r   rH      s    		z%install_egg_info._get_all_ns_packagesN)r   r	   r
   )rS   rT   rU   rV   rW   rX   )rY   )__name__
__module____qualname____doc__descriptionuser_optionsr   r.   r:   r;   r8   r9   r`   rb   classmethodrJ   rH   r   r   r   r   r      s$   	     r   )	distutilsr   r   r(   r   Zsetuptools.extern.six.movesr   
setuptoolsr   Zsetuptools.archive_utilr   r   r   r   r   r   r   <module>   s   