B /g^@sdZddlZddlZddlmZmZddlmZddlm Z dddZ d d Z dd d Z ej d krvddlmZdadadddZdddZdS)zdistutils.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)DistutilsPlatformErrorDistutilsExecError)DEBUG)logcCsNt|}tjdkr"t|||dn(tjdkrt | } | dkr"dSts,|}td|| fn,t!| rPqvntsZ|}td|| fqvWdS)Nrrr$MACOSX_DEPLOYMENT_TARGETcSsg|] }t|qSr)int).0xrrr esz _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: %srz"command %r terminated by signal %dz%command %r failed with exit status %dz1unknown error executing %r: termination status %d)"rrrr execvpexecvsysplatform _cfg_targetr%Zget_config_varsplit_cfg_target_splitenvirongetrdictexecvpeexecveforkr!rstderrwritestrerror_exitwaitpidrr WIFSIGNALEDWTERMSIG WIFEXITED WEXITSTATUS WIFSTOPPED)rrrrr"Zexec_fnenvZ cur_targetZmy_msgpideZstatusr#Z exit_statusrrrr Xs      &     r c Cstj|\}}tjdkr*|dkr*|d}tj|r:|S|dkrtjdd}|dkrytd}Wnt t fk rtj }YnX|sdS| tj }x*|D]"}tj||}tj|r|SqWdS)zTries 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. Zwin32z.exeNPATHCS_PATH)r pathsplitextr/r0isfiler4r5confstrAttributeError ValueErrordefpathr2pathsepr)r"rI_Zextpathspfrrrrs(     r)rrr)rrr)rrr)N)__doc__r/r Zdistutils.errorsrrZdistutils.debugrZ distutilsrrrrr0r%r1r3r rrrrrs       Q