ó
ÏrOc           @   sw   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 e f d „  ƒ  YZ d „  Z
 d S(   iÿÿÿÿN(   t   build_py(   t   convert_path(   t   globR    c           B   s   e  Z d  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z	 d „  Z
 e j d	 k  rr d
 d „ Z n  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   sQ   t  j |  ƒ |  j j |  _ |  j j p+ i  |  _ d |  j k rM |  j d =n  d  S(   Nt
   data_files(   t	   _build_pyt   finalize_optionst   distributiont   package_datat   exclude_package_datat   __dict__(   t   self(    (    s?   /var/www/python/setuptools-0.6c9/setuptools/command/build_py.pyR      s
     c         C   sn   |  j  r |  j r d S|  j  r. |  j ƒ  n  |  j rN |  j ƒ  |  j ƒ  n  |  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_datat   byte_compileR   t   get_outputs(   R
   (    (    s?   /var/www/python/setuptools-0.6c9/setuptools/command/build_py.pyt   run   s    		
c         C   s3   | d k r# |  j  ƒ  |  _ } | St j |  | ƒ S(   NR   (   t   _get_data_filesR   R   t   __getattr__(   R
   t   attrt   files(    (    s?   /var/www/python/setuptools-0.6c9/setuptools/command/build_py.pyR   %   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   patht   joint	   build_libt   splitt   lent   find_data_filest   append(   R
   t   datat   packaget   src_dirt	   build_dirt   plent   filet	   filenames(    (    s?   /var/www/python/setuptools-0.6c9/setuptools/command/build_py.pyR   *   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    (
   R   t   gett   manifest_filest   extendR   R   R   R   R   t   exclude_data_files(   R
   R$   R%   t   globsR   t   pattern(    (    s?   /var/www/python/setuptools-0.6c9/setuptools/command/build_py.pyR!   ?   s    ,c         C   sˆ   d } x{ |  j D]p \ } } } } x[ | D]S } t j j | | ƒ } |  j t j j | ƒ ƒ |  j t j j | | ƒ | ƒ q) Wq Wd S(   s$   Copy data files into build directoryN(   t   NoneR   R   R   R   t   mkpatht   dirnamet	   copy_file(   R
   t   lastdirR$   R%   R&   R)   t   filenamet   target(    (    s?   /var/www/python/setuptools-0.6c9/setuptools/command/build_py.pyR   I   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(    (   R,   R   t   include_package_dataR   t   assert_relativeR   t   run_commandt   get_finalized_commandt   filelistR   R   R   R   R1   R   t   endswitht
   setdefaultR"   (   R
   t   mft   src_dirsR$   t   ei_cmdR   t   dt   ft   prevt   oldft   df(    (    s?   /var/www/python/setuptools-0.6c9/setuptools/command/build_py.pyR   S   s(    !c         C   s   d  S(   N(    (   R
   (    (    s?   /var/www/python/setuptools-0.6c9/setuptools/command/build_py.pyt   get_data_filesk   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.)
            (   R   R   R   R   R   R   (   R
   R   R$   R%   R&   R)   R6   (    (    s?   /var/www/python/setuptools-0.6c9/setuptools/command/build_py.pyR   n   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_namespaceR   t   rUt   declare_namespaceiÿÿÿÿ(   t   logs¼   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   KeyErrorR   t   check_packageR   t   namespace_packagest
   startswitht   opent   readt	   distutilsRK   t   warnt   close(   R
   R$   t   package_dirt   init_pyt   pkgRD   RK   (    (    s?   /var/www/python/setuptools-0.6c9/setuptools/command/build_py.pyRN   |   s(    

c         C   s   i  |  _  t j |  ƒ d  S(   N(   RL   R   t   initialize_options(   R
   (    (    s?   /var/www/python/setuptools-0.6c9/setuptools/command/build_py.pyRY   ›   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   (   R   R+   R-   t   fnmatcht   filterR   R   R   R   t   dictt   fromkeysR?   (	   R
   R$   R%   R   R/   t   badR0   t   seenRD   (    (    s?   /var/www/python/setuptools-0.6c9/setuptools/command/build_py.pyR.   ¥   s    &(   t   __name__t
   __module__t   __doc__R   R   R   R   R!   R   R   RH   t   syst   versionR   RN   RY   R.   (    (    (    s?   /var/www/python/setuptools-0.6c9/setuptools/command/build_py.pyR       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.
(   R   R   t   isabst   distutils.errorsRe   (   R   Re   (    (    s?   /var/www/python/setuptools-0.6c9/setuptools/command/build_py.pyR:   ¸   s
    (   t   os.pathR   Rc   RZ   t   distutils.command.build_pyR    R   t   distutils.utilR   R   R:   (    (    (    s?   /var/www/python/setuptools-0.6c9/setuptools/command/build_py.pyt   <module>   s
   $²