B /g^c@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)NrrrMACOSX_DEPLOYMENT_TARGETZcSg|] }t|qSr ZintZ.0Zxr r r ez _spawn_posix..Z.cSrr r r!r r rr"kr#zF$MACOSX_DEPLOYMENT_TARGET mismatch: now "%s" but "%s" during configure)rzunable to execute %r: %s rz(unable to execute %r for unknown reasonsrrz"command %r terminated by signal %drz1unknown error executing %r: termination status %d)"rrrrZexecvpZexecvsysplatform _cfg_targetrZget_config_varsplit_cfg_target_splitenvirongetrZdictZexecvpeZexecveZforkrrZstderrZwriteZstrerrorZ_exitZwaitpidrrZ WIFSIGNALEDZWTERMSIGZ WIFEXITEDZ WEXITSTATUSZ WIFSTOPPED)r r r rrZexec_fnZenvZ cur_targetZmy_msgZpidZeZstatusrZ exit_statusr r rrXs      &     rc 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.exeNZPATHZCS_PATH)rpathZsplitextr$r%Zisfiler)r*ZconfstrZAttributeErrorZ ValueErrorZdefpathr'Zpathsepr)rr+Z_ZextZpathsZpZfr r rrs(     rrrrr,r,)N)Z__doc__r$rZdistutils.errorsrrZdistutils.debugrZ distutilsrrrr r%rr&r(rrr r r rZs       Q