
ó
/’ac            @  sa   d  d l  m Z d  d l m Z d  d l m Z d  d l Z d „  Z d d „ Z	 i  d „ Z
 d S(	   i    (   t   absolute_import(   t   defaultdict(   t   find_packagesNc         C@  s
   |  ‚ d  S(   N(    (   t   e(    (    t?   /home/mgorny/git/pyproject2setup.py/pyproject2setuppy/common.pyt	   raise_exc   s    s   .c         C@ sÔ   i  } | d k r& i  | d 6| d <n  t  j É t  j É | |  Ê Ê r| | É i  t d | d |  d É |  Ê f ƒ d 6Ê nT t  j É t  j É | |  d Ê Ê r» | É i  |  g d	 6Ê n t d
 É |  Ê ƒ ‚ | S(   s°   
    Find packages for modname, and supply proper setup() args for them.
    Supports both packages and modules in correct directory.  Includes
    all nested subpackages.
    s   .t    t   package_dirt   wheret   includes   {}.*t   packagess   .pyt
   py_moduless   No package matching {} found(	   t   ost   patht   isdirt   joint   updateR   t   formatt   isfilet   RuntimeError(   t   modnamet   subdirt   retdict(    (    R   t   auto_find_packages   s    !%c   
      C@ s  t  t ƒ } d g | d <xÞ |  D]Ö } | É | t j É | É d d Ê | É d d Ê Ê Ê } x” t É | d t ÊD]} \ } } } g  | D]' } | d k r² | É	 d Ê s² | ^ q‹ | (d | k rò t j É
 | | Ê }	 | | É |	 d Ê qu qu Wq  Wt d	 „  | É Ê  Dƒ ƒ S(
   s?   Find additional package data dirs and return package_data dict.s   *R   s   .s   /t   onerrort   __pycache__s   __init__.pys   /*c         s@  s-   |  ]# \ } } | t  t | ƒ ƒ f Vq d  S(   N(   t   sortedt	   frozenset(   t   .0t   xt   y(    (    R   t	   <genexpr>9   s    (   R   t   listt   getR   R   R   t   replacet   walkR   t
   startswitht   relpatht   appendt   dictt   items(
   R
   t   package_dirst   rett   pt   pkgdirt   topdirt   dirst   filesR   t	   data_path(    (    R   t   find_package_data(   s     !  (   t
   __future__R    t   collectionsR   t
   setuptoolsR   t   os.pathR   R   R   R1   (    (    (    R   t   <module>   s   	