ó
<@HOc           @   sÙ   d  Z  d Z d d l Z d d l Z d d l m Z m Z d d l m Z d d d d „ Z	 d	 „  Z
 d d d d
 „ Z d d d d „ Z e j d k r· d d l m Z d a d a n  d d d d „ Z d d „ Z d S(   sì   distutils.spawn

Provides the 'spawn()' function, a front-end to various platform-
specific functions for launching another program in a sub-process.
Also provides the 'find_executable()' to search the path for a given
executable name.
s   $Id$iÿÿÿÿN(   t   DistutilsPlatformErrort   DistutilsExecError(   t   logi   i    c         C   sƒ   t  j d k r% t |  | d | ƒnZ t  j d k rJ t |  | d | ƒn5 t  j d k ro t |  | d | ƒn t d t  j ‚ d S(   s  Run another program, specified as a command list 'cmd', in a new process.

    'cmd' is just the argument list for the new process, ie.
    cmd[0] is the program to run and cmd[1:] are the rest of its arguments.
    There is no way to run a program with a name different from that of its
    executable.

    If 'search_path' is true (the default), the system's executable
    search path will be used to find the program; otherwise, cmd[0]
    must be the exact path to the executable.  If 'dry_run' is true,
    the command will not actually be run.

    Raise DistutilsExecError if running the program fails in any way; just
    return on success.
    t   posixt   dry_runt   ntt   os2s1   don't know how to spawn programs on platform '%s'N(   t   ost   namet   _spawn_posixt	   _spawn_ntt
   _spawn_os2R    (   t   cmdt   search_patht   verboseR   (    (    sW   E:\ROMs\3DS\3DS_OfflineDecTool_v1.0\Scripts\PortablePython27\App\lib\distutils\spawn.pyt   spawn   s    c         C   s>   x7 t  |  ƒ D]) \ } } d | k r d | |  | <q q W|  S(   sª   Quote command-line arguments for DOS/Windows conventions.

    Just wraps every argument which contains blanks in double quotes, and
    returns a new argument list.
    t    s   "%s"(   t	   enumerate(   t   argst   it   arg(    (    sW   E:\ROMs\3DS\3DS_OfflineDecTool_v1.0\Scripts\PortablePython27\App\lib\distutils\spawn.pyt   _nt_quote_args+   s    c         C   sÒ   |  d } t  |  ƒ }  | r1 t | ƒ p+ | } n  t j d j | g |  d ƒ ƒ | sÎ y t j t j | |  ƒ } Wn. t k
 r¤ } t	 d |  d | d f ‚ n X| d k rÎ t	 d |  d | f ‚ qÎ n  d  S(   Ni    R   i   s   command '%s' failed: %siÿÿÿÿs'   command '%s' failed with exit status %d(
   R   t   find_executableR   t   infot   joinR   t   spawnvt   P_WAITt   OSErrorR   (   R   R   R   R   t
   executablet   rct   exc(    (    sW   E:\ROMs\3DS\3DS_OfflineDecTool_v1.0\Scripts\PortablePython27\App\lib\distutils\spawn.pyR
   ;   s    
!c         C   sá   |  d } | r% t  | ƒ p | } n  t j d j | g |  d ƒ ƒ | sÝ y t j t j | |  ƒ } Wn. t k
 r˜ } t d |  d | d f ‚ n X| d k rÝ t j	 d |  d | f ƒ t d |  d | f ‚ qÝ n  d  S(   Ni    R   i   s   command '%s' failed: %siÿÿÿÿs'   command '%s' failed with exit status %d(
   R   R   R   R   R   R   R   R   R   t   debug(   R   R   R   R   R   R   R   (    (    sW   E:\ROMs\3DS\3DS_OfflineDecTool_v1.0\Scripts\PortablePython27\App\lib\distutils\spawn.pyR   O   s    
!t   darwin(   t	   sysconfigc      
   C   s  t  j d j |  ƒ ƒ | r  d  S| r/ t j p5 t j } |  d |  g } t j d k rTt d  k r¬ t
 j d ƒ pu d a t r¬ g  t j d ƒ D] } t | ƒ ^ qŽ a q¬ n  t rTt j j d t ƒ } t g  | j d ƒ D] } t | ƒ ^ qÚ k rd | t f } t | ƒ ‚ n  t t j d | ƒ}	 | r8t j p>t j } | j |	 ƒ qTn  t j ƒ  }
 |
 d k ræy | | Œ  WnA t k
 r½} t j j d |  d | j f ƒ t j d	 ƒ n Xt j j d
 |  d ƒ t j d	 ƒ nxy t j |
 d ƒ \ }
 } WnR t k
 rY} d d  l } | j | j k r;qén  t d |  d | d f ‚ n Xt j  | ƒ rŒt d |  d t j! | ƒ f ‚ qét j" | ƒ rÔt j# | ƒ } | d k rºd  St d |  d | f ‚ qét j$ | ƒ réqéqét d |  d | f ‚ qéd  S(   NR   i    R    t   MACOSX_DEPLOYMENT_TARGETt    t   .sF   $MACOSX_DEPLOYMENT_TARGET mismatch: now "%s" but "%s" during configures   unable to execute %s: %s
i   s(   unable to execute %s for unknown reasonsiÿÿÿÿs   command '%s' failed: %ss$   command '%s' terminated by signal %ds'   command '%s' failed with exit status %ds3   unknown error executing '%s': termination status %d(%   R   R   R   R   t   execvpt   execvt   syst   platformt   _cfg_targett   NoneR!   t   get_config_vart   splitt   intt   _cfg_target_splitt   environt   getR    t   dictt   execvpet   execvet   appendt   forkR   t   stderrt   writet   strerrort   _exitt   waitpidt   errnot   EINTRR   t   WIFSIGNALEDt   WTERMSIGt	   WIFEXITEDt   WEXITSTATUSt
   WIFSTOPPED(   R   R   R   R   t   exec_fnt	   exec_argst   xt
   cur_targett   my_msgt   envt   pidt   et   statusR   R;   t   exit_status(    (    sW   E:\ROMs\3DS\3DS_OfflineDecTool_v1.0\Scripts\PortablePython27\App\lib\distutils\spawn.pyR	   h   sp    ..	c         C   s×   | d k r t j d } n  | j t j ƒ } t j j |  ƒ \ } } t j d k sd t j	 d k r} | d k r} |  d }  n  t j j
 |  ƒ sÏ x9 | D]1 } t j j | |  ƒ } t j j
 | ƒ r– | Sq– Wd S|  Sd S(   sÚ   Tries to find 'executable' in the directories listed in 'path'.

    A string listing directories separated by 'os.pathsep'; defaults to
    os.environ['PATH'].  Returns the complete filename or None if not found.
    t   PATHt   win32R   s   .exeN(   R*   R   R/   R,   t   pathsept   patht   splitextR'   R(   R   t   isfileR   (   R   RO   t   pathst   baset   extt   pt   f(    (    sW   E:\ROMs\3DS\3DS_OfflineDecTool_v1.0\Scripts\PortablePython27\App\lib\distutils\spawn.pyR   ±   s    *(   t   __doc__t   __revision__R'   R   t   distutils.errorsR    R   t	   distutilsR   R   R   R
   R   R(   R!   R*   R)   R.   R	   R   (    (    (    sW   E:\ROMs\3DS\3DS_OfflineDecTool_v1.0\Scripts\PortablePython27\App\lib\distutils\spawn.pyt   <module>   s   		I