a
    }Œ@h4  ã                   @   sn   d Z ddlZddlZddlZddlmZmZ ddlmZ ddl	m
Z
 ejdkrVdadaddd	„Zdd
d„ZdS )zì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.
é    N)ÚDistutilsPlatformErrorÚDistutilsExecError)ÚDEBUG)ÚlogÚdarwiné   c              
   C   sŽ  t | ƒ} t d | ¡¡ |r dS |r@t| d ƒ}|dur@|| d< d}tjdkrøtdu rˆddlm	} | 
d¡pndatrˆdd	„ t d
¡D ƒatrøtj dt¡}dd	„ | d
¡D ƒ}tdd… ddgkrê|dd… ddgk rêd|tf }	t|	ƒ‚ttj|d�}z tj| |d�}
|
 ¡  |
j}W nL t�yd } z2t�s8| d } td| |jd f ƒ|‚W Y d}~n
d}~0 0 |�rŠt�sz| d } td| |f ƒ‚dS )a�  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.
    ú Nr   r   )Ú	sysconfigÚMACOSX_DEPLOYMENT_TARGETÚ c                 S   s   g | ]}t |ƒ‘qS © ©Úint©Ú.0Úxr   r   ú lib/python3.9/distutils/spawn.pyÚ
<listcomp><   ó    zspawn.<locals>.<listcomp>Ú.c                 S   s   g | ]}t |ƒ‘qS r   r   r   r   r   r   r   D   r   é   é
   é   z]$MACOSX_DEPLOYMENT_TARGET mismatch: now "%s" but "%s" during configure;must use 10.3 or later)r
   )Úenvzcommand %r failed: %séÿÿÿÿz#command %r failed with exit code %s)Úlistr   ÚinfoÚjoinÚfind_executableÚsysÚplatformÚ_cfg_targetÚ	distutilsr	   Zget_config_varÚsplitÚ_cfg_target_splitÚosÚenvironÚgetr   ÚdictÚ
subprocessÚPopenÚwaitÚ
returncodeÚOSErrorr   r   Úargs)ÚcmdÚsearch_pathÚverboseZdry_runÚ
executabler   r	   Z
cur_targetZcur_target_splitZmy_msgÚprocZexitcodeÚexcr   r   r   Úspawn   s`    
ÿÿ(ýÿ
ÿÿ
ÿr5   c              	   C   sÈ   t j | ¡\}}tjdkr*|dkr*| d } t j | ¡r:| S |du r„t j dd¡}|du r„zt  d¡}W n t	t
fy‚   t j}Y n0 |sŒdS | t j¡}|D ]&}t j || ¡}t j |¡rœ|  S qœdS )zÚ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.
    Zwin32z.exeNÚPATHÚCS_PATH)r%   ÚpathÚsplitextr   r    Úisfiler&   r'   ÚconfstrÚAttributeErrorÚ
ValueErrorÚdefpathr#   Úpathsepr   )r2   r8   Ú_ZextÚpathsÚpÚfr   r   r   r   _   s(    
r   )r   r   r   )N)Ú__doc__r   r%   r)   Zdistutils.errorsr   r   Zdistutils.debugr   r"   r   r    r!   r$   r5   r   r   r   r   r   Ú<module>   s   

H