ó
.¿”Wc           @   s  d  d l  m  Z  d  d l m Z d  d l j j Z d  d l Z d  d l 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 m Z m Z y d  d l m Z Wn$ e k
 rà d d d „  ƒ  YZ n Xd	 e j e f d
 „  ƒ  YZ d d „ Z d „  Z d S(   iÿÿÿÿ(   t   glob(   t   convert_pathN(   t   six(   t   mapt   filtert   filterfalse(   t	   Mixin2to3R   c           B   s   e  Z e d  „ Z RS(   c         C   s   d S(   s
   do nothingN(    (   t   selft   filest   doctests(    (    s?   /tmp/pip-build-Q3rTTP/setuptools/setuptools/command/build_py.pyt   run_2to3   s    (   t   __name__t
   __module__t   TrueR
   (    (    (    s?   /tmp/pip-build-Q3rTTP/setuptools/setuptools/command/build_py.pyR      s   t   build_pyc           B   s›   e  Z d  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z	 d „  Z
 d	 „  Z d
 „  Z d „  Z d „  Z d „  Z d „  Z e d „  ƒ Z RS(   sX  Enhanced 'build_py' command that includes data files with packages

    The data files are specified via a 'package_data' argument to 'setup()'.
    See 'setuptools.dist.Distribution' for more details.

    Also, this version of the 'build_py' command allows you to specify both
    'py_modules' and 'packages' in the same setup operation.
    c         C   sf   t  j j |  ƒ |  j j |  _ |  j j p. i  |  _ d |  j k rP |  j d =n  g  |  _ g  |  _ d  S(   Nt
   data_files(	   t   origR   t   finalize_optionst   distributiont   package_datat   exclude_package_datat   __dict__t   _build_py__updated_filest   _build_py__doctests_2to3(   R   (    (    s?   /tmp/pip-build-Q3rTTP/setuptools/setuptools/command/build_py.pyR   !   s    		c         C   sª   |  j  r |  j r d S|  j  r. |  j ƒ  n  |  j rN |  j ƒ  |  j ƒ  n  |  j |  j t ƒ |  j |  j t ƒ |  j |  j	 t ƒ |  j
 t j j |  d d ƒƒ d S(   s?   Build modules, packages, and copy data files to build directoryNt   include_bytecodei    (   t
   py_modulest   packagest   build_modulest   build_packagest   build_package_dataR
   R   t   FalseR   R   t   byte_compileR   R   t   get_outputs(   R   (    (    s?   /tmp/pip-build-Q3rTTP/setuptools/setuptools/command/build_py.pyt   run+   s    		
c         C   s5   | d k r" |  j  ƒ  |  _ |  j St j j |  | ƒ S(   s   lazily compute data filesR   (   t   _get_data_filesR   R   R   t   __getattr__(   R   t   attr(    (    s?   /tmp/pip-build-Q3rTTP/setuptools/setuptools/command/build_py.pyR#   ?   s    c         C   sq   t  j r- t | t  j ƒ r- | j d ƒ } n  t j j |  | | | ƒ \ } } | rg |  j j	 | ƒ n  | | f S(   Nt   .(
   R   t   PY2t
   isinstancet   string_typest   splitR   R   t   build_moduleR   t   append(   R   t   modulet   module_filet   packaget   outfilet   copied(    (    s?   /tmp/pip-build-Q3rTTP/setuptools/setuptools/command/build_py.pyR*   F   s    c         C   s)   |  j  ƒ  t t |  j |  j p" d ƒ ƒ S(   s?   Generate list of '(package,src_dir,build_dir,filenames)' tuples(    (   t   analyze_manifestt   listR   t   _get_pkg_data_filesR   (   R   (    (    s?   /tmp/pip-build-Q3rTTP/setuptools/setuptools/command/build_py.pyR"   P   s    
c         C   sx   |  j  | ƒ } t j j |  j g | j d ƒ Œ  } g  |  j | | ƒ D] } t j j | | ƒ ^ qG } | | | | f S(   NR%   (   t   get_package_dirt   ost   patht   joint	   build_libR)   t   find_data_filest   relpath(   R   R.   t   src_dirt	   build_dirt   filet	   filenames(    (    s?   /tmp/pip-build-Q3rTTP/setuptools/setuptools/command/build_py.pyR3   U   s
    %1c         C   s‚   |  j  |  j | | ƒ } t t | ƒ } t j j | ƒ } t t j	 j
 | ƒ } t j |  j j | g  ƒ | ƒ } |  j | | | ƒ S(   s6   Return filenames for package's data files in 'src_dir'(   t   _get_platform_patternsR   R   R    t	   itertoolst   chaint   from_iterableR   R5   R6   t   isfilet   manifest_filest   gett   exclude_data_files(   R   R.   R;   t   patternst   globs_expandedt   globs_matchest
   glob_filesR   (    (    s?   /tmp/pip-build-Q3rTTP/setuptools/setuptools/command/build_py.pyR9   c   s    		c   
      C   sÍ   xÆ |  j  D]» \ } } } } x¦ | D]ž } t j j | | ƒ } |  j t j j | ƒ ƒ t j j | | ƒ } |  j | | ƒ \ } }	 t j j | ƒ } |	 r# | |  j j	 k r# |  j
 j | ƒ q# q# Wq
 Wd S(   s$   Copy data files into build directoryN(   R   R5   R6   R7   t   mkpatht   dirnamet	   copy_filet   abspathR   t   convert_2to3_doctestsR   R+   (
   R   R.   R;   R<   R>   t   filenamet   targett   srcfilet   outfR0   (    (    s?   /tmp/pip-build-Q3rTTP/setuptools/setuptools/command/build_py.pyR   t   s    c         C   s\  i  |  _  } |  j j s d  Si  } x0 |  j p2 d D] } | | t |  j | ƒ ƒ <q3 W|  j d ƒ |  j d ƒ } xã | j j	 D]Õ } t
 j j t | ƒ ƒ \ } } d  } | }	 xU | r| | k r| | k r| } t
 j j | ƒ \ } }
 t
 j j |
 | ƒ } q² W| | k r | j d ƒ r4| |	 k r4q n  | j | | g  ƒ j | ƒ q q Wd  S(   Nt   egg_infos   .py(    (   RD   R   t   include_package_dataR   t   assert_relativeR4   t   run_commandt   get_finalized_commandt   filelistR   R5   R6   R)   t   NoneR7   t   endswitht
   setdefaultR+   (   R   t   mft   src_dirsR.   t   ei_cmdR6   t   dt   ft   prevt   oldft   df(    (    s?   /tmp/pip-build-Q3rTTP/setuptools/setuptools/command/build_py.pyR1      s(    !c         C   s   d  S(   N(    (   R   (    (    s?   /tmp/pip-build-Q3rTTP/setuptools/setuptools/command/build_py.pyt   get_data_files™   s    c         C   sñ   y |  j  | SWn t k
 r" n Xt j j |  | | ƒ } | |  j  | <| s\ |  j j r` | Sx; |  j j D]) } | | k s’ | j | d ƒ rm Pqm qm W| St j	 | d ƒ  } | j
 ƒ  } Wd QXd | k rí t j j d | f ƒ ‚ n  | S(   s8   Check namespace packages' __init__ for declare_namespaceR%   t   rbNt   declare_namespacesÁ   Namespace package problem: %s is a namespace package, but its
__init__.py does not call declare_namespace()! Please fix it.
(See the setuptools manual under "Namespace Packages" for details.)
"(   t   packages_checkedt   KeyErrorR   R   t   check_packageR   t   namespace_packagest
   startswitht   iot   opent   readt	   distutilst   errorst   DistutilsError(   R   R.   t   package_dirt   init_pyt   pkgRa   t   contents(    (    s?   /tmp/pip-build-Q3rTTP/setuptools/setuptools/command/build_py.pyRj   œ   s&    	c         C   s   i  |  _  t j j |  ƒ d  S(   N(   Rh   R   R   t   initialize_options(   R   (    (    s?   /tmp/pip-build-Q3rTTP/setuptools/setuptools/command/build_py.pyRw   º   s    	c         C   sD   t  j j |  | ƒ } |  j j d  k	 r@ t j j |  j j | ƒ S| S(   N(	   R   R   R4   R   t   src_rootRZ   R5   R6   R7   (   R   R.   t   res(    (    s?   /tmp/pip-build-Q3rTTP/setuptools/setuptools/command/build_py.pyR4   ¾   s    c            s~   t  ˆ ƒ ‰ |  j |  j | | ƒ } ‡ f d †  | Dƒ } t j j | ƒ } t | ƒ ‰  ‡  f d †  ˆ Dƒ } t  t | ƒ ƒ S(   s6   Filter filenames for package's data files in 'src_dir'c         3   s!   |  ] } t  j ˆ  | ƒ Vq d  S(   N(   t   fnmatchR   (   t   .0t   pattern(   R   (    s?   /tmp/pip-build-Q3rTTP/setuptools/setuptools/command/build_py.pys	   <genexpr>Í   s   c         3   s!   |  ] } | ˆ  k r | Vq d  S(   N(    (   R{   t   fn(   t   bad(    s?   /tmp/pip-build-Q3rTTP/setuptools/setuptools/command/build_py.pys	   <genexpr>Ô   s   (   R2   R?   R   R@   RA   RB   t   sett   _unique_everseen(   R   R.   R;   R   RG   t   match_groupst   matchest   keepers(    (   R~   R   s?   /tmp/pip-build-Q3rTTP/setuptools/setuptools/command/build_py.pyRF   Ä   s    	

c            s>   t  j |  j d g  ƒ |  j | g  ƒ ƒ } ‡  f d †  | Dƒ S(   sÜ   
        yield platfrom-specific path patterns (suitable for glob
        or fn_match) from a glob-based spec (such as
        self.package_data or self.exclude_package_data)
        matching package in src_dir.
        t    c         3   s*   |  ]  } t  j j ˆ  t | ƒ ƒ Vq d  S(   N(   R5   R6   R7   R   (   R{   R|   (   R;   (    s?   /tmp/pip-build-Q3rTTP/setuptools/setuptools/command/build_py.pys	   <genexpr>é   s   (   R@   RA   RE   (   t   specR.   R;   t   raw_patterns(    (   R;   s?   /tmp/pip-build-Q3rTTP/setuptools/setuptools/command/build_py.pyR?   Û   s
    (   R   R   t   __doc__R   R!   R#   R*   R"   R3   R9   R   R1   Re   Rj   Rw   R4   RF   t   staticmethodR?   (    (    (    s?   /tmp/pip-build-Q3rTTP/setuptools/setuptools/command/build_py.pyR      s    	
			
										c         c   sŒ   t  ƒ  } | j } | d k rM xg t | j |  ƒ D] } | | ƒ | Vq1 Wn; x8 |  D]0 } | | ƒ } | | k rT | | ƒ | VqT qT Wd S(   sH   List unique elements, preserving order. Remember all elements ever seen.N(   R   t   addRZ   R   t   __contains__(   t   iterablet   keyt   seent   seen_addt   elementt   k(    (    s?   /tmp/pip-build-Q3rTTP/setuptools/setuptools/command/build_py.pyR€   ï   s    		

c         C   sO   t  j j |  ƒ s |  Sd d l m } t j d ƒ j ƒ  |  } | | ƒ ‚ d  S(   Niÿÿÿÿ(   t   DistutilsSetupErrorsÓ   
        Error: setup script specifies an absolute path:

            %s

        setup() arguments must *always* be /-separated paths relative to the
        setup.py directory, *never* absolute paths.
        (   R5   R6   t   isabst   distutils.errorsR‘   t   textwrapt   dedentt   lstrip(   R6   R‘   t   msg(    (    s?   /tmp/pip-build-Q3rTTP/setuptools/setuptools/command/build_py.pyRV     s    (    (   R    t   distutils.utilR   t   distutils.command.build_pyt   commandR   R   R5   Rz   R”   Rm   R“   Rp   R@   t   setuptools.externR   t   setuptools.extern.six.movesR   R   R   t   setuptools.lib2to3_exR   t   ImportErrorRZ   R€   RV   (    (    (    s?   /tmp/pip-build-Q3rTTP/setuptools/setuptools/command/build_py.pyt   <module>   s"   Ø