ó 2ÄÈ[c@`sdZddlmZmZmZddlZddlZddlZddlm Z m Z m Z m Z ddlmZmZddlZddlmZddlmZmZe e e ejƒdd ƒƒZed „Zejjed d ƒd „ƒZdS(s\ Test scripts Test that we can run executable scripts that have been installed with numpy. i(tdivisiontprint_functiontabsolute_importN(tjointisfiletdirnametbasename(tPopentPIPE(t basestring(tassert_t assert_equals..ssetup.pyc C`st|tƒr|gn t|ƒ}tjdkrjg|D]'}d|kr[dj|ƒn|^q:}nt|dtdtƒ}|jƒ\}}|j ƒd kr³|j ƒn|r|j dkrt djddd d d dd d gƒj|||ƒƒ‚n|j ||fS(sp Run command sequence `cmd` returning exit code, stdout, stderr Parameters ---------- cmd : str or sequence string with command name or sequence of strings defining command check_code : {True, False}, optional If True, raise error for non-zero return code Returns ------- returncode : int return code from execution of `cmd` stdout : bytes (python 3) or str (python 2) stdout from `cmd` stderr : bytes (python 3) or str (python 2) stderr from `cmd` Raises ------ RuntimeError If `check_code` is True, and return code !=0 tntt s"{0}"tstdouttstderris sCommand "{0}" failed withs------s{1}ts{2}N(t isinstanceR tlisttostnametformatRRt communicatetpolltNonet terminatet returncodet RuntimeErrorR(tcmdt check_codetctprocRR((s7/tmp/pip-build-fiC0ax/numpy/numpy/tests/test_scripts.pyt run_commands$7   'treasons Cannot test f2py command inplacec C`sLtjdkr‡ttjƒ}|jdƒr:d|}n d|}ttj|dgƒ\}}}|jƒdk}t|dƒnÁtj}t |j ƒ}t |j ƒ}dd|d|d |f} t }x[| D]S}y9t|dgƒ\}}}t |jƒdƒt}PWqÚtk r,qÚXqÚWd | } t|| ƒdS( Ntwin32tScriptss %s\f2py.pys%s\Scripts\f2py.pys-vt2sWarning: f2py not found in pathtf2pyt.s/Warning: neither %s nor %s nor %s found in path(tsystplatformRt executabletendswithR tstripR t version_infotstrtmajortminortFalseR tTruet Exception( texe_dirtf2py_cmdtcodeRRtsuccesstversionR.R/t f2py_cmdstmsg((s7/tmp/pip-build-fiC0ax/numpy/numpy/tests/test_scripts.pyt test_f2py>s.  !    (t__doc__t __future__RRRR'Rtpytesttos.pathRtpathjoinRRRt subprocessRRtnumpytnptnumpy.compat.py3kR t numpy.testingR R t__file__t is_inplaceR1R tmarktskipifR:(((s7/tmp/pip-build-fiC0ax/numpy/numpy/tests/test_scripts.pyts   " ! *