
>gT                 @   s   d  d l  Z  d  d l m Z d  d l m Z d  d l m Z m Z m Z d  d l	 m
 Z
 d  d l m Z m Z e  j d  Z d Z d	 d
   Z Gd d   d e  Z d S)    N)glob1)remove)existsisdirjoin)rmtree)Baseshell_commandZdhpythonzsetup.py|setup-3.pyc                s"     f d d   }   j  | _  | S)zdistutils doesn't have sane command-line API - this decorator creates
    .pydistutils.cfg file to workaround it

    hint: if you think this is plain stupid, please don't read
    distutils/setuptools/distribute sources
    c                s   t  | d d  } t |  s t | d d d F } | j d d d d	 j | d
  d d d d j | d  g  Wd  QXn  | d | d d <  |  | | | |  S)NZhome_dirz.pydistutils.cfgwencodingzutf-8z[clean]
zall=1
z[build]
zbuild-lib={}
Z	build_dirz
[install]
zinstall-layout=deb
zinstall-scripts=/usr/bin
zinstall-lib={}
Zinstall_dirZENVHOME)r   r   open
writelinesformat)selfcontextargsZoargskwargsfpathfp)func 7/usr/share/dh-python/dhpython/build/plugin_distutils.pywrapped_func(   s    	 z,create_pydistutils_cfg.<locals>.wrapped_func)__name__)r   r   r   )r   r   create_pydistutils_cfg    s    r   c                   s   e  Z d  Z d Z d d d d d d d h Z e g Z i d	 d
 6d	 d 6d d 6d d 6Z   f d d   Z e	 e
   f d d     Z e	 e
 d d     Z e	 e
 d d     Z e	 e
 d d     Z e	 e
   f d d     Z   S)BuildSystemzDistutils build systempythonpython3zpython{version}z
python-dbgzpython3-dbgzpython{version}-dbgZpypy   z	setup.cfgzrequirements.txt
   zPKG-INFOz
*.egg-infoc                sU   t  t |   j |  } t |  j k rC |  j t d | d d <n d | d d <| S)Nr   r   setup_pyzsetup.py)superr   detect
_setup_tplZDETECTED_REQUIRED_FILES)r   r   result)	__class__r   r   r#   F   s
    zBuildSystem.detectc                s   t  t |   j | |  t | d d  } t |  oA t |  xP t | d d  D]; } t | d |  } t |  r t |  n	 t |  qV Wt | d j	    r d Sd S)Ndirbuildz
*.egg-infoZinterpreterz%{interpreter} {setup_py} clean {args}r   )
r"   r   cleanr   r   r   r   r   r   Zbinary)r   r   r   Zdpathfnamer   )r&   r   r   r)   N   s    &zBuildSystem.cleanc             C   s   d S)Nz&{interpreter} {setup_py} config {args}r   )r   r   r   r   r   r   	configure[   s    zBuildSystem.configurec             C   s   d S)Nz/{interpreter.binary_dv} {setup_py} build {args}r   )r   r   r   r   r   r   r(   `   s    zBuildSystem.buildc             C   s   d S)NzB{interpreter.binary_dv} {setup_py} install --root {destdir} {args}r   )r   r   r   r   r   r   installe   s    zBuildSystem.installc          	      sv   |  j  j s] t | d | d  } t | d  & } | j   j d  d k rT d SWd  QXn  t t |   j | |  S)Nr'   r!   rbs
   test_suiter   z${interpreter} {setup_py} test {args})	ZcfgZcustom_testsr   r   readfindr"   r   test)r   r   r   r   r   )r&   r   r   r0   j   s    zBuildSystem.test)r   
__module____qualname__ZDESCRIPTIONZSUPPORTED_INTERPRETERSr$   ZREQUIRED_FILESZOPTIONAL_FILESr#   r	   r   r)   r+   r(   r,   r0   r   r   )r&   r   r   ;   s(   				

r   )ZloggingZglobr   osr   os.pathr   r   r   Zshutilr   Zdhpython.build.baser   r	   Z	getLoggerlogr$   r   r   r   r   r   r   <module>   s   