ó
RÁNc           @   s  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	 yr d  d l m
 Z d  d l m Z d  d l m Z m Z d  d l Z d e f d	 „  ƒ  YZ d
 e f d „  ƒ  YZ
 Wn$ e k
 rì d
 d d „  ƒ  YZ
 n Xd e e
 f d „  ƒ  YZ d „  Z d S(   iÿÿÿÿN(   t   build_py(   t   convert_path(   t   glob(   t	   Mixin2to3(   t   log(   t   RefactoringToolt   get_fixers_from_packaget   DistutilsRefactoringToolc           B   s#   e  Z d  „  Z d „  Z d „  Z RS(   c         O   s   t  j | | Œ d  S(   N(   R   t   error(   t   selft   msgt   argst   kw(    (    s?   /usr/lib/python2.7/dist-packages/setuptools/command/build_py.pyt	   log_error   s    c         G   s   t  j | | Œ d  S(   N(   R   t   info(   R	   R
   R   (    (    s?   /usr/lib/python2.7/dist-packages/setuptools/command/build_py.pyt   log_message   s    c         G   s   t  j | | Œ d  S(   N(   R   t   debug(   R	   R
   R   (    (    s?   /usr/lib/python2.7/dist-packages/setuptools/command/build_py.pyt	   log_debug   s    (   t   __name__t
   __module__R   R   R   (    (    (    s?   /usr/lib/python2.7/dist-packages/setuptools/command/build_py.pyR      s   		R   c           B   s&   e  Z e d  „ Z d „  Z d „  Z RS(   c         C   sŸ   |  j  j t k	 r d  S| s  d  St j d d j | ƒ ƒ |  j ƒ  |  j ƒ  | r‹ t j	 r› t
 |  j ƒ } | j | d t d t ƒq› n t j |  | ƒ d  S(   Ns   Fixing t    t   writet   doctests_only(   t   distributiont   use_2to3t   TrueR   R   t   joint   _Mixin2to3__build_fixer_namest   _Mixin2to3__exclude_fixerst
   setuptoolst   run_2to3_on_doctestsR   t   fixer_namest   refactort
   _Mixin2to3t   run_2to3(   R	   t   filest   doctestst   r(    (    s?   /usr/lib/python2.7/dist-packages/setuptools/command/build_py.pyR"      s    

	c         C   s†   |  j  r d  Sg  |  _  x' t j D] } |  j  j t | ƒ ƒ q  W|  j j d  k	 r‚ x- |  j j D] } |  j  j t | ƒ ƒ q_ Wn  d  S(   N(   R   R   t   lib2to3_fixer_packagest   extendR   R   t   use_2to3_fixerst   None(   R	   t   p(    (    s?   /usr/lib/python2.7/dist-packages/setuptools/command/build_py.pyt   __build_fixer_names(   s    	 	c         C   s„   t  |  d g  ƒ } |  j j d  k	 r: | j |  j j ƒ n  xC | D]; } | |  j k rl t j d | ƒ qA n  |  j j | ƒ qA Wd  S(   Nt   exclude_fixerss   Excluded fixer %s not found(	   t   getattrR   t   use_2to3_exclude_fixersR)   R'   R   R   t   warnt   remove(   R	   t   excluded_fixerst
   fixer_name(    (    s?   /usr/lib/python2.7/dist-packages/setuptools/command/build_py.pyt   __exclude_fixers1   s    (   R   R   t   FalseR"   R   R   (    (    (    s?   /usr/lib/python2.7/dist-packages/setuptools/command/build_py.pyR      s   		c           B   s   e  Z e d  „ Z RS(   c         C   s   d  S(   N(    (   R	   R#   R$   (    (    s?   /usr/lib/python2.7/dist-packages/setuptools/command/build_py.pyR"   =   s    (   R   R   R   R"   (    (    (    s?   /usr/lib/python2.7/dist-packages/setuptools/command/build_py.pyR   <   s   R    c           B   s¡   e  Z d  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z	 d „  Z
 d	 „  Z e j d
 k  r{ d d „ Z n  d „  Z d „  Z d „  Z 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   sc   t  j |  ƒ |  j j |  _ |  j j p+ i  |  _ d |  j k rM |  j d =n  g  |  _ g  |  _ d  S(   Nt
   data_files(   t	   _build_pyt   finalize_optionsR   t   package_datat   exclude_package_datat   __dict__t   _build_py__updated_filest   _build_py__doctests_2to3(   R	   (    (    s?   /usr/lib/python2.7/dist-packages/setuptools/command/build_py.pyR7   J   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 |  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;   R4   R   R<   t   byte_compileR6   t   get_outputs(   R	   (    (    s?   /usr/lib/python2.7/dist-packages/setuptools/command/build_py.pyt   runR   s    		
c         C   s3   | d k r# |  j  ƒ  |  _ } | St j |  | ƒ S(   NR5   (   t   _get_data_filesR5   R6   t   __getattr__(   R	   t   attrR#   (    (    s?   /usr/lib/python2.7/dist-packages/setuptools/command/build_py.pyRG   f   s     c         C   sA   t  j |  | | | ƒ \ } } | r7 |  j j | ƒ n  | | f S(   N(   R6   t   build_moduleR;   t   append(   R	   t   modulet   module_filet   packaget   outfilet   copied(    (    s?   /usr/lib/python2.7/dist-packages/setuptools/command/build_py.pyRI   k   s    c         C   s´   |  j  ƒ  g  } x |  j p d D]Œ } |  j | ƒ } t j j |  j g | j d ƒ Œ  } t | ƒ d } g  |  j	 | | ƒ D] } | | ^ q} } | j
 | | | | f ƒ q  W| S(   s?   Generate list of '(package,src_dir,build_dir,filenames)' tuplest   .i   (    (   t   analyze_manifestR?   t   get_package_dirt   ost   pathR   t	   build_libt   splitt   lent   find_data_filesRJ   (   R	   t   dataRM   t   src_dirt	   build_dirt   plent   filet	   filenames(    (    s?   /usr/lib/python2.7/dist-packages/setuptools/command/build_py.pyRF   q   s    
%)c         C   sŠ   |  j  j d g  ƒ |  j  j | g  ƒ } |  j j | g  ƒ } x6 | D]. } | j t t j j | t | ƒ ƒ ƒ ƒ qE W|  j	 | | | ƒ S(   s6   Return filenames for package's data files in 'src_dir't    (
   R8   t   gett   manifest_filesR'   R   RS   RT   R   R   t   exclude_data_files(   R	   RM   RZ   t   globsR#   t   pattern(    (    s?   /usr/lib/python2.7/dist-packages/setuptools/command/build_py.pyRX   †   s    ,c         C   sÓ   d } 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   RS   RT   R   t   mkpatht   dirnamet	   copy_filet   abspathR   t   convert_2to3_doctestsR<   RJ   (   R	   t   lastdirRM   RZ   R[   R^   t   filenamet   targett   srcfilet   outfRO   (    (    s?   /usr/lib/python2.7/dist-packages/setuptools/command/build_py.pyRB      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(    (   Ra   R   t   include_package_dataR?   t   assert_relativeRR   t   run_commandt   get_finalized_commandt   filelistR#   RS   RT   RV   R)   R   t   endswitht
   setdefaultRJ   (   R	   t   mft   src_dirsRM   t   ei_cmdRT   t   dt   ft   prevt   oldft   df(    (    s?   /usr/lib/python2.7/dist-packages/setuptools/command/build_py.pyRQ   ž   s(    !c         C   s   d  S(   N(    (   R	   (    (    s?   /usr/lib/python2.7/dist-packages/setuptools/command/build_py.pyt   get_data_files¶   s    s   2.4i   c         C   sR   t  j |  | ƒ g  |  j D]4 \ } } } } | D] } t j j | | ƒ ^ q/ q S(   sj  Return complete list of files copied to the build directory

            This includes both '.py' files and data files, as well as '.pyc'
            and '.pyo' files if 'include_bytecode' is true.  (This method is
            needed for the 'install_lib' command to do its job properly, and to
            generate a correct installation manifest.)
            (   R6   RD   R5   RS   RT   R   (   R	   R=   RM   RZ   R[   R^   Rk   (    (    s?   /usr/lib/python2.7/dist-packages/setuptools/command/build_py.pyRD   ¹   s    c         C   sí   y |  j  | SWn t k
 r" n Xt j |  | | ƒ } | |  j  | <| sY |  j j r] | Sx; |  j j D]) } | | k s | j | d ƒ rj Pqj qj W| St | d ƒ } d | j ƒ  k rß d d l	 m
 } | j d | ƒ n  | j ƒ  | S(   s8   Check namespace packages' __init__ for declare_namespaceRP   t   rUt   declare_namespaceiÿÿÿÿ(   R   s¼   WARNING: %s is a namespace package, but its __init__.py does
not declare_namespace(); setuptools 0.7 will REQUIRE this!
(See the setuptools manual under "Namespace Packages" for details.)
(   t   packages_checkedt   KeyErrorR6   t   check_packageR   t   namespace_packagest
   startswitht   opent   readt	   distutilsR   R/   t   close(   R	   RM   t   package_dirt   init_pyt   pkgR{   R   (    (    s?   /usr/lib/python2.7/dist-packages/setuptools/command/build_py.pyR„   Ç   s(    

c         C   s   i  |  _  t j |  ƒ d  S(   N(   R‚   R6   t   initialize_options(   R	   (    (    s?   /usr/lib/python2.7/dist-packages/setuptools/command/build_py.pyRŽ   æ   s    	c         C   sA   t  j |  | ƒ } |  j j d  k	 r= t j j |  j j | ƒ S| S(   N(   R6   RR   R   t   src_rootR)   RS   RT   R   (   R	   RM   t   res(    (    s?   /usr/lib/python2.7/dist-packages/setuptools/command/build_py.pyRR   ë   s    c   	      C   sÃ   |  j  j d g  ƒ |  j  j | g  ƒ } g  } x< | D]4 } | j t j | t j j | t | ƒ ƒ ƒ ƒ q5 Wt	 j
 | ƒ } i  } g  | D]6 } | | k r‰ | | k r‰ | j | d ƒ r‰ | ^ q‰ S(   s6   Filter filenames for package's data files in 'src_dir'R_   i   (   R9   R`   R'   t   fnmatcht   filterRS   RT   R   R   t   dictt   fromkeysRv   (	   R	   RM   RZ   R#   Rc   t   badRd   t   seenR{   (    (    s?   /usr/lib/python2.7/dist-packages/setuptools/command/build_py.pyRb   ò   s    &(   R   R   t   __doc__R7   RE   RG   RI   RF   RX   RB   RQ   R   t   syst   versionRD   R„   RŽ   RR   Rb   (    (    (    s?   /usr/lib/python2.7/dist-packages/setuptools/command/build_py.pyR    A   s    						
						c         C   s:   t  j j |  ƒ s |  Sd d l m } | d |  ƒ ‚ 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.
(   RS   RT   t   isabst   distutils.errorsRš   (   RT   Rš   (    (    s?   /usr/lib/python2.7/dist-packages/setuptools/command/build_py.pyRq     s
    (    (   t   os.pathRS   R˜   R‘   t   distutils.command.build_pyR    R6   t   distutils.utilR   R   R   R!   R‰   R   t   lib2to3.refactorR   R   R   R   t   ImportErrorRq   (    (    (    s?   /usr/lib/python2.7/dist-packages/setuptools/command/build_py.pyt   <module>   s   $
%Ä