
ˆ`@_“  ã               @   si   d  d l  Z  d  d l Z d  d l Z d  d l m Z m Z d  d l j j Z	 Gd d „  d e	 j ƒ Z d S)é    N)ÚproductÚstarmapc               @   s¦   e  Z d  Z d Z d d „  Z d d „  Z d d „  Z d d	 „  Z d
 d „  Z e	 d d „  ƒ Z
 d d „  Z e	 d d „  ƒ Z d d d d d d „ Z d d „  Z d S)Úinstall_libz9Don't add compiled flags to filenames of non-Python filesc             C   s&   t  j j |  ƒ d  |  _ d  |  _ d  S)N)Úorigr   Úinitialize_optionsÚ	multiarchÚinstall_layout)Úself© r
   úD/tmp/pip-build-tw3_dw7d/setuptools/setuptools/command/install_lib.pyr   
   s    	zinstall_lib.initialize_optionsc             C   sj   t  j j |  ƒ |  j d d ƒ |  j d k rf t j d  d … d	 k rf d d  l } | j d ƒ |  _	 d  S)
NÚinstallr   Údebé   é   r   Ú	MULTIARCH)úinstall_layoutr   )r   r   )
r   r   Úfinalize_optionsÚset_undefined_optionsr   ÚsysÚversion_infoÚ	sysconfigÚget_config_varr   )r	   r   r
   r
   r   r      s
    (zinstall_lib.finalize_optionsc             C   s3   |  j  ƒ  |  j ƒ  } | d  k	 r/ |  j | ƒ d  S)N)Úbuildr   Úbyte_compile)r	   Úoutfilesr
   r
   r   Úrun   s    
zinstall_lib.runc                sJ   ‡  f d d †  ˆ  j  ƒ  Dƒ } t | ˆ  j ƒ  ƒ } t t ˆ  j | ƒ ƒ S)z—
        Return a collections.Sized collections.Container of paths to be
        excluded for single_version_externally_managed installations.
        c             3   s+   |  ]! } ˆ  j  | ƒ D] } | Vq q d  S)N)Ú_all_packages)Ú.0Zns_pkgÚpkg)r	   r
   r   ú	<genexpr>#   s   z-install_lib.get_exclusions.<locals>.<genexpr>)Ú_get_SVEM_NSPsr   Ú_gen_exclusion_pathsÚsetr   Ú_exclude_pkg_path)r	   Zall_packagesZ
excl_specsr
   )r	   r   Úget_exclusions   s    zinstall_lib.get_exclusionsc             C   s,   | j  d ƒ | g } t j j |  j | Œ S)zw
        Given a package name and exclusion path within that package,
        compute the full exclusion path.
        Ú.)ÚsplitÚosÚpathÚjoinÚinstall_dir)r	   r   Zexclusion_pathÚpartsr
   r
   r   r#   +   s    zinstall_lib._exclude_pkg_pathc             c   s.   x' |  r) |  V|  j  d ƒ \ }  } } q Wd S)zn
        >>> list(install_lib._all_packages('foo.bar.baz'))
        ['foo.bar.baz', 'foo.bar', 'foo']
        r%   N)Ú
rpartition)Úpkg_nameÚsepÚchildr
   r
   r   r   3   s    	zinstall_lib._all_packagesc             C   s<   |  j  j s g  S|  j d ƒ } | j } | r8 |  j  j Sg  S)z‰
        Get namespace packages (list) but only for
        single_version_externally_managed installations and empty otherwise.
        r   )ÚdistributionZnamespace_packagesÚget_finalized_commandZ!single_version_externally_managed)r	   Zinstall_cmdZsvemr
   r
   r   r    =   s
    	zinstall_lib._get_SVEM_NSPsc              c   si   d Vd Vd Vt  t d ƒ s" d St j j d d t j ƒ  ƒ }  |  d V|  d	 V|  d
 V|  d Vd S)zk
        Generate file paths to be excluded for namespace packages (bytecode
        cache files).
        z__init__.pyz__init__.pycz__init__.pyoÚget_tagNÚ__pycache__z	__init__.z.pycz.pyoz
.opt-1.pycz
.opt-2.pyc)ÚhasattrÚimpr'   r(   r)   r2   )Úbaser
   r
   r   r!   M   s    			z install_lib._gen_exclusion_pathsé   r   c                s.  | r | r | s t  ‚ ˆ j ƒ  ‰  ˆ  s\ d d  l } ˆ j | j _ t j j ˆ | | ƒ Sd d l	 m
 } d d l m ‰ g  ‰ ˆ j rù d d  l }	 |	 j d ƒ ‰ ˆ j ˆ j ˆ d	 d  … ƒ rÏ d  ‰ n* d ˆ d  d
 … ˆ j ˆ d d  … f ‰ ‡  ‡ ‡ ‡ ‡ ‡ f d d †  }
 | | | |
 ƒ ˆ S)Nr   )Úunpack_directory)ÚlogÚ
EXT_SUFFIXr   z%s-%s%sc                s¬   | ˆ  k r  ˆ j  d | ƒ d Sˆ j r| ˆ r| | j ˆ ƒ r| | j ˆ ƒ r| | j ˆ ˆ ƒ } ˆ j d t j j | ƒ ƒ ˆ j d |  t j j | ƒ ƒ ˆ j	 | ƒ | S)Nz/Skipping installation of %s (namespace package)Fzrenaming extension to %szcopying %s -> %s)
Úwarnr   ÚendswithÚreplaceÚinfor'   r(   ÚbasenameÚdirnameÚappend)ÚsrcÚdst)ÚexcludeÚ
ext_suffixr9   Ú
new_suffixr   r	   r
   r   Úpf}   s    	.z!install_lib.copy_tree.<locals>.pféýÿÿÿrH   rH   )ÚAssertionErrorr$   Údistutils.dir_utilr   Údir_utilÚ
_multiarchr   r   Ú	copy_treeZsetuptools.archive_utilr8   Ú	distutilsr9   r   r   r<   )r	   ÚinfileÚoutfileÚpreserve_modeÚpreserve_timesÚpreserve_symlinksÚlevelrN   r8   r   rG   r
   )rD   rE   r9   rF   r   r	   r   rM   b   s$    	 	*!zinstall_lib.copy_treec                s?   t  j j |  ƒ } |  j ƒ  ‰  ˆ  r; ‡  f d d †  | Dƒ S| S)Nc                s"   g  |  ] } | ˆ  k r | ‘ q Sr
   r
   )r   Úf)rD   r
   r   ú
<listcomp>’   s   	 z+install_lib.get_outputs.<locals>.<listcomp>)r   r   Úget_outputsr$   )r	   Úoutputsr
   )rD   r   rW   Ž   s
    zinstall_lib.get_outputsN)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r   r   r$   r#   Ústaticmethodr   r    r!   rM   rW   r
   r
   r
   r   r      s   
*r   )
r'   r   r5   Ú	itertoolsr   r   Zdistutils.command.install_libÚcommandr   r   r
   r
   r
   r   Ú<module>   s
   