
`@_@                 @   s  d  Z  d d l Z d d l 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 m Z m Z d d l Z d d l m Z d d l m Z m Z m Z d d	 l m Z d
 d d d d d d g Z e j j Z d Z d Z d g Z Gd d   d e  Z  Gd d   d e   Z! e  j" Z# e j$ j% Z% e e  Z Gd d   d e  Z e e j$ _ d d   Z& e j' d d  Z( e( e j) _( d S)z@Extensions to the 'distutils' for large or complex distributions    N)Command)convert_path)fnmatchcase)filterfalsemap)	Extension)DistributionFeature_get_unpatched)Requiresetupr   r	   r   r   r   find_packagesTzlib2to3.fixesc               @   s   e  Z d  Z e d f  d d d   Z e d d    Z e d d    Z e d	 d
    Z e d d    Z	 e d d    Z
 d S)PackageFinder.*c             C   sp   |  j  t |   } |  j |  } |  j |   } |  j d d |  } t | |  } t | |  } t |  S)aA  Return a list all Python packages found within directory 'where'

        'where' should be supplied as a "cross-platform" (i.e. URL-style)
        path; it will be converted to the appropriate local path syntax.
        'exclude' is a sequence of package names to exclude; '*' can be used
        as a wildcard in the names, such that 'foo.*' will exclude all
        subpackages of 'foo' (but not 'foo' itself).

        'include' is a sequence of package names to include.  If it's
        specified, only the named packages will be included.  If it's not
        specified, all found packages will be included.  'include' can contain
        shell style wildcard patterns just like 'exclude'.

        The list of included packages is built up first and then any
        explicitly excluded packages are removed from it.
        Zez_setupz*__pycache__)_find_packages_iterr   require_parents_build_filterfilterr   list)clswhereexcludeincludeoutZincludesZexcludes r   9/tmp/pip-build-tw3_dw7d/setuptools/setuptools/__init__.pyfind#   s    zPackageFinder.findc             c   sZ   g  } xM |  D]E } | j  d  \ } } } | r@ | | k r@ q | j |  | Vq Wd S)z
        Exclude any apparent package that apparently doesn't include its
        parent.

        For example, exclude 'foo.bar' if 'foo' is not present.
        r   N)
rpartitionappend)packagesfoundpkgbasesepchildr   r   r   r   =   s    zPackageFinder.require_parentsc             c   s   d d   } xs t  j |  d d D]\ \ } } } t | |  | d d  <x1 | D]) } t  j j t  j j | |  |   VqQ Wq" Wd S)zF
        Return all dirs in base_path that might be packages.
        c             S   s
   d |  k S)Nr   r   )namer   r   r   <lambda>R   s    z/PackageFinder._candidate_dirs.<locals>.<lambda>followlinksTN)oswalkr   pathrelpathjoin)	base_pathZhas_dotrootdirsfilesdirr   r   r   _candidate_dirsM   s
    %zPackageFinder._candidate_dirsc                s)    j     }    f d d   | D S)Nc             3   sE   |  ]; }  j  t j j   |   r | j t j j d   Vq d S)r   N)_looks_like_packager)   r+   r-   replacer$   ).0r+   )r.   r   r   r   	<genexpr>^   s   z4PackageFinder._find_packages_iter.<locals>.<genexpr>)r3   )r   r.   
candidatesr   )r.   r   r   r   Z   s    z!PackageFinder._find_packages_iterc             C   s   t  j j t  j j |  d   S)Nz__init__.py)r)   r+   isfiler-   )r+   r   r   r   r4   c   s    z!PackageFinder._looks_like_packagec                 s     f d d   S)z
        Given a list of patterns, return a callable that will be true only if
        the input matches one of the patterns.
        c                s   t    f d d    D  S)Nc             3   s!   |  ] } t    d  | Vq d S)patN)r   )r6   r:   )r&   r   r   r7   m   s    z@PackageFinder._build_filter.<locals>.<lambda>.<locals>.<genexpr>)any)r&   )patterns)r&   r   r'   m   s    z-PackageFinder._build_filter.<locals>.<lambda>r   )r<   r   )r<   r   r   g   s    zPackageFinder._build_filterN)r   )__name__
__module____qualname__classmethodr   staticmethodr   r3   r   r4   r   r   r   r   r   r   "   s   	r   c               @   s"   e  Z d  Z e d d    Z d S)PEP420PackageFinderc             C   s   d S)NTr   )r+   r   r   r   r4   p   s    z'PEP420PackageFinder._looks_like_packageN)r=   r>   r?   rA   r4   r   r   r   r   rB   o   s   rB   c               @   s:   e  Z d  Z e j Z d Z d d   Z d d d  Z d S)r   Fc             K   s'   t  j |  |  t |   j |  d S)zj
        Construct the command for dist, updating
        vars(self) with any keyword parameters.
        N)_Command__init__varsupdate)selfdistkwr   r   r   rD      s    zCommand.__init__r   c             K   s,   t  j |  | |  } t |  j |  | S)N)rC   reinitialize_commandrE   rF   )rG   commandreinit_subcommandsrI   cmdr   r   r   rJ      s    zCommand.reinitialize_commandN)r=   r>   r?   rC   __doc__Zcommand_consumes_argumentsrD   rJ   r   r   r   r   r   z   s   	c             C   s5   d d   t  j |  d d D } t t  j j |  S)z%
    Find all files under 'path'
    c             s   s:   |  ]0 \ } } } | D] } t  j j | |  Vq q d  S)N)r)   r+   r-   )r6   r#   r0   r1   filer   r   r   r7      s   z#_find_all_simple.<locals>.<genexpr>r(   T)r)   r*   r   r+   r9   )r+   resultsr   r   r   _find_all_simple   s    	rQ   c             C   sO   t  |   } |  t j k rE t j t j j d |  } t | |  } t |  S)z
    Find all files under 'dir' and return the list of full filenames.
    Unless dir is '.', return full filenames with dir prepended.
    start)	rQ   r)   curdir	functoolspartialr+   r,   r   r   )r2   r1   Zmake_relr   r   r   findall   s
    rV   )*rN   r)   rT   distutils.core	distutilsdistutils.filelistr   rC   distutils.utilr   fnmatchr   Zsetuptools.extern.six.movesr   r   Zsetuptools.version
setuptoolsZsetuptools.extensionr   Zsetuptools.distr   r	   r
   Zsetuptools.dependsr   __all__version__version__Zbootstrap_install_fromZrun_2to3_on_doctestsZlib2to3_fixer_packagesobjectr   rB   r   r   corer   rQ   rS   rV   filelistr   r   r   r   <module>   s8   		M	