3 \�@s�dZddlZddlZddlmZmZddlmZddlm Z ddd�Z d d �Z dd d �Z ej d krvddlmZdadaddd�Zddd�ZdS)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�cCsNt|�}tjdkr"t|||d�n(tjdkresz _spawn_posix..�.cSsg|] }t|��qSr)r()r)r*rrrr+kszF$MACOSX_DEPLOYMENT_TARGET mismatch: now "%s" but "%s" during configure)r&zunable to execute %r: %s rz(unable to execute %r for unknown reasonszcommand %r failed: %sz"command %r terminated by signal %dz%command %r failed with exit status %dz1unknown error executing %r: termination status %dr)"rrrr �execvp�execv�sys�platform� _cfg_targetr%�get_config_var�split�_cfg_target_split�environ�getr�dict�execvpe�execve�forkr!r�stderr�write�strerror�_exit�waitpidrr� WIFSIGNALED�WTERMSIG� WIFEXITED� WEXITSTATUS� WIFSTOPPED)rrrrr"Zexec_fn�envZ cur_targetZmy_msg�pid�eZstatusr#Z exit_statusrrrr Xs�     &     r cCs�|dkrtjjdtj�}|jtj�}tjj|�\}}tj dkrN|dkrN|d}tjj |�s�x*|D]"}tjj ||�}tjj |�r`|Sq`WdS|SdS)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. N�PATHZwin32z.exe) r r5r6�defpathr3�pathsep�path�splitextr/r0�isfiler)r"rK�paths�baseZext�p�frrrr�s    r)rrr)rrr)rrr)N)�__doc__r/r Zdistutils.errorsrrZdistutils.debugrZ distutilsrrrrr0r%r1r4r rrrrr�s       Q